From b2f4ee698bb35f7e708bc2029b8cc7c10d062d60 Mon Sep 17 00:00:00 2001 From: Shank Date: Thu, 2 Jun 2011 20:48:42 -0600 Subject: [PATCH 1/4] Re-added broadcast event for kill tile abuse. Added kick for SendSection Added kick for NPC abuse --- TShockAPI/TShock.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index ad03e9b7..bc981905 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -173,11 +173,13 @@ namespace TShockAPI if (e.MsgID == 0x0A) //SendSection { Tools.Broadcast(string.Format("{0}({1}) attempted sending a section", Main.player[e.Msg.whoAmI].name, e.Msg.whoAmI)); + Tools.Kick(e.Msg.whoAmI, "SendSection abuse."); e.Handled = true; } if (e.MsgID == 0x17) //Npc Data { Tools.Broadcast(string.Format("{0}({1}) attempted spawning an NPC", Main.player[e.Msg.whoAmI].name, e.Msg.whoAmI)); + Tools.Kick(e.Msg.whoAmI, "Spawn NPC abuse"); e.Handled = true; } } @@ -265,6 +267,7 @@ namespace TShockAPI { 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."); } tileThreshold[i] = 0; } From daf56053c8b5822839f347be3d76ea8d797bea50 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Fri, 3 Jun 2011 10:51:02 +0800 Subject: [PATCH 2/4] Remove item max stack check. --- TShockAPI/Commands.cs | 2 +- TShockAPI/TShock.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 52cd9c3c..9519e965 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -68,7 +68,7 @@ namespace TShockAPI Tools.Broadcast(plStr + " was kicked by " + Tools.FindPlayer(ply)); } else - Tools.SendMessage(ply, "You can't ban another admin!", new float[] { 255f, 0f, 0f }); + Tools.SendMessage(ply, "You can't kick another admin!", new float[] { 255f, 0f, 0f }); } else Tools.SendMessage(ply, "Invalid player!", new float[] { 255f, 0f, 0f }); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index bc981905..87b11fe0 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -466,11 +466,11 @@ namespace TShockAPI public static bool CheckInventory(int plr) { - for (int i = 0; i < 44; i++) + /*for (int i = 0; i < 44; i++) { if (Main.player[plr].inventory[i].stack > Main.player[plr].inventory[i].maxStack) return true; - } + }*/ return false; } } From ff5c47a57c5064f34d8a436071c9d9dcefa8ea84 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Fri, 3 Jun 2011 10:57:43 +0800 Subject: [PATCH 3/4] Updated NPC and Item methods for the new items. --- TShockAPI/Commands.cs | 6 +++--- TShockAPI/TShock.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 9519e965..71032dc7 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -233,7 +233,7 @@ namespace TShockAPI if (!int.TryParse(inputtype, out type)) type = TShock.GetNPCID(inputtype); - if (type >= 1 && type <= 43) + if (type >= 1 && type <= 45) { for (int i = 0; i < amount; i++) npcid = NPC.NewNPC(x, y, type, 0); @@ -254,7 +254,7 @@ namespace TShockAPI int type = 0; if (!int.TryParse(msgargs, out type)) type = TShock.GetItemID(msgargs); - if (type >= 1 && type <= 235) + if (type >= 1 && type <= 238) { for (int i = 0; i < 40; i++) { @@ -290,7 +290,7 @@ namespace TShockAPI int player = -1; if (!int.TryParse(msgargs[1], out type)) type = TShock.GetItemID(msgargs[1]); - if (type >= 1 && type <= 235) + if (type >= 1 && type <= 238) { player = Tools.FindPlayer(msgargs[2]); if (player != -1) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 87b11fe0..9317f28a 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -430,7 +430,7 @@ namespace TShockAPI public static int GetNPCID(string name, bool exact = false) { NPC npc = new NPC(); - for (int i = 1; i <= 43; i++) + for (int i = 1; i <= 45; i++) { if (exact) { @@ -455,7 +455,7 @@ namespace TShockAPI { Item item = new Item(); name = name.ToLower(); - for (int i = 1; i <= 235; i++) + for (int i = 1; i <= 238; i++) { item.SetDefaults(i); if (item.name.ToLower().StartsWith(name)) From cbf525b1486eba63272dbb898c9fe93bac77cf68 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Fri, 3 Jun 2011 11:51:40 +0800 Subject: [PATCH 4/4] Fixed /item and /give --- TShockAPI/Commands.cs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 71032dc7..522ffd67 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -260,10 +260,16 @@ namespace TShockAPI { if (!Main.player[ply].inventory[i].active) { - Main.player[ply].inventory[i].SetDefaults(type); - Main.player[ply].inventory[i].stack = Main.player[ply].inventory[i].maxStack; - Tools.SendMessage(ply, "Got some " + Main.player[ply].inventory[i].name + "."); - TShock.UpdateInventories(); + //Main.player[ply].inventory[i].SetDefaults(type); + //Main.player[ply].inventory[i].stack = Main.player[ply].inventory[i].maxStack; + int id = Terraria.Item.NewItem(0, 0, 0, 0, type, 1, true); + Main.item[id].position.X = (float)args.PlayerX; + Main.item[id].position.Y = (float)args.PlayerY; + Main.item[id].stack = Main.item[id].maxStack; + //TShock.SendDataAll(21, -1, "", id); + NetMessage.SendData(21, -1, -1, "", id, 0f, 0f, 0f); + Tools.SendMessage(ply, "Got some " + Main.item[id].name + "."); + //TShock.UpdateInventories(); flag = true; break; } @@ -299,11 +305,17 @@ namespace TShockAPI { if (!Main.player[player].inventory[i].active) { - Main.player[player].inventory[i].SetDefaults(type); - Main.player[player].inventory[i].stack = Main.player[player].inventory[i].maxStack; - Tools.SendMessage(ply, string.Format("Gave {0} some {1}.", msgargs[2], Main.player[player].inventory[i].name)); - Tools.SendMessage(player, string.Format("{0} gave you some {1}.", Tools.FindPlayer(ply), Main.player[player].inventory[i].name)); - TShock.UpdateInventories(); + //Main.player[player].inventory[i].SetDefaults(type); + //Main.player[player].inventory[i].stack = Main.player[player].inventory[i].maxStack; + int id = Terraria.Item.NewItem(0, 0, 0, 0, type, 1, true); + Main.item[id].position.X = Main.player[player].position.X; + Main.item[id].position.Y = Main.player[player].position.Y; + Main.item[id].stack = Main.item[id].maxStack; + //TShock.SendDataAll(21, -1, "", id); + NetMessage.SendData(21, -1, -1, "", id, 0f, 0f, 0f); + Tools.SendMessage(ply, string.Format("Gave {0} some {1}.", msgargs[2], Main.item[id].name)); + Tools.SendMessage(player, string.Format("{0} gave you some {1}.", Tools.FindPlayer(ply), Main.item[id].name)); + //TShock.UpdateInventories(); flag = true; break; }