diff --git a/MCGalaxy/Blocks/Extended/Portal.cs b/MCGalaxy/Blocks/Extended/Portal.cs index 9831bc297..8da32aeb5 100644 --- a/MCGalaxy/Blocks/Extended/Portal.cs +++ b/MCGalaxy/Blocks/Extended/Portal.cs @@ -30,7 +30,7 @@ namespace MCGalaxy.Blocks.Extended { "WHERE EntryX=@0 AND EntryY=@1 AND EntryZ=@2", x, y, z); int last = Portals.Rows.Count - 1; if (last == -1) { Portals.Dispose(); return false; } - byte yaw = p.Rot.RotY, pitch = p.Rot.HeadX; + Orientation rot = p.Rot; DataRow row = Portals.Rows[last]; string map = row["ExitMap"].ToString(); @@ -49,7 +49,9 @@ namespace MCGalaxy.Blocks.Extended { x = ushort.Parse(row["ExitX"].ToString()); y = ushort.Parse(row["ExitY"].ToString()); z = ushort.Parse(row["ExitZ"].ToString()); - PlayerActions.MoveCoords(p, x, y, z, yaw, pitch); + + Position pos = Position.FromFeetBlockCoords(x, y, z); + p.SendPos(Entities.SelfID, pos, rot); Portals.Dispose(); return true; } catch { diff --git a/MCGalaxy/Commands/World/CmdDeleteLvl.cs b/MCGalaxy/Commands/World/CmdDeleteLvl.cs index 1a90267b4..a8870a38b 100644 --- a/MCGalaxy/Commands/World/CmdDeleteLvl.cs +++ b/MCGalaxy/Commands/World/CmdDeleteLvl.cs @@ -45,7 +45,7 @@ namespace MCGalaxy.Commands.World { public override void Help(Player p) { Player.Message(p, "%T/DeleteLvl [map]"); - Player.Message(p, "%HCompletely deletes [map] (portals, MBs, everything"); + Player.Message(p, "%HCompletely deletes [map] (portals, MBs, everything)"); Player.Message(p, "%HA backup of the map will be placed in the levels/deleted folder"); } } diff --git a/MCGalaxy/Commands/World/CmdOverseer.SubCommands.cs b/MCGalaxy/Commands/World/CmdOverseer.SubCommands.cs index e702d079c..b40123df4 100644 --- a/MCGalaxy/Commands/World/CmdOverseer.SubCommands.cs +++ b/MCGalaxy/Commands/World/CmdOverseer.SubCommands.cs @@ -94,7 +94,7 @@ namespace MCGalaxy.Commands.World { Player.Message(p, "You may only perform that action on your own map."); return; } - if (cmd == "ADD") { + if (IsCreateCommand(cmd)) { AddMap(p, value); } else if (cmd == "PHYSICS") { if (value == "0" || value == "1" || value == "2" || value == "3" || value == "4" || value == "5") { diff --git a/MCGalaxy/Commands/other/CmdRide.cs b/MCGalaxy/Commands/other/CmdRide.cs index 8700c0a3b..3ae550b1a 100644 --- a/MCGalaxy/Commands/other/CmdRide.cs +++ b/MCGalaxy/Commands/other/CmdRide.cs @@ -48,7 +48,7 @@ namespace MCGalaxy.Commands.Misc { return; } - Vec3S32 P = p.Pos.BlockFeetCoords; + Vec3S32 P = p.Pos.FeetBlockCoords; for (int dx = -1; dx <= 1; dx++) for (int dy = -1; dy <= 1; dy++) for (int dz = -1; dz <= 1; dz++) @@ -66,7 +66,8 @@ namespace MCGalaxy.Commands.Misc { else pitch = 8; if (dx != 0 || dy != 0 || dz != 0) { - PlayerActions.MoveCoords(p, P.X + dx, P.Y + dy, P.Z + dz, yaw, pitch); + Position pos = Position.FromFeetBlockCoords(P.X + dx, P.Y + dy, P.Z + dz); + p.SendPos(Entities.SelfID, pos, new Orientation(yaw, pitch)); } return; } diff --git a/MCGalaxy/Commands/other/CmdTp.cs b/MCGalaxy/Commands/other/CmdTp.cs index 1f85308a6..6076996c2 100644 --- a/MCGalaxy/Commands/other/CmdTp.cs +++ b/MCGalaxy/Commands/other/CmdTp.cs @@ -28,17 +28,18 @@ namespace MCGalaxy.Commands.Misc { get { return new [] { new CommandAlias("Teleport"), new CommandAlias("TPP", "-precise") }; } } - public override void Use(Player p, string message) { - string[] args = message.SplitSpaces(); - if (message.Length == 0 || args.Length > 4) { Help(p); return; } - if (args.Length == 3) { TeleportCoords(p, args); return; } + const string precisePrefix = "-precise "; + public override void Use(Player p, string message) { + if (message.Length == 0) { Help(p); return; } - if (message.CaselessStarts("-precise ")) { - if (args.Length != 4) { Help(p); return; } - TeleportCoordsPrecise(p, args); - return; + bool preciseTP = message.CaselessStarts(precisePrefix); + if (preciseTP) { + message = message.Substring(precisePrefix.Length); } + string[] args = message.SplitSpaces(); + if (args.Length >= 3) { TeleportCoords(p, args, preciseTP); return; } + Player target = null; PlayerBot bot = null; if (args.Length == 1) { @@ -70,21 +71,35 @@ namespace MCGalaxy.Commands.Misc { p.SendPos(Entities.SelfID, pos, rot); } - static void TeleportCoords(Player p, string[] args) { - Vec3S32 P = p.Pos.BlockFeetCoords; - if (!CommandParser.GetCoords(p, args, 0, ref P)) return; - + static void TeleportCoords(Player p, string[] args, bool precise) { + Vec3S32 P; Position pos; + + if (!precise) { + // relative to feet block coordinates + P = p.Pos.FeetBlockCoords; + if (!CommandParser.GetCoords(p, args, 0, ref P)) return; + pos = Position.FromFeetBlockCoords(P.X, P.Y, P.Z); + } else { + // relative to feet position exactly + P = new Vec3S32(p.Pos.X, p.Pos.Y + Entities.CharacterHeight, p.Pos.Z); + if (!CommandParser.GetCoords(p, args, 0, ref P)) return; + pos = new Position(P.X, P.Y - Entities.CharacterHeight, P.Z); + } + + byte yaw = p.Rot.RotY, pitch = p.Rot.HeadX; + int angle = 0; + + if (args.Length > 3) { + if (!CommandParser.GetInt(p, args[3], "Yaw angle", ref angle, -360, 360)) return; + yaw = Orientation.DegreesToPacked(angle); + } + if (args.Length > 4) { + if (!CommandParser.GetInt(p, args[4], "Pitch angle", ref angle, -360, 360)) return; + pitch = Orientation.DegreesToPacked(angle); + } + SavePreTeleportState(p); - PlayerActions.MoveCoords(p, P.X, P.Y, P.Z, p.Rot.RotY, p.Rot.HeadX); - } - - static void TeleportCoordsPrecise(Player p, string[] args) { - Vec3S32 P = new Vec3S32(p.Pos.X, p.Pos.Y + Entities.CharacterHeight, p.Pos.Z); - if (!CommandParser.GetCoords(p, args, 1, ref P)) return; - - SavePreTeleportState(p); - Position pos = new Position(P.X, P.Y - Entities.CharacterHeight, P.Z); - p.SendPos(Entities.SelfID, pos, p.Rot); + p.SendPos(Entities.SelfID, pos, new Orientation(yaw, pitch)); } static void SavePreTeleportState(Player p) { @@ -112,9 +127,9 @@ namespace MCGalaxy.Commands.Misc { public override void Help(Player p) { Player.Message(p, "%HUse ~ before a coordinate to move relative to current position"); - Player.Message(p, "%T/TP [x y z]"); + Player.Message(p, "%T/TP [x y z] "); Player.Message(p, "%HTeleports yourself to the given block coordinates."); - Player.Message(p, "%T/TP -precise [x y z]"); + Player.Message(p, "%T/TP -precise [x y z] "); Player.Message(p, "%HTeleports using precise units. (32 units = 1 block)"); Player.Message(p, "%T/TP [player]"); Player.Message(p, "%HTeleports yourself to that player."); diff --git a/MCGalaxy/CorePlugin/ConnectingHandler.cs b/MCGalaxy/CorePlugin/ConnectingHandler.cs index ada76b214..3787b00f5 100644 --- a/MCGalaxy/CorePlugin/ConnectingHandler.cs +++ b/MCGalaxy/CorePlugin/ConnectingHandler.cs @@ -38,7 +38,7 @@ namespace MCGalaxy.Core { if (!IPThrottler.CheckIP(p)) return false; if (!CheckTempban(p)) return false; - bool whitelisted = CheckWhitelist(p.name, p.ip); + bool whitelisted = CheckWhitelist(p); if (!whitelisted) { p.Leave(null, "This is a private server!", true); return false; @@ -95,12 +95,12 @@ namespace MCGalaxy.Core { return true; } - static bool CheckWhitelist(string name, string ip) { + static bool CheckWhitelist(Player p) { if (!ServerConfig.WhitelistedOnly) return true; - if (ServerConfig.VerifyNames) return Server.whiteList.Contains(name); + if (!Server.whiteList.Contains(p.name)) return false; - // Verify names is off, check if the player is on the same IP. - return Server.whiteList.Contains(name) && PlayerInfo.FindAccounts(ip).Contains(name); + // If verify names is off, check if the player is on the same IP. + return ServerConfig.VerifyNames || PlayerInfo.FindAccounts(p.ip).Contains(p.name); } static bool CheckPlayersCount(Player p) { diff --git a/MCGalaxy/Entity/Structs.cs b/MCGalaxy/Entity/Structs.cs index 2f38d0e41..d2b3433ec 100644 --- a/MCGalaxy/Entity/Structs.cs +++ b/MCGalaxy/Entity/Structs.cs @@ -38,12 +38,15 @@ namespace MCGalaxy { public Position(int x, int y, int z) { X = x; Y = y; Z = z; } public static Position FromFeet(int x, int y, int z) { return new Position(x, y + Entities.CharacterHeight, z); } + public static Position FromFeetBlockCoords(int bX, int bY, int bZ) { + return Position.FromFeet(16 + bX * 32, bY * 32, 16 + bZ * 32); + } /// World/block coordinate of this position. public Vec3S32 BlockCoords { get { return new Vec3S32(X >> 5, Y >> 5, Z >> 5); } } /// World/block coordinate of this position. - public Vec3S32 BlockFeetCoords { get { return new Vec3S32(X >> 5, (Y - Entities.CharacterHeight) >> 5, Z >> 5); } } + public Vec3S32 FeetBlockCoords { get { return new Vec3S32(X >> 5, (Y - Entities.CharacterHeight) >> 5, Z >> 5); } } /// X block coordinate of this position. public int BlockX { get { return X >> 5; } } diff --git a/MCGalaxy/Levels/AccessController.cs b/MCGalaxy/Levels/AccessController.cs index 51688bc92..3ca7f6a8f 100644 --- a/MCGalaxy/Levels/AccessController.cs +++ b/MCGalaxy/Levels/AccessController.cs @@ -244,12 +244,11 @@ namespace MCGalaxy { } public override void OnListChanged(Player p, Level lvl, string name, bool whitelist, bool removedFromOpposite) { - string type = IsVisit ? "visit" : "build"; string msg = PlayerInfo.GetColoredName(p, name); if (removedFromOpposite) { - msg += " %Swas removed from the " + type + (whitelist ? " blacklist" : " whitelist"); + msg += " %Swas removed from the " + Type + (whitelist ? " blacklist" : " whitelist"); } else { - msg += " %Swas " + type + (whitelist ? " whitelisted" : " blacklisted"); + msg += " %Swas " + Type + (whitelist ? " whitelisted" : " blacklisted"); } DoChange(p, lvl, msg); } diff --git a/MCGalaxy/Player/PlayerActions.cs b/MCGalaxy/Player/PlayerActions.cs index 5233ca3e2..2141f1610 100644 --- a/MCGalaxy/Player/PlayerActions.cs +++ b/MCGalaxy/Player/PlayerActions.cs @@ -24,12 +24,6 @@ using MCGalaxy.Commands.World; namespace MCGalaxy { public static class PlayerActions { - /// Moves the player to the specified block coordinates. (bY is treated as player feet) - public static void MoveCoords(Player p, int bX, int bY, int bZ, byte rotX, byte rotY) { - Position pos = Position.FromFeet(16 + bX * 32, bY * 32, 16 + bZ * 32); - p.SendPos(Entities.SelfID, pos, new Orientation(rotX, rotY)); - } - /// Moves the player to the specified map. public static bool ChangeMap(Player p, string name) { return ChangeMap(p, null, name); }