Dont mess with the vitrual methods.

This commit is contained in:
Zack Piispanen 2012-05-24 18:30:14 -04:00
parent 73ff9145c1
commit 3e0c290243
2 changed files with 13 additions and 6 deletions

View file

@ -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));

View file

@ -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)
public bool GiveItemCheck(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);
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)