FastCraft

FastCraft

138k Downloads

PrepareItemCraftEvent error in other plugins

TheTechnologyStudio opened this issue ยท 11 comments

commented

This error spams console when ever u take a sword or piece of armour out of inventory

[17:38:52 ERROR]: Could not pass event PrepareItemCraftEvent to Better_Combat v1.12
org.bukkit.event.EventException: null
        at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:46) ~[patched_1.12.jar:git-Paper-1124]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.12.jar:git-Paper-1124]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.jar:git-Paper-1124]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:514) [patched_1.12.jar:git-Paper-1124]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:499) [patched_1.12.jar:git-Paper-1124]
        at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPreCraftEvent(CraftEventFactory.java:790) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.Container.a(Container.java:652) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.ContainerPlayer.a(ContainerPlayer.java:75) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.InventoryCrafting.setItem(InventoryCrafting.java:130) [patched_1.12.jar:git-Paper-1124]
        at org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventoryCrafting.setItem(CraftInventoryCrafting.java:83) [patched_1.12.jar:git-Paper-1124]
        at co.kepler.fastcraftplus.recipes.CraftingListener$1.run(CraftingListener.java:47) [FastCraftPlus.jar:?]
        at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:58) [patched_1.12.jar:git-Paper-1124]
        at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:356) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:832) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:423) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:766) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:664) [patched_1.12.jar:git-Paper-1124]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
Caused by: java.lang.NullPointerException
        at me.anderson.bc.players.PlayerOffHand.craftItem(PlayerOffHand.java:74) ~[?:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor215.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:44) ~[patched_1.12.jar:git-Paper-1124]
        ... 17 more
commented

This looks like an issue with Better Combat. The plugin isn't null checking before accessing variables. You should share this stack trace with the developer of that plugin.

commented

its being caused by your plugin, it only happens with ur plugin installed. Also i removed better combat and still got the same error.

When i removed your plugin the error stopped.

commented

Can you share the error you get when you remove Better Combat?

The stack trace you shared says the error from Better Combat:

[17:38:52 ERROR]: Could not pass event PrepareItemCraftEvent to Better_Combat v1.12
...
Caused by: java.lang.NullPointerException
        at me.anderson.bc.players.PlayerOffHand.craftItem(PlayerOffHand.java:74) ~[?:?]

This is saying a null pointer exception is occurring in PlayerOffHand, which is from Better Combat.

commented

tried it with another plugin, not better_combat also ur plugin is the only one i own that edits crafting items.

[13:09:40 ERROR]: Could not pass event PrepareItemCraftEvent to OldCombatMechanics v1.4.2
org.bukkit.event.EventException: null
        at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:46) ~[patched_1.12.jar:git-Paper-1124]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.12.jar:git-Paper-1124]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.jar:git-Paper-1124]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:514) [patched_1.12.jar:git-Paper-1124]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:499) [patched_1.12.jar:git-Paper-1124]
        at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPreCraftEvent(CraftEventFactory.java:790) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.Container.a(Container.java:652) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.ContainerPlayer.a(ContainerPlayer.java:75) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.InventoryCrafting.setItem(InventoryCrafting.java:130) [patched_1.12.jar:git-Paper-1124]
        at org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventoryCrafting.setItem(CraftInventoryCrafting.java:83) [patched_1.12.jar:git-Paper-1124]
        at co.kepler.fastcraftplus.recipes.CraftingListener$1.run(CraftingListener.java:47) [FastCraftPlus.jar:?]
        at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:58) [patched_1.12.jar:git-Paper-1124]
        at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:356) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:832) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:423) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:766) [patched_1.12.jar:git-Paper-1124]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:664) [patched_1.12.jar:git-Paper-1124]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
Caused by: java.lang.NullPointerException
        at gvlfm78.plugin.OldCombatMechanics.module.ModuleShieldCrafting.onItemCraft(ModuleShieldCrafting.java:45) ~[?:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor205.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:44) ~[patched_1.12.jar:git-Paper-1124]
        ... 17 more
commented

Does this occur when you take an item out of your own inventory (unrelated to crafting), when you craft an item using the FastCraft interface, or when you craft with the normal Minecraft crafting table?

This seems like an issue with other plugins missing null checks, but I will see if there's anything I can do to prevent it from my end.

commented

when i take a item out of creative mode inventory and put into my hotbar

commented

Ok, i will talk to them

commented

This isn't something that I will be able to fix. This happens when FastCraft monitors crafting tables for its custom recipes (from the recipes.yml file). It isn't doing anything out of the ordinary that a well coded plugin shouldn't be able to handle.

Checking that values aren't null before using them is a standard practice, and the plugins throwing errors are making the bad assumption that the values will never be null. You should share the stack traces with the plugin developers, and mention that they should include null checks to prevent their plugins from causing errors.

commented

It should be a quick fix. Adding code like this should do the trick for them:

if (event.getRecipe() == null) return;
commented

I found a way to resolve the issue. v0.27.2 will have the fix.

commented

i saw and it works. Thank you.