1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-08-30 17:59:53 +02:00

Add command option /more all

This commit is contained in:
snowleo
2012-10-15 23:12:02 +02:00
parent 6f34f208b0
commit c74545d614
2 changed files with 44 additions and 26 deletions

View File

@@ -13,7 +13,20 @@ 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();
ItemStack[] stacks;
if (args.length > 0 && args[0].equalsIgnoreCase("all"))
{
stacks = user.getPlayer().getInventory().getContents();
}
else
{
stacks = new ItemStack[]
{
user.getPlayer().getItemInHand()
};
}
for (ItemStack stack : stacks)
{
if (stack == null)
{
throw new Exception(_("cantSpawnItem", "Air"));
@@ -42,6 +55,11 @@ public class Commandmore extends EssentialsCommand
{
stack.setAmount(defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize());
}
}
if (stacks.length > 1)
{
user.getPlayer().getInventory().setContents(stacks);
}
user.getPlayer().updateInventory();
}
}

View File

@@ -224,7 +224,7 @@ commands:
aliases: [action,describe,eme,eaction,edescribe]
more:
description: Fills the item stack in hand to maximum size.
usage: /<command>
usage: /<command> [all]
aliases: [emore]
motd:
description: Views the Message Of The Day.