Errorspam with anvils and enchantingtables
First of all, i know its bad to decompile plugins, but the errors were kind of annoying and i wanted to find out what caused them, since im using mythicenchants so much in the past time i stumbled upon these thousands of time and it just got really frustrating, even if its just visual.
[16:20:37 WARN]: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "item" is null
[16:20:37 WARN]: at MythicEnchants-0.0.1-SNAPSHOT (7).jar//io.lumine.mythicenchants.enchants.EnchantManager.getMythicEnchants(EnchantManager.java:88)
[16:20:37 WARN]: at MythicEnchants-0.0.1-SNAPSHOT (7).jar//io.lumine.mythicenchants.enchants.anvil.AnvilManager.handleAnvilEvent(AnvilManager.java:74)
[16:20:37 WARN]: at MythicLib-1.3-R21-SNAPSHOT_3 (2).jar//io.lumine.mythic.utils.Delegates$ConsumerToBiConsumerSecond.accept(Delegates.java:144)
[16:20:37 WARN]: at MythicLib-1.3-R21-SNAPSHOT_3 (2).jar//io.lumine.mythic.utils.events.functional.single.EventListener.execute(EventListener.java:131)
[16:20:37 WARN]: at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)
[16:20:37 WARN]: at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
[16:20:37 WARN]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628)
[16:20:37 WARN]: at org.bukkit.event.Event.callEvent(Event.java:45)
[16:20:37 WARN]: at org.bukkit.craftbukkit.v1_18_R1.event.CraftEventFactory.callPrepareResultEvent(CraftEventFactory.java:1661)
[16:20:37 WARN]: at net.minecraft.world.inventory.ContainerAnvil.a(ContainerAnvil.java:319)
[16:20:37 WARN]: at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:983)
[16:20:37 WARN]: at net.minecraft.network.protocol.game.PacketPlayInItemName.a(PacketPlayInItemName.java:24)
[16:20:37 WARN]: at net.minecraft.network.protocol.game.PacketPlayInItemName.a(PacketPlayInItemName.java:6)
[16:20:37 WARN]: at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$ensureRunningOnSameThread$1(PlayerConnectionUtils.java:56)
[16:20:37 WARN]: at net.minecraft.server.TickTask.run(TickTask.java:18)
[16:20:37 WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.c(IAsyncTaskHandler.java:149)
[16:20:37 WARN]: at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.c(IAsyncTaskHandlerReentrant.java:23)
[16:20:37 WARN]: at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1413)
[16:20:37 WARN]: at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:189)
[16:20:37 WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.y(IAsyncTaskHandler.java:122)
[16:20:37 WARN]: at net.minecraft.server.MinecraftServer.bf(MinecraftServer.java:1391)
[16:20:37 WARN]: at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1384)
[16:20:37 WARN]: at net.minecraft.util.thread.IAsyncTaskHandler.bp(IAsyncTaskHandler.java:110)
[16:20:37 WARN]: at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1518)
[16:20:37 WARN]: at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1264)
[16:20:37 WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317)
[16:20:37 WARN]: at java.base/java.lang.Thread.run(Thread.java:833)
in io.lumine.mythicenchants.enchants.EnchantManager, the first check should use || instead of && to check whether the item is empty/non-existent:
[16:21:23 WARN]: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.hasItemMeta()" because "lapis" is null
[16:21:23 WARN]: at MythicEnchants-0.0.1-SNAPSHOT (7).jar//io.lumine.mythicenchants.enchants.table.TableManager.getLapisData(TableManager.java:308)
[16:21:23 WARN]: at MythicEnchants-0.0.1-SNAPSHOT (7).jar//io.lumine.mythicenchants.enchants.table.TableManager.prepareEnchants(TableManager.java:271)
[16:21:23 WARN]: at MythicLib-1.3-R21-SNAPSHOT_3 (2).jar//io.lumine.mythic.utils.Delegates$ConsumerToBiConsumerSecond.accept(Delegates.java:144)
[16:21:23 WARN]: at MythicLib-1.3-R21-SNAPSHOT_3 (2).jar//io.lumine.mythic.utils.events.functional.single.EventListener.execute(EventListener.java:131)
[16:21:23 WARN]: at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)
[16:21:23 WARN]: at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
[16:21:23 WARN]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628)
... (this went on for a while, this was huge)
In prepareEnchants in io.lumine.mythicenchants.enchants.table.TableManager, you should check if lapis is null before calling getLapisData(lapis):
if (lapis == null) {
return;
}
int lapisType = getLapisData(lapis);