mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 20:00:46 +00:00
Fix MetaItemStack canSpawn() method to try it on a clone, readd check to /give and /i
This commit is contained in:
parent
14c4ed8379
commit
ff3b1e810f
3 changed files with 12 additions and 3 deletions
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue