crashdemons / LoreKillCounter

Bukkit plugin that adds kill-counters to weapon ingame-item loretext
2 stars 0 forks source link

NPE on entity death under certain conditions (eg: Ghast Return-to-Sender) #1

Closed crashdemons closed 5 years ago

crashdemons commented 5 years ago

The line causing the NPE is indicated by logs to be Line 69 of LKC in in v0.0.2: https://github.com/crashdemons/LoreKillCounter/blob/ab5401911c0fe3e9a3db780d40f444d4476f69a0/src/main/java/com/github/crashdemons/lorekillcounter/LoreKillCounter.java#L65-L69

The NPE seems to imply the meta is null, however it is already checked and generated if null - additionally, Item.getItemMeta's code also now performs this same check/construction in spigot-api.

I am really confused by this.

The trace is below:

[15:24:54] [Server thread/ERROR]: Could not pass event EntityDeathEvent to LoreKillCounter v0.0.2-SNAPSHOT
java.lang.NullPointerException: null
    at com.github.crashdemons.lorekillcounter.LoreKillCounter.applyCounterOperation(LoreKillCounter.java:69) ~[?:?]
    at com.github.crashdemons.lorekillcounter.LoreKillCounter.applyCounterOperation(LoreKillCounter.java:77) ~[?:?]
    at com.github.crashdemons.lorekillcounter.LoreKillCounter.onEntityDeathEvent(LoreKillCounter.java:178) ~[?:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor20.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.13.2.jar:git-Paper-600]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.13.2.jar:git-Paper-600]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:66) ~[patched_1.13.2.jar:git-Paper-600]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:520) ~[patched_1.13.2.jar:git-Paper-600]
    at org.bukkit.craftbukkit.v1_13_R2.event.CraftEventFactory.callEntityDeathEvent(CraftEventFactory.java:607) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.EntityLiving.die(EntityLiving.java:1243) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.EntityLiving.damageEntity(EntityLiving.java:1088) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.EntityGhast.damageEntity(EntityGhast.java:46) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.EntityLargeFireball.a(EntityLargeFireball.java:22) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.EntityFireball.tick(EntityFireball.java:81) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.World.entityJoinedWorld(World.java:1569) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.World.g(World.java:1536) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.World.tickEntities(World.java:1343) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.WorldServer.tickEntities(WorldServer.java:599) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.MinecraftServer.b(MinecraftServer.java:1107) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:439) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:940) ~[patched_1.13.2.jar:git-Paper-600]
    at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:837) ~[patched_1.13.2.jar:git-Paper-600]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_202]
[15:24:54] [Server thread/INFO]: Etherack has completed the challenge [Return to Sender]
crashdemons commented 5 years ago

After much obscure research there appears to be one exception to Bukkit.getItemFactory().getItemMeta(...) returning an object, one that is not listed in the javadoc: When the item type is AIR.

I'm not sure why I didn't have this error when testing previous versions though.