mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-29 17:58:25 +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) {
|
public boolean canSpawn(final IEssentials ess) {
|
||||||
try {
|
try {
|
||||||
ess.getServer().getUnsafe().modifyItemStack(stack, "{}");
|
ess.getServer().getUnsafe().modifyItemStack(stack.clone(), "{}");
|
||||||
return true;
|
return true;
|
||||||
} catch (NullPointerException npe) {
|
} catch (NullPointerException npe) {
|
||||||
if (ess.getSettings().isDebug()) {
|
if (ess.getSettings().isDebug()) {
|
||||||
|
|
|
@ -50,8 +50,12 @@ public class Commandgive extends EssentialsCommand {
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length > 3) {
|
|
||||||
MetaItemStack metaStack = new MetaItemStack(stack);
|
MetaItemStack metaStack = new MetaItemStack(stack);
|
||||||
|
if (!metaStack.canSpawn(ess)) {
|
||||||
|
throw new Exception(tl("unableToSpawnItem", itemname));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length > 3) {
|
||||||
boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
||||||
if (allowUnsafe && sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.enchantments.allowunsafe")) {
|
if (allowUnsafe && sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.enchantments.allowunsafe")) {
|
||||||
allowUnsafe = false;
|
allowUnsafe = false;
|
||||||
|
|
|
@ -39,8 +39,13 @@ public class Commanditem extends EssentialsCommand {
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
if (args.length > 2) {
|
|
||||||
MetaItemStack metaStack = new MetaItemStack(stack);
|
MetaItemStack metaStack = new MetaItemStack(stack);
|
||||||
|
if (!metaStack.canSpawn(ess)) {
|
||||||
|
throw new Exception(tl("unableToSpawnItem", itemname));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length > 2) {
|
||||||
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchantments.allowunsafe");
|
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchantments.allowunsafe");
|
||||||
|
|
||||||
metaStack.parseStringMeta(user.getSource(), allowUnsafe, args, 2, ess);
|
metaStack.parseStringMeta(user.getSource(), allowUnsafe, args, 2, ess);
|
||||||
|
|
Loading…
Reference in a new issue