From f1d821a554c7881afa7a9032a33ff70667357034 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Fri, 3 Jun 2011 21:43:05 +0800 Subject: [PATCH] Added Dynamite/Bomb projectile checks. Fixed issue where Kill Tile Abuse doesn't check for config values. --- TShockAPI/ConfigFile.cs | 2 ++ TShockAPI/ConfigurationManager.cs | 7 +++++ TShockAPI/FileTools.cs | 2 +- TShockAPI/TShock.cs | 49 +++++++++++++++++++++++++++---- TShockAPI/Tools.cs | 6 ++-- 5 files changed, 57 insertions(+), 9 deletions(-) diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 0990f5bd..1ce76424 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -21,5 +21,7 @@ namespace TShockAPI public bool BanGriefers = true; public bool BanKillTileAbusers = false; public bool KickKillTileAbusers = false; + public bool BanExplosives = true; + public bool KickExplosives = true; } } diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index 1a447e87..aacce18c 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -27,6 +27,9 @@ namespace TShockAPI public static bool banGriefer = true; public static bool banTnt = false; public static bool kickTnt = false; + public static bool banBoom = true; + public static bool kickBoom = true; + public enum NPCList : int { WORLD_EATER = 0, @@ -53,6 +56,8 @@ namespace TShockAPI banGriefer = cfg.BanGriefers; banTnt = cfg.BanKillTileAbusers; kickTnt = cfg.KickKillTileAbusers; + banBoom = cfg.BanExplosives; + kickBoom = cfg.KickExplosives; } public static void WriteJsonConfiguration() @@ -80,6 +85,8 @@ namespace TShockAPI cfg.BanGriefers = banGriefer; cfg.BanKillTileAbusers = true; cfg.KickKillTileAbusers = true; + cfg.BanExplosives = true; + cfg.KickExplosives = true; string json = JsonConvert.SerializeObject(cfg, Formatting.Indented); TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json"); diff --git a/TShockAPI/FileTools.cs b/TShockAPI/FileTools.cs index b95c1505..91d7637e 100644 --- a/TShockAPI/FileTools.cs +++ b/TShockAPI/FileTools.cs @@ -128,7 +128,7 @@ namespace TShockAPI /// /// /// - public static bool CheckGreif(String ip) + public static bool Checkgrief(String ip) { ip = Tools.GetRealIP(ip); if (!ConfigurationManager.banTnt) { return false; } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 01e5f49a..dd72497f 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -232,6 +232,41 @@ namespace TShockAPI Tools.HandleCheater(ply); } } + else if (e.MsgID == 0x1B) + { + Int16 ident; + float posx; + float posy; + float velx; + float vely; + float knockback; + Int16 dmg; + byte owner; + byte type; + using (var br = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))) + { + ident = br.ReadInt16(); + posx = br.ReadSingle(); + posy = br.ReadSingle(); + velx = br.ReadSingle(); + vely = br.ReadSingle(); + knockback = br.ReadSingle(); + dmg = br.ReadInt16(); + owner = br.ReadByte(); + type = br.ReadByte(); + } + if (type == 29 || type == 28) + { + if (ConfigurationManager.kickTnt || ConfigurationManager.banTnt) + { + int i = e.Msg.whoAmI; + if (ConfigurationManager.banTnt) + FileTools.WriteGrief((int)i); + Tools.Kick((int)i, "Explosives was thrown."); + Tools.Broadcast(Main.player[i].name + " was " + (ConfigurationManager.banBoom ? "banned" : "kicked") + " for throwing an explosive device."); + } + } + } } void OnGreetPlayer(int who, HandledEventArgs e) @@ -289,9 +324,9 @@ namespace TShockAPI { Tools.Kick(ply, "You were flagged for cheating."); } - else if (FileTools.CheckGreif(ip)) + else if (FileTools.Checkgrief(ip)) { - Tools.Kick(ply, "You were flagged for kill tile abuse."); + Tools.Kick(ply, "You were flagged for griefing (either kill tile abuse or explosives)."); } if (!FileTools.OnWhitelist(ip)) { @@ -323,9 +358,13 @@ namespace TShockAPI { if (Main.player[i] != null) { - FileTools.WriteGrief((int)i); - Tools.Kick((int)i, "Kill tile abuse detected."); - Tools.Broadcast(Main.player[i].name + " was " + (ConfigurationManager.banTnt ? "banned" : "kicked") + " for kill tile abuse."); + if (ConfigurationManager.kickTnt || ConfigurationManager.banTnt) + { + if (ConfigurationManager.banTnt) + FileTools.WriteGrief((int)i); + Tools.Kick((int)i, "Kill tile abuse detected."); + Tools.Broadcast(Main.player[i].name + " was " + (ConfigurationManager.banTnt ? "banned" : "kicked") + " for kill tile abuse."); + } } players[i].tileThreshold = 0; } diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs index d1852618..312f1697 100644 --- a/TShockAPI/Tools.cs +++ b/TShockAPI/Tools.cs @@ -254,10 +254,10 @@ namespace TShockAPI } /// - /// Adds someone to greifers.txt + /// Adds someone to griefers.txt /// /// int player - public static void HandleGreifer(int ply) + public static void HandleGriefer(int ply) { if (!TShock.players[ply].IsAdmin()) { @@ -269,7 +269,7 @@ namespace TShockAPI Netplay.serverSock[ply].kill = true; Netplay.serverSock[ply].Reset(); NetMessage.syncPlayers(); - Tools.Broadcast(cheater + " was " + (ConfigurationManager.banCheater ? "banned " : "kicked ") + "for greifing."); + Tools.Broadcast(cheater + " was " + (ConfigurationManager.banGriefer ? "banned " : "kicked ") + "for griefing."); } }