mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-31 10:11:46 +02:00
Add command option /more all
This commit is contained in:
@@ -13,35 +13,53 @@ 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 (stack == null)
|
if (args.length > 0 && args[0].equalsIgnoreCase("all"))
|
||||||
{
|
{
|
||||||
throw new Exception(_("cantSpawnItem", "Air"));
|
stacks = user.getPlayer().getInventory().getContents();
|
||||||
}
|
|
||||||
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
|
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();
|
user.getPlayer().updateInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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.
|
||||||
|
Reference in New Issue
Block a user