1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-01 10:42:41 +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 @Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception 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) if (stack == null)
{ {
throw new Exception(_("cantSpawnItem", "Air")); throw new Exception(_("cantSpawnItem", "Air"));
@@ -42,6 +55,11 @@ public class Commandmore extends EssentialsCommand
{ {
stack.setAmount(defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize()); stack.setAmount(defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize());
} }
}
if (stacks.length > 1)
{
user.getPlayer().getInventory().setContents(stacks);
}
user.getPlayer().updateInventory(); user.getPlayer().updateInventory();
} }
} }

View File

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