Fix MetaItemStack canSpawn() method to try it on a clone, readd check to /give and /i

This commit is contained in:
vemacs 2015-06-04 11:18:47 -06:00
parent 14c4ed8379
commit ff3b1e810f
3 changed files with 12 additions and 3 deletions

View file

@ -90,7 +90,7 @@ public class MetaItemStack {
public boolean canSpawn(final IEssentials ess) {
try {
ess.getServer().getUnsafe().modifyItemStack(stack, "{}");
ess.getServer().getUnsafe().modifyItemStack(stack.clone(), "{}");
return true;
} catch (NullPointerException npe) {
if (ess.getSettings().isDebug()) {

View file

@ -50,8 +50,12 @@ public class Commandgive extends EssentialsCommand {
throw new NotEnoughArgumentsException();
}
MetaItemStack metaStack = new MetaItemStack(stack);
if (!metaStack.canSpawn(ess)) {
throw new Exception(tl("unableToSpawnItem", itemname));
}
if (args.length > 3) {
MetaItemStack metaStack = new MetaItemStack(stack);
boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
if (allowUnsafe && sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.enchantments.allowunsafe")) {
allowUnsafe = false;

View file

@ -39,8 +39,13 @@ public class Commanditem extends EssentialsCommand {
} catch (NumberFormatException e) {
throw new NotEnoughArgumentsException();
}
MetaItemStack metaStack = new MetaItemStack(stack);
if (!metaStack.canSpawn(ess)) {
throw new Exception(tl("unableToSpawnItem", itemname));
}
if (args.length > 2) {
MetaItemStack metaStack = new MetaItemStack(stack);
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchantments.allowunsafe");
metaStack.parseStringMeta(user.getSource(), allowUnsafe, args, 2, ess);