mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 20:53:40 -04:00
Add a basic PlayerActions class.
This commit is contained in:
parent
9a1a252f45
commit
e4ecb67bc7
@ -33,18 +33,19 @@ namespace MCGalaxy.BlockBehaviour {
|
||||
if (last == -1) { Portals.Dispose(); return true; }
|
||||
|
||||
DataRow row = Portals.Rows[last];
|
||||
if (p.level.name != row["ExitMap"].ToString()) {
|
||||
string map = row["ExitMap"].ToString();
|
||||
if (p.level.name != map) {
|
||||
if (p.level.permissionvisit > p.group.Permission) {
|
||||
Player.Message(p, "You do not have the adequate rank to visit this map!"); return true;
|
||||
}
|
||||
|
||||
p.ignorePermission = true;
|
||||
Level curLevel = p.level;
|
||||
Command.all.Find("goto").Use(p, row["ExitMap"].ToString());
|
||||
PlayerActions.ChangeMap(p, map);
|
||||
if (curLevel == p.level) { Player.Message(p, "The map the portal goes to isn't loaded."); return true; }
|
||||
p.ignorePermission = false;
|
||||
}
|
||||
p.BlockUntilLoad(10);
|
||||
p.BlockUntilLoad(10);
|
||||
}
|
||||
Command.all.Find("move").Use(p, p.name + " " + row["ExitX"].ToString() + " " + row["ExitY"].ToString() + " " + row["ExitZ"].ToString());
|
||||
Portals.Dispose();
|
||||
} catch {
|
||||
|
@ -63,7 +63,7 @@ namespace MCGalaxy.Commands
|
||||
Level[] loaded = LevelInfo.Loaded.Items;
|
||||
if (!loaded.Any(l => l.name == mapname))
|
||||
Command.all.Find("load").Use(p, mapname);
|
||||
Command.all.Find("goto").Use(p, mapname);
|
||||
PlayerActions.ChangeMap(p, mapname);
|
||||
} else if (cmd == "LB" || cmd == "LEVELBLOCK") {
|
||||
string[] lbArgs = message.Split(trimChars, 2);
|
||||
string lbArg = lbArgs.Length > 1 ? lbArgs[1] : "";
|
||||
@ -82,15 +82,15 @@ namespace MCGalaxy.Commands
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players) {
|
||||
if (pl.level == p.level && pl.name != p.name)
|
||||
Command.all.Find("goto").Use(pl, Server.mainLevel.name);
|
||||
PlayerActions.ChangeMap(pl, Server.mainLevel.name);
|
||||
}
|
||||
} else if (cmd == "KICK") {
|
||||
if (arg == "") { p.SendMessage("You must specify a player to kick."); return; }
|
||||
|
||||
Player kicked = PlayerInfo.FindOrShowMatches(p, arg);
|
||||
if (kicked != null) {
|
||||
if (kicked.level.name == p.level.name)
|
||||
Command.all.Find("goto").Use(kicked, Server.mainLevel.name);
|
||||
Player pl = PlayerInfo.FindOrShowMatches(p, arg);
|
||||
if (pl != null) {
|
||||
if (pl.level.name == p.level.name)
|
||||
PlayerActions.ChangeMap(pl, Server.mainLevel.name);
|
||||
else
|
||||
p.SendMessage("Player is not on your level!");
|
||||
}
|
||||
@ -324,7 +324,7 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
Player.Message(p, blocked.name + " has been blacklisted from your map.");
|
||||
if (blocked.level.name == p.level.name) {
|
||||
Command.all.Find("goto").Use(blocked, Server.mainLevel.name); return;
|
||||
PlayerActions.ChangeMap(blocked, Server.mainLevel.name); return;
|
||||
}
|
||||
} else if (cmd == "UNBLOCK") {
|
||||
if (value == "") {
|
||||
|
@ -50,9 +50,9 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
switch (cmd) {
|
||||
case "help":
|
||||
Command.all.Find("help").Use(p, "countdown"); return;
|
||||
Help(p); return;
|
||||
case "goto":
|
||||
Command.all.Find("goto").Use(p, "countdown"); return;
|
||||
PlayerActions.ChangeMap(p, "countdown"); return;
|
||||
case "join":
|
||||
HandleJoin(p); return;
|
||||
case "leave":
|
||||
@ -238,7 +238,7 @@ namespace MCGalaxy.Commands {
|
||||
const string format = "Generated map ({0}x{1}x{2}), sending you to it..";
|
||||
Player.Message(p, format, width, height, length);
|
||||
Command.all.Find("load").Use(p, "countdown");
|
||||
Command.all.Find("goto").Use(p, "countdown");
|
||||
PlayerActions.ChangeMap(p, "countdown");
|
||||
|
||||
p.level.permissionbuild = LevelPermission.Nobody;
|
||||
p.level.motd = "Welcome to the Countdown map!!!! -hax";
|
||||
|
@ -39,7 +39,7 @@ namespace MCGalaxy.Commands
|
||||
if (s[0] == "go")
|
||||
{
|
||||
if (!Server.lava.active) { Player.Message(p, "There is no Lava Survival game right now."); return; }
|
||||
Command.all.Find("goto").Use(p, Server.lava.map.name);
|
||||
PlayerActions.ChangeMap(p, Server.lava.map.name);
|
||||
return;
|
||||
}
|
||||
if (s[0] == "info")
|
||||
|
@ -63,7 +63,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
if (p != null && who.level != p.level) {
|
||||
Player.Message(p, "Moving player to your map...");
|
||||
Command.all.Find("goto").Use(who, p.level.name);
|
||||
PlayerActions.ChangeMap(who, p.level.name);
|
||||
who.BlockUntilLoad(500);
|
||||
}
|
||||
Player.GlobalMessage(who.ColoredName + " %Shas been locked down!");
|
||||
|
@ -34,7 +34,7 @@ namespace MCGalaxy.Commands
|
||||
return;
|
||||
}
|
||||
if (p.level.name.ToLower() != p.beforeTeleportMap.ToLower())
|
||||
Command.all.Find("goto").Use(p, p.beforeTeleportMap);
|
||||
PlayerActions.ChangeMap(p, p.beforeTeleportMap);
|
||||
p.SendPos(0xFF, p.beforeTeleportPos[0], p.beforeTeleportPos[1], p.beforeTeleportPos[2], 0, 0);
|
||||
}
|
||||
public override void Help(Player p)
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Commands {
|
||||
if (p.level.name == Server.mainLevel.name) {
|
||||
Player.Message(p, "You are already on the server's main level."); return;
|
||||
}
|
||||
Command.all.Find("goto").Use(p, Server.mainLevel.name);
|
||||
PlayerActions.ChangeMap(p, Server.mainLevel.name);
|
||||
} else {
|
||||
if (!CheckAdditionalPerm(p)) { MessageNeedPerms(p, "change the main level"); return; }
|
||||
if (!Player.ValidName(message)) {
|
||||
|
@ -51,7 +51,7 @@ namespace MCGalaxy.Commands
|
||||
MessageTooHighRank(p, "move", true); return;
|
||||
}
|
||||
|
||||
Command.all.Find("goto").Use(who, where.name);
|
||||
PlayerActions.ChangeMap(who, where.name);
|
||||
if (who.level == where)
|
||||
Player.Message(p, "Sent " + who.ColoredName + " %Sto " + where.name);
|
||||
else
|
||||
@ -77,10 +77,7 @@ namespace MCGalaxy.Commands
|
||||
ushort x = ushort.Parse(args[offset + 0]);
|
||||
ushort y = ushort.Parse(args[offset + 1]);
|
||||
ushort z = ushort.Parse(args[offset + 2]);
|
||||
x *= 32; x += 16;
|
||||
y *= 32;
|
||||
z *= 32; z += 16;
|
||||
who.SendOwnFeetPos(x, y, z, p.rot[0], p.rot[1]);
|
||||
PlayerActions.MoveCoords(who, x, y, z);
|
||||
if (p != who) Player.Message(p, "Moved " + who.color + who.name);
|
||||
}
|
||||
catch { Player.Message(p, "Invalid co-ordinates"); }
|
||||
|
@ -57,7 +57,7 @@ namespace MCGalaxy.Commands
|
||||
if (p.level != who.level)
|
||||
{
|
||||
Player.Message(p, who.ColoredName + " %Sis in a different Level. Forcefetching has started!");
|
||||
Command.all.Find("goto").Use(who, p.level.name);
|
||||
PlayerActions.ChangeMap(who, p.level.name);
|
||||
Thread.Sleep(1000);
|
||||
// Sleep for a bit while they load
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace MCGalaxy.Commands {
|
||||
p.beforeTeleportPos = p.pos;
|
||||
|
||||
if (p.level != target.level)
|
||||
Command.all.Find("goto").Use(p, target.level.name);
|
||||
PlayerActions.ChangeMap(p, target.level.name);
|
||||
if (target.Loading) {
|
||||
Player.Message(p, "Waiting for " + target.ColoredName + " %Sto spawn...");
|
||||
target.BlockUntilLoad(10);
|
||||
|
@ -100,7 +100,7 @@ namespace MCGalaxy.Commands {
|
||||
if (p.level != who.level)
|
||||
{
|
||||
Level where = p.level;
|
||||
Command.all.Find("goto").Use(who, where.name);
|
||||
PlayerActions.ChangeMap(who, where.name);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ namespace MCGalaxy.Eco {
|
||||
Level level = LevelInfo.Find(name);
|
||||
if (level.permissionbuild > p.group.Permission) { level.permissionbuild = p.group.Permission; }
|
||||
if (level.permissionvisit > p.group.Permission) { level.permissionvisit = p.group.Permission; }
|
||||
Command.all.Find("goto").Use(p, name);
|
||||
PlayerActions.ChangeMap(p, name);
|
||||
|
||||
Player.Message(p, "%aSuccessfully created your map: '%f" + name + "%a'");
|
||||
try {
|
||||
|
@ -29,7 +29,7 @@ namespace MCGalaxy.Games {
|
||||
Player.Message(p, "You've joined the Countdown game!!");
|
||||
Player.GlobalMessage(p.name + " has joined Countdown!!");
|
||||
if (p.level != Server.Countdown.mapon)
|
||||
Command.all.Find("goto").Use(p, "countdown");
|
||||
PlayerActions.ChangeMap(p, "countdown");
|
||||
p.playerofcountdown = true;
|
||||
} else {
|
||||
Player.Message(p, "Sorry, you have already joined!!, to leave please type /countdown leave");
|
||||
|
@ -63,7 +63,7 @@ namespace MCGalaxy.Games {
|
||||
foreach (Player pl in players) {
|
||||
if (pl.level != mapon) {
|
||||
pl.SendMessage("Sending you to the correct map.");
|
||||
Command.all.Find("goto").Use(pl, mapon.name);
|
||||
PlayerActions.ChangeMap(pl, mapon.name);
|
||||
}
|
||||
p.SpawnEntity(p, 0xFF, x1, y1, z1, 0, 0);
|
||||
}
|
||||
|
@ -306,8 +306,10 @@ namespace MCGalaxy.Games
|
||||
pl.Game.PledgeSurvive = false;
|
||||
if (pl.level == oldMap)
|
||||
{
|
||||
if (sendAfkMain && pl.IsAfk) Command.all.Find("main").Use(pl, "");
|
||||
else Command.all.Find("goto").Use(pl, map.name);
|
||||
if (sendAfkMain && pl.IsAfk)
|
||||
PlayerActions.ChangeMap(pl, Server.mainLevel.name);
|
||||
else
|
||||
PlayerActions.ChangeMap(pl, map.name);
|
||||
}
|
||||
}
|
||||
if (OnMapChange != null)
|
||||
|
@ -157,7 +157,7 @@ namespace MCGalaxy.Games
|
||||
{
|
||||
foreach (player p in Players.Where(p => p.p.level != lvl))
|
||||
{
|
||||
Command.all.Find("goto").Use(p.p, lvl.name);
|
||||
PlayerActions.ChangeMap(p.p, lvl.name);
|
||||
p.p.inTNTwarsMap = true;
|
||||
}
|
||||
if (GameMode == TntWarsGameMode.TDM) { Command.all.Find("reveal").Use(null, "all " + lvl.name); }//So peoples names apear above their heads in the right color!
|
||||
|
@ -123,7 +123,7 @@ namespace MCGalaxy.Games {
|
||||
pl.Game.PledgeSurvive = false;
|
||||
if (!pl.level.name.CaselessEq(next) && pl.level.name.CaselessEq(LastLevelName)) {
|
||||
pl.SendMessage("Going to the next map - &a" + next);
|
||||
Command.all.Find("goto").Use(pl, next);
|
||||
PlayerActions.ChangeMap(pl, next);
|
||||
}
|
||||
}
|
||||
if (LastLevelName != "")
|
||||
|
@ -421,7 +421,7 @@ namespace MCGalaxy
|
||||
foreach (Player p in players) {
|
||||
if (p.level.name.ToLower() == name.ToLower()) {
|
||||
Player.Message(p, "You were moved to the main level as " + name + " was unloaded.");
|
||||
Command.all.Find("goto").Use(p, Server.mainLevel.name);
|
||||
PlayerActions.ChangeMap(p, Server.mainLevel.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -524,6 +524,7 @@
|
||||
<Compile Include="Player\Group\GroupCommands.cs" />
|
||||
<Compile Include="Player\Group\GroupProperties.cs" />
|
||||
<Compile Include="Player\Player.Handlers.cs" />
|
||||
<Compile Include="Player\PlayerActions.cs" />
|
||||
<Compile Include="Player\PlayerInfo.cs" />
|
||||
<Compile Include="Player\PlayersFile.cs" />
|
||||
<Compile Include="Player\TabList.cs" />
|
||||
|
@ -393,7 +393,7 @@ namespace MCGalaxy {
|
||||
aiming = false;
|
||||
} catch( Exception ex ) {
|
||||
success = false;
|
||||
Command.all.Find("goto").Use(this, Server.mainLevel.name);
|
||||
PlayerActions.ChangeMap(this, Server.mainLevel.name);
|
||||
SendMessage("There was an error sending the map data, you have been sent to the main level.");
|
||||
Server.ErrorLog(ex);
|
||||
} finally {
|
||||
|
@ -676,7 +676,7 @@ namespace MCGalaxy {
|
||||
reader.Dispose();
|
||||
|
||||
try {
|
||||
Command.all.Find("goto").Use(this, parts[1]);
|
||||
PlayerActions.ChangeMap(this, parts[1]);
|
||||
Command.all.Find("jail").Use(null, parts[0]);
|
||||
} catch (Exception ex) {
|
||||
Kick("Error occured");
|
||||
|
41
Player/PlayerActions.cs
Normal file
41
Player/PlayerActions.cs
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2011 MCForge
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
namespace MCGalaxy {
|
||||
public static class PlayerActions {
|
||||
|
||||
/// <summary> Moves the player to the specified block coordinates. </summary>
|
||||
public static void MoveCoords(Player p, int bX, int bY, int bZ) {
|
||||
MoveCoords(p, bX, bY, bZ, p.rot[0], p.rot[1]);
|
||||
}
|
||||
|
||||
/// <summary> Moves the player to the specified block coordinates. </summary>
|
||||
public static void MoveCoords(Player p, int bX, int bY, int bZ,
|
||||
byte rotX, byte rotY) {
|
||||
ushort x = (ushort)(bX * 32 + 16);
|
||||
ushort y = (ushort)(bY * 32);
|
||||
ushort z = (ushort)(bZ * 32 + 16);
|
||||
p.SendOwnFeetPos(x, y, z, rotX, rotY);
|
||||
}
|
||||
|
||||
/// <summary> Moves the player to the specified map. </summary>
|
||||
public static void ChangeMap(Player p, string name) {
|
||||
Command.all.Find("goto").Use(p, name);
|
||||
}
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ namespace MCGalaxy {
|
||||
|
||||
Level lvl = LevelInfo.FindExact(wp.lvlname);
|
||||
if (p.level != lvl)
|
||||
Command.all.Find("goto").Use(p, wp.lvlname);
|
||||
PlayerActions.ChangeMap(p, wp.lvlname);
|
||||
|
||||
if (p.level.name.CaselessEq(wp.lvlname)) {
|
||||
p.SendPos(0xFF, wp.x, wp.y, wp.z, wp.rotx, wp.roty);
|
||||
|
Loading…
x
Reference in New Issue
Block a user