From aec5859c2a203bcbe2c4823ac90847795b417c3c Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Thu, 16 May 2024 16:54:26 -0400 Subject: [PATCH] Fix console error during /give command 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. --- .../earth2me/essentials/MetaItemStack.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java b/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java index 989e6fb76..7926a31c8 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java +++ b/Essentials/src/main/java/com/earth2me/essentials/MetaItemStack.java @@ -129,17 +129,20 @@ public class MetaItemStack { } 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 {