From a1a82745d0d3e541642c44ad238388d6dd3c59e7 Mon Sep 17 00:00:00 2001 From: ricky Date: Tue, 14 Jun 2011 12:16:12 +1000 Subject: [PATCH 1/9] Using Player Damage instead of Kill Me message for /kill Added current value of DisableBuild to the debug-condig output --- TShockAPI/Commands.cs | 20 +++++++++----------- TShockAPI/TShock.cs | 5 ++--- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 71851e36..688b921a 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -297,14 +297,14 @@ namespace TShockAPI ConfigurationManager.banTnt, ConfigurationManager.kickTnt, ConfigurationManager.banBoom, ConfigurationManager.kickBoom); Tools.SendMessage(ply, lineTwo, Color.Yellow); - string lineThree = string.Format("InvMultiplier : {0}, ProtectS : {1}, ProtectR : {2}, DMS : {3}, SpawnRate {4}", - ConfigurationManager.invasionMultiplier, ConfigurationManager.spawnProtect, - ConfigurationManager.spawnProtectRadius, ConfigurationManager.defaultMaxSpawns, - ConfigurationManager.defaultSpawnRate); + string lineThree = string.Format("RangeChecks : {0}, DisableBuild : {1}, ProtectSpawn : {2}, ProtectRadius : {3}", + ConfigurationManager.rangeChecks, ConfigurationManager.disableBuild, + ConfigurationManager.spawnProtect, ConfigurationManager.spawnProtectRadius); Tools.SendMessage(ply, lineThree, Color.Yellow); - string lineFour = string.Format("MaxSlots : {0}, RangeChecks : {1}, SpamChecks : {2}", - ConfigurationManager.maxSlots, ConfigurationManager.rangeChecks, - ConfigurationManager.spamChecks); + string lineFour = string.Format("MaxSlots : {0}, SpamChecks : {1}, InvMultiplier : {2}, DMS : {3}, SpawnRate {4}", + ConfigurationManager.maxSlots, ConfigurationManager.spamChecks, + ConfigurationManager.invasionMultiplier, ConfigurationManager.defaultMaxSpawns, + ConfigurationManager.defaultSpawnRate); Tools.SendMessage(ply, lineFour, Color.Yellow); } @@ -1006,13 +1006,11 @@ namespace TShockAPI Tools.SendMessage(adminplr, "Invalid player!", Color.Red); else if (player == -2) Tools.SendMessage(adminplr, "More than one player matched!", Color.Red); - else if (player == adminplr) - Tools.SendMessage(adminplr, "Can't kill yourself!", Color.Red); else { Tools.SendMessage(adminplr, string.Format("You just killed {0}!", Tools.FindPlayer(player))); Tools.SendMessage(player, string.Format("{0} just killed you!", Tools.FindPlayer(adminplr))); - TShock.KillMe(player); + TShock.PlayerDamage(player, 999999); } } @@ -1044,7 +1042,7 @@ namespace TShockAPI { int.TryParse(args.Parameters[1], out damage); } - NetMessage.SendData(26, -1, -1, "", player, ((new Random()).Next(-1, 1)), damage, (float)0); + TShock.PlayerDamage(player, damage); Tools.Broadcast(string.Format("{0} slapped {1} for {2} damage.", Tools.FindPlayer(adminplr), Tools.FindPlayer(player), damage)); } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 1990eae9..41b95d4a 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -837,10 +837,9 @@ namespace TShockAPI } } - public static void KillMe(int plr) + public static void PlayerDamage(int plr, int damage) { - for (int i = 0; i < Main.player.Length; i++) - NetMessage.SendData(44, i, -1, "", plr, 1, 9999999, (float)0); + NetMessage.SendData(26, -1, -1, "", plr, ((new Random()).Next(-1, 1)), damage, (float)0); } //TODO : Notify the player if there is more than one match. (or do we want a First() kinda thing?) From 1ce4e75eff5f407812188b23925d23ae5ce83110 Mon Sep 17 00:00:00 2001 From: ricky Date: Tue, 14 Jun 2011 14:40:58 +1000 Subject: [PATCH 2/9] Notify user that world is protected from changed when anti build is on. --- TShockAPI/TShock.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 41b95d4a..3a600060 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -349,6 +349,7 @@ namespace TShockAPI { if (!players[e.Msg.whoAmI].group.HasPermission("editspawn")) { + Tools.SendMessage(e.Msg.whoAmI, "World protected from changes.", Color.Red); return true; } } From 7e8e8fb9864b7e6b6be954db279b76da10388709 Mon Sep 17 00:00:00 2001 From: Shank Date: Tue, 14 Jun 2011 01:38:22 -0600 Subject: [PATCH 3/9] Version Tick: 2.1.0.3 (Fuck it, no hostname resolution if nobody bothers to test) --- TShockAPI/TShock.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 3a600060..0a5c2212 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -36,9 +36,9 @@ namespace TShockAPI public static string saveDir = "./tshock/"; - public static Version VersionNum = new Version(2, 1, 0, 2); + public static Version VersionNum = new Version(2, 1, 0, 3); - public static string VersionCodename = "Forgot to close the issue."; + public static string VersionCodename = "Revert!"; private static bool[] BlacklistTiles; From b8b4b6c8e82a1d029ddb69fb123b68b79ce51f1d Mon Sep 17 00:00:00 2001 From: Shank Date: Tue, 14 Jun 2011 02:06:04 -0600 Subject: [PATCH 4/9] Added /rules, reads from ./tshock/rules.txt --- TShockAPI/Commands.cs | 14 ++++++++++++++ TShockAPI/FileTools.cs | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 688b921a..f2923168 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -223,6 +223,7 @@ namespace TShockAPI commands.Add(new Command("auth", "", AuthToken)); commands.Add(new Command("me", "", ThirdPerson)); commands.Add(new Command("p", "", PartyChat)); + commands.Add(new Command("rules", "", Rules)); commands.Add(new Command("antibuild", "editspawn", ToggleAntiBuild)); if (ConfigurationManager.distributationAgent != "terraria-online") { @@ -237,6 +238,19 @@ namespace TShockAPI #region Command Methods + public static void Rules(CommandArgs args) + { + TextReader sr = new StreamReader(FileTools.SaveDir + "rules.txt"); + string unsplit = sr.ReadToEnd(); + sr.Close(); + + string[] split = unsplit.Split(Convert.ToChar("\n")); + for (int i = 0; i < split.Length; i++) + { + Tools.SendMessage(args.PlayerID, split[i]); + } + } + public static void ToggleAntiBuild(CommandArgs args) { Tools.SendMessage(args.PlayerID, "Toggled world anti-build."); diff --git a/TShockAPI/FileTools.cs b/TShockAPI/FileTools.cs index fc9eb531..15d498b7 100644 --- a/TShockAPI/FileTools.cs +++ b/TShockAPI/FileTools.cs @@ -61,6 +61,14 @@ namespace TShockAPI { Directory.CreateDirectory(SaveDir); } + if (!File.Exists(SaveDir + "rules.txt")) + { + CreateFile(SaveDir + "rules.txt"); + TextWriter tw = new StreamWriter(SaveDir + "rules.txt"); + tw.WriteLine("Respect the admins!"); + tw.WriteLine("Don't use TNT!"); + tw.Close(); + } if (!File.Exists(SaveDir + "motd.txt")) { CreateFile(SaveDir + "motd.txt"); From 37d40374bedf595fb7ceceb83a5ff749879888ac Mon Sep 17 00:00:00 2001 From: Shank Date: Tue, 14 Jun 2011 02:15:18 -0600 Subject: [PATCH 5/9] /rules now follows MOTD formatting rules. Tools.ShowMOTD is deprecated, use Tools.ShowFileToUser instead. --- TShockAPI/Commands.cs | 10 +--------- TShockAPI/Tools.cs | 17 +++++++++++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index f2923168..abb1ba1e 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -240,15 +240,7 @@ namespace TShockAPI public static void Rules(CommandArgs args) { - TextReader sr = new StreamReader(FileTools.SaveDir + "rules.txt"); - string unsplit = sr.ReadToEnd(); - sr.Close(); - - string[] split = unsplit.Split(Convert.ToChar("\n")); - for (int i = 0; i < split.Length; i++) - { - Tools.SendMessage(args.PlayerID, split[i]); - } + Tools.ShowFileToUser(args.PlayerID, "rules.txt"); } public static void ToggleAntiBuild(CommandArgs args) diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs index ed0e7a78..f818bb11 100755 --- a/TShockAPI/Tools.cs +++ b/TShockAPI/Tools.cs @@ -342,15 +342,20 @@ namespace TShockAPI } return false; } - - /// - /// Shows a MOTD to the player - /// - /// int player + [Obsolete("Use ShowFileToUser(int ply, string file) instead.")] public static void ShowMOTD(int ply) + { + ShowFileToUser(ply, "motd.txt"); + } + /// + /// Shows a file to the user. + /// + /// int player + /// string filename reletave to savedir + public static void ShowFileToUser(int ply, string file) { string foo = ""; - TextReader tr = new StreamReader(FileTools.SaveDir + "motd.txt"); + TextReader tr = new StreamReader(FileTools.SaveDir + file); while ((foo = tr.ReadLine()) != null) { foo = foo.Replace("%map%", Main.worldName); From 49ca8fcd1a666451e48cc7f9e9c35f42a6305d0a Mon Sep 17 00:00:00 2001 From: Shank Date: Tue, 14 Jun 2011 02:28:06 -0600 Subject: [PATCH 6/9] Freaking updater. --- Update/Update.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Update/Update.csproj b/Update/Update.csproj index 2b5dda25..f37c3dee 100644 --- a/Update/Update.csproj +++ b/Update/Update.csproj @@ -59,8 +59,9 @@ Designer + - +