Added config option to prevent people from spawning banned items.
This commit is contained in:
parent
c27dfddaaa
commit
50d9cb602d
3 changed files with 27 additions and 12 deletions
|
|
@ -3347,8 +3347,14 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (itemAmount == 0 || itemAmount > item.maxStack)
|
if (itemAmount == 0 || itemAmount > item.maxStack)
|
||||||
itemAmount = item.maxStack;
|
itemAmount = item.maxStack;
|
||||||
args.Player.GiveItem(item.type, item.name, item.width, item.height, itemAmount, prefix);
|
if (args.Player.GiveItem(item.type, item.name, item.width, item.height, itemAmount, prefix))
|
||||||
args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name));
|
{
|
||||||
|
args.Player.SendMessage(string.Format("Gave {0} {1}(s).", itemAmount, item.name));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
args.Player.SendMessage("The item is banned and the config prevents you from spawning banned items.", Color.Red);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -3425,9 +3431,16 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (itemAmount == 0 || itemAmount > item.maxStack)
|
if (itemAmount == 0 || itemAmount > item.maxStack)
|
||||||
itemAmount = item.maxStack;
|
itemAmount = item.maxStack;
|
||||||
plr.GiveItem(item.type, item.name, item.width, item.height, itemAmount, prefix);
|
if( plr.GiveItem(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));
|
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));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
args.Player.SendMessage("The item is banned and the config prevents spawning banned items.", Color.Red);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -220,14 +220,13 @@ namespace TShockAPI
|
||||||
|
|
||||||
[Description("Allows hallow to spread when a world is hardmode.")] public bool AllowHallowCreep = true;
|
[Description("Allows hallow to spread when a world is hardmode.")] public bool AllowHallowCreep = true;
|
||||||
|
|
||||||
[Description("How many things a statue can spawn within 200 pixels(?) before it stops spawning. Default = 3")]
|
[Description("How many things a statue can spawn within 200 pixels(?) before it stops spawning. Default = 3")] public int StatueSpawn200 = 3;
|
||||||
public int StatueSpawn200 = 3;
|
|
||||||
|
|
||||||
[Description("How many things a statue can spawn within 600 pixels(?) before it stops spawning. Default = 6")]
|
[Description("How many things a statue can spawn within 600 pixels(?) before it stops spawning. Default = 6")] public int StatueSpawn600 = 6;
|
||||||
public int StatueSpawn600 = 6;
|
|
||||||
|
|
||||||
[Description("How many things a statue spawns can exist in the world before it stops spawning. Default = 10")]
|
[Description("How many things a statue spawns can exist in the world before it stops spawning. Default = 10")] public int StatueSpawnWorld = 10;
|
||||||
public int StatueSpawnWorld = 10;
|
|
||||||
|
[Description("Prevent banned items from being /i or /give")] public bool PreventBannedItemSpawn = false;
|
||||||
|
|
||||||
public static ConfigFile Read(string path)
|
public static ConfigFile Read(string path)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -359,9 +359,11 @@ namespace TShockAPI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void GiveItem(int type, string name, int width, int height, int stack, int prefix = 0)
|
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);
|
int itemid = Item.NewItem((int) X, (int) Y, width, height, type, stack, true, prefix);
|
||||||
|
if (TShock.Itembans.ItemIsBanned(name) && TShock.Config.PreventBannedItemSpawn)
|
||||||
|
return false;
|
||||||
// This is for special pickaxe/hammers/swords etc
|
// This is for special pickaxe/hammers/swords etc
|
||||||
Main.item[itemid].SetDefaults(name);
|
Main.item[itemid].SetDefaults(name);
|
||||||
// The set default overrides the wet and stack set by NewItem
|
// The set default overrides the wet and stack set by NewItem
|
||||||
|
|
@ -372,6 +374,7 @@ namespace TShockAPI
|
||||||
Main.item[itemid].prefix = (byte) prefix;
|
Main.item[itemid].prefix = (byte) prefix;
|
||||||
NetMessage.SendData((int) PacketTypes.ItemDrop, -1, -1, "", itemid, 0f, 0f, 0f);
|
NetMessage.SendData((int) PacketTypes.ItemDrop, -1, -1, "", itemid, 0f, 0f, 0f);
|
||||||
NetMessage.SendData((int) PacketTypes.ItemOwner, -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)
|
public virtual void SendMessage(string msg)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue