mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Throw syntax error on /item, if syntax is wrong.
This commit is contained in:
parent
b3847270fa
commit
1bd1665faa
1 changed files with 37 additions and 32 deletions
|
@ -36,41 +36,46 @@ public class Commanditem extends EssentialsCommand
|
||||||
{
|
{
|
||||||
throw new Exception(_("cantSpawnItem", itemname));
|
throw new Exception(_("cantSpawnItem", itemname));
|
||||||
}
|
}
|
||||||
|
try
|
||||||
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
|
|
||||||
{
|
{
|
||||||
stack.setAmount(Integer.parseInt(args[1]));
|
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
|
||||||
}
|
|
||||||
else if (ess.getSettings().getDefaultStackSize() > 0)
|
|
||||||
{
|
|
||||||
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
|
||||||
}
|
|
||||||
else if (ess.getSettings().getOversizedStackSize() > 0 && user.isAuthorized("essentials.oversizedstacks"))
|
|
||||||
{
|
|
||||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length > 2)
|
|
||||||
{
|
|
||||||
for (int i = 2; i < args.length; i++)
|
|
||||||
{
|
{
|
||||||
final String[] split = args[i].split("[:+',;.]", 2);
|
stack.setAmount(Integer.parseInt(args[1]));
|
||||||
if (split.length < 1)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], user);
|
|
||||||
int level;
|
|
||||||
if (split.length > 1)
|
|
||||||
{
|
|
||||||
level = Integer.parseInt(split[1]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
level = enchantment.getMaxLevel();
|
|
||||||
}
|
|
||||||
stack.addEnchantment(enchantment, level);
|
|
||||||
}
|
}
|
||||||
|
else if (ess.getSettings().getDefaultStackSize() > 0)
|
||||||
|
{
|
||||||
|
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
||||||
|
}
|
||||||
|
else if (ess.getSettings().getOversizedStackSize() > 0 && user.isAuthorized("essentials.oversizedstacks"))
|
||||||
|
{
|
||||||
|
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||||
|
}
|
||||||
|
if (args.length > 2)
|
||||||
|
{
|
||||||
|
for (int i = 2; i < args.length; i++)
|
||||||
|
{
|
||||||
|
final String[] split = args[i].split("[:+',;.]", 2);
|
||||||
|
if (split.length < 1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], user);
|
||||||
|
int level;
|
||||||
|
if (split.length > 1)
|
||||||
|
{
|
||||||
|
level = Integer.parseInt(split[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
level = enchantment.getMaxLevel();
|
||||||
|
}
|
||||||
|
stack.addEnchantment(enchantment, level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e)
|
||||||
|
{
|
||||||
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getType() == Material.AIR)
|
if (stack.getType() == Material.AIR)
|
||||||
|
|
Loading…
Reference in a new issue