Skip to content

Commit

Permalink
Dont mess with the vitrual methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zack Piispanen committed May 24, 2012
1 parent 73ff914 commit 3e0c290
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions TShockAPI/Commands.cs
Expand Up @@ -3347,7 +3347,7 @@ private static void Item(CommandArgs args)
{
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));
}
Expand Down Expand Up @@ -3431,7 +3431,7 @@ private static void Give(CommandArgs args)
{
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));
Expand Down
15 changes: 11 additions & 4 deletions TShockAPI/TSPlayer.cs
Expand Up @@ -359,11 +359,19 @@ public virtual bool SendTileSquare(int x, int y, int size = 10)
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
Expand All @@ -374,7 +382,6 @@ public virtual bool GiveItem(int type, string name, int width, int height, int s
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)
Expand Down

0 comments on commit 3e0c290

Please sign in to comment.