Skip to content

Commit

Permalink
Fix console error during /give command
Browse files Browse the repository at this point in the history
There has been a method for this since 1.13.
Why have we been using this for so long?

Since item NBT is now dead, this method for checking
if an item is spawn-able is defunct and produces a console
error every time the give command is ran.
  • Loading branch information
JRoy committed May 27, 2024
1 parent 5392169 commit aec5859
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,20 @@ private void resetPotionMeta() {
}

public boolean canSpawn(final IEssentials ess) {
try {
ess.getServer().getUnsafe().modifyItemStack(stack.clone(), "{}");
return true;
} catch (final NoSuchMethodError nsme) {
return true;
} catch (final Throwable npe) {
if (ess.getSettings().isDebug()) {
ess.getLogger().log(Level.INFO, "Itemstack is invalid", npe);
if (VersionUtil.PRE_FLATTENING) {
try {
ess.getServer().getUnsafe().modifyItemStack(stack.clone(), "{}");
return true;
} catch (final NoSuchMethodError nsme) {
return true;
} catch (final Throwable npe) {
if (ess.getSettings().isDebug()) {
ess.getLogger().log(Level.INFO, "Itemstack is invalid", npe);
}
return false;
}
return false;
}
return stack.getType().isItem();
}

public void parseStringMeta(final CommandSource sender, final boolean allowUnsafe, final String[] string, final int fromArg, final IEssentials ess) throws Exception {
Expand Down

0 comments on commit aec5859

Please sign in to comment.