mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-01-03 22:08:28 +00:00
[trunk] Prevent scam (air, zero items) signs and prevent stacks size lower than 1 with /give and /item
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1087 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
f1e44b1fda
commit
09006ced4f
3 changed files with 18 additions and 7 deletions
|
@ -78,7 +78,10 @@ public class EssentialsEcoBlockListener extends BlockListener
|
|||
{
|
||||
event.setLine(0, "§1[Buy]");
|
||||
event.setLine(1, "" + Math.abs(Integer.parseInt(event.getLine(1))));
|
||||
ItemDb.get(event.getLine(2));
|
||||
ItemStack is = ItemDb.get(event.getLine(2));
|
||||
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0) {
|
||||
throw new Exception("Don't sell air.");
|
||||
}
|
||||
event.setLine(3, "$" + Integer.parseInt(event.getLine(3).replaceAll("[^0-9]", "")));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
|
@ -98,7 +101,10 @@ public class EssentialsEcoBlockListener extends BlockListener
|
|||
{
|
||||
event.setLine(0, "§1[Sell]");
|
||||
event.setLine(1, "" + Math.abs(Integer.parseInt(event.getLine(1))));
|
||||
ItemDb.get(event.getLine(2));
|
||||
ItemStack is = ItemDb.get(event.getLine(2));
|
||||
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0) {
|
||||
throw new Exception("Don't buy air.");
|
||||
}
|
||||
event.setLine(3, "$" + Integer.parseInt(event.getLine(3).replaceAll("[^0-9]", "")));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
|
|
|
@ -34,15 +34,18 @@ public class Commandgive extends EssentialsCommand
|
|||
sender.sendMessage(ChatColor.RED + "You are not allowed to spawn that item");
|
||||
return;
|
||||
}
|
||||
if (itemArgs.length > 1)
|
||||
if (itemArgs.length > 1) {
|
||||
stack.setDurability(Short.parseShort(itemArgs[1]));
|
||||
if (args.length > 2)
|
||||
}
|
||||
if (args.length > 2 && Integer.parseInt(args[2]) > 0) {
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
}
|
||||
|
||||
User giveTo = getPlayer(server, args, 0);
|
||||
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
|
||||
if (sender instanceof Player)
|
||||
if (sender instanceof Player) {
|
||||
User.get(sender).charge(this);
|
||||
}
|
||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
||||
giveTo.getInventory().addItem(stack);
|
||||
}
|
||||
|
|
|
@ -31,11 +31,13 @@ public class Commanditem extends EssentialsCommand
|
|||
user.sendMessage(ChatColor.RED + "You are not allowed to spawn that item");
|
||||
return;
|
||||
}
|
||||
if (itemArgs.length > 1)
|
||||
if (itemArgs.length > 1) {
|
||||
stack.setDurability(Short.parseShort(itemArgs[1]));
|
||||
}
|
||||
|
||||
if (args.length > 1)
|
||||
if (args.length > 1 && Integer.parseInt(args[1]) > 0) {
|
||||
stack.setAmount(Integer.parseInt(args[1]));
|
||||
}
|
||||
|
||||
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
|
||||
user.charge(this);
|
||||
|
|
Loading…
Reference in a new issue