From 3e0c29024351b142ff67f03a0628a982d561651a Mon Sep 17 00:00:00 2001 From: Zack Piispanen Date: Thu, 24 May 2012 18:30:14 -0400 Subject: [PATCH] Dont mess with the vitrual methods. --- TShockAPI/Commands.cs | 4 ++-- TShockAPI/TSPlayer.cs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 40d1ed4f..cdca36fd 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -3347,7 +3347,7 @@ namespace TShockAPI { if (itemAmount == 0 || itemAmount > item.maxStack) itemAmount = item.maxStack; - if (args.Player.GiveItem(item.type, item.name, item.width, item.height, itemAmount, prefix)) + if (args.Player.GiveItemCheck(item.type, item.name, item.width, item.height, itemAmount, prefix)) { args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name)); } @@ -3431,7 +3431,7 @@ namespace TShockAPI { if (itemAmount == 0 || itemAmount > item.maxStack) itemAmount = item.maxStack; - if( plr.GiveItem(item.type, item.name, item.width, item.height, itemAmount, prefix)) + if (plr.GiveItemCheck(item.type, item.name, item.width, item.height, itemAmount, prefix)) { args.Player.SendMessage(string.Format("Gave {0} {1} {2}(s).", plr.Name, itemAmount, item.name)); plr.SendMessage(string.Format("{0} gave you {1} {2}(s).", args.Player.Name, itemAmount, item.name)); diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 6be973b5..e08df139 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -359,11 +359,19 @@ namespace TShockAPI return false; } - public virtual bool GiveItem(int type, string name, int width, int height, int stack, int prefix = 0) - { - int itemid = Item.NewItem((int) X, (int) Y, width, height, type, stack, true, prefix); + public bool GiveItemCheck(int type, string name, int width, int height, int stack, int prefix = 0) + { if (TShock.Itembans.ItemIsBanned(name) && TShock.Config.PreventBannedItemSpawn) return false; + + GiveItem(type,name,width,height,stack,prefix); + return true; + } + + public virtual void GiveItem(int type, string name, int width, int height, int stack, int prefix = 0) + { + int itemid = Item.NewItem((int) X, (int) Y, width, height, type, stack, true, prefix); + // This is for special pickaxe/hammers/swords etc Main.item[itemid].SetDefaults(name); // The set default overrides the wet and stack set by NewItem @@ -374,7 +382,6 @@ namespace TShockAPI Main.item[itemid].prefix = (byte) prefix; NetMessage.SendData((int) PacketTypes.ItemDrop, -1, -1, "", itemid, 0f, 0f, 0f); NetMessage.SendData((int) PacketTypes.ItemOwner, -1, -1, "", itemid, 0f, 0f, 0f); - return true; } public virtual void SendMessage(string msg)