diff --git a/Essentials/src/net/ess3/commands/Commandmore.java b/Essentials/src/net/ess3/commands/Commandmore.java index 9b5a8b8ae..26c7d7de3 100644 --- a/Essentials/src/net/ess3/commands/Commandmore.java +++ b/Essentials/src/net/ess3/commands/Commandmore.java @@ -13,35 +13,53 @@ public class Commandmore extends EssentialsCommand @Override public void run(final IUser user, final String commandLabel, final String[] args) throws Exception { - final ItemStack stack = user.getPlayer().getItemInHand(); - if (stack == null) + ItemStack[] stacks; + if (args.length > 0 && args[0].equalsIgnoreCase("all")) { - throw new Exception(_("cantSpawnItem", "Air")); - } - ISettings settings = ess.getSettings(); - - int defaultStackSize = settings.getData().getGeneral().getDefaultStacksize(); - int oversizedStackSize = settings.getData().getGeneral().getOversizedStacksize(); - - if (stack.getAmount() >= (Permissions.OVERSIZEDSTACKS.isAuthorized(user) - ? oversizedStackSize - : defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize())) - { - throw new NoChargeException(); - } - final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); - if (!Permissions.ITEMSPAWN.isAuthorized(user, stack)) - { - throw new Exception(_("cantSpawnItem", itemname)); - } - if (Permissions.OVERSIZEDSTACKS.isAuthorized(user)) - { - stack.setAmount(oversizedStackSize); + stacks = user.getPlayer().getInventory().getContents(); } else { - stack.setAmount(defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize()); + stacks = new ItemStack[] + { + user.getPlayer().getItemInHand() + }; + } + for (ItemStack stack : stacks) + { + if (stack == null) + { + throw new Exception(_("cantSpawnItem", "Air")); + } + ISettings settings = ess.getSettings(); + + int defaultStackSize = settings.getData().getGeneral().getDefaultStacksize(); + int oversizedStackSize = settings.getData().getGeneral().getOversizedStacksize(); + + if (stack.getAmount() >= (Permissions.OVERSIZEDSTACKS.isAuthorized(user) + ? oversizedStackSize + : defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize())) + { + throw new NoChargeException(); + } + final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); + if (!Permissions.ITEMSPAWN.isAuthorized(user, stack)) + { + throw new Exception(_("cantSpawnItem", itemname)); + } + if (Permissions.OVERSIZEDSTACKS.isAuthorized(user)) + { + stack.setAmount(oversizedStackSize); + } + else + { + stack.setAmount(defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize()); + } + } + if (stacks.length > 1) + { + user.getPlayer().getInventory().setContents(stacks); } user.getPlayer().updateInventory(); } -} \ No newline at end of file +} diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index a7fa9e8dd..6be38184a 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -224,7 +224,7 @@ commands: aliases: [action,describe,eme,eaction,edescribe] more: description: Fills the item stack in hand to maximum size. - usage: / + usage: / [all] aliases: [emore] motd: description: Views the Message Of The Day.