diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 5f948cc8..64773b67 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -138,6 +138,7 @@ namespace TShockAPI ChatCommands.Add(new Command("me", "", ThirdPerson)); ChatCommands.Add(new Command("p", "", PartyChat)); ChatCommands.Add(new Command("rules", "", Rules)); + ChatCommands.Add(new Command("whitelist", "maintenance", Whitelist)); if (ConfigurationManager.DistributationAgent != "terraria-online") { ChatCommands.Add(new Command("kill", "kill", Kill)); @@ -176,7 +177,6 @@ namespace TShockAPI if (cmd == null) { - player.SendMessage("That command does not exist, try /help", Color.Red); } else { @@ -853,6 +853,17 @@ namespace TShockAPI #region General Commands + public static void Whitelist(CommandArgs args) + { + if (args.Parameters.Count == 1) + { + TextWriter tw = new StreamWriter(FileTools.WhitelistPath, true); + tw.WriteLine(args.Parameters[0]); + tw.Close(); + args.Player.SendMessage("Added " + args.Parameters[0] + " to the whitelist."); + } + } + private static void Help(CommandArgs args) { args.Player.SendMessage("TShock Commands:"); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 2dfb1736..7c2e3d4e 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -412,20 +412,23 @@ namespace TShockAPI public static void Teleport(int ply, int x, int y) { - Main.player[ply].position.X = x; - Main.player[ply].position.Y = y; - NetMessage.SendData(0x0d, -1, ply, "", ply); - NetMessage.SendData(0x0d, -1, -1, "", ply); - NetMessage.syncPlayers(); + int oldSpawnX = Main.spawnTileX; + int oldSpawnY = Main.spawnTileY; + Main.spawnTileX = x; + Main.spawnTileY = y; + //Send only that player the new spawn point data + NetMessage.SendData(7, ply, -1, "", 0, 0f, 0f, 0f); + //Force them to respawn + NetMessage.SendData(12, ply, -1, "", ply, 0.0f, 0.0f, 0.0f); + //Reset to old spawnpoint and send spawn data back to player + Main.spawnTileX = (int)oldSpawnX; + Main.spawnTileY = (int)oldSpawnY; + NetMessage.SendData(7, ply, -1, "", 0, 0f, 0f, 0f); } public static void Teleport(int ply, float x, float y) { - Main.player[ply].position.X = x; - Main.player[ply].position.Y = y; - NetMessage.SendData(0x0d, -1, ply, "", ply); - NetMessage.SendData(0x0d, -1, -1, "", ply); - NetMessage.syncPlayers(); + Teleport(ply, (int)x, (int)y); } public static void StartInvasion()