CreeperHeal

CreeperHeal

281k Downloads

NPE in new API

ryantheleach opened this issue ยท 3 comments

commented

[00:04:26] [Server thread/ERROR]: Could not pass event EntityExplodeEvent to CreeperHeal v6.7.2
org.bukkit.event.EventException
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:294) ~[spigot.jar:git-Spigot-1366]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-1366]
at org.bukkit.plugin.TimedRegisteredListener.callEvent(TimedRegisteredListener.java:30) ~[spigot.jar:git-Spigot-1366]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-1366]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.Explosion.a(Explosion.java:219) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.World.createExplosion(World.java:1759) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.WorldServer.createExplosion(WorldServer.java:885) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.EntityTNTPrimed.explode(EntityTNTPrimed.java:82) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.EntityTNTPrimed.h(EntityTNTPrimed.java:62) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.World.entityJoinedWorld(World.java:1484) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.World.playerJoinedWorld(World.java:1460) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.World.tickEntities(World.java:1329) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.WorldServer.tickEntities(WorldServer.java:515) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.MinecraftServer.v(MinecraftServer.java:676) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.DedicatedServer.v(DedicatedServer.java:273) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.MinecraftServer.u(MinecraftServer.java:566) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.MinecraftServer.run(MinecraftServer.java:472) [spigot.jar:git-Spigot-1366]
at net.minecraft.server.v1_7_R2.ThreadServerApplication.run(SourceFile:618) [spigot.jar:git-Spigot-1366]
Caused by: java.lang.NullPointerException
at
https://github.com/nitnelave/CreeperHeal/blob/master/src/main/java/com/nitnelave/CreeperHeal/block/ToReplaceList.java#L34

com.nitnelave.CreeperHeal.block.ToReplaceList.addToReplace(ToReplaceList.java:34) ~[?:?]
at
https://github.com/nitnelave/CreeperHeal/blob/master/src/main/java/com/nitnelave/CreeperHeal/block/ExplodedBlockManager.java#L182
com.nitnelave.CreeperHeal.block.ExplodedBlockManager.processExplosion(ExplodedBlockManager.java:183) ~[?:?]
at com.nitnelave.CreeperHeal.block.ExplodedBlockManager.processExplosion(ExplodedBlockManager.java:156) ~[?:?]
at com.nitnelave.CreeperHeal.listeners.CreeperListener.onEntityExplode(CreeperListener.java:60) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_05]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_05]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_05]
at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_05]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[spigot.jar:git-Spigot-1366]
... 18 more

I suspected it may a null block, but I added a check to see if the block was null, and if so log to system.out.println in the plugin modifying CreeperHealExplosionRecord but no output appeared.

I had tested this so I am unsure if this is an occasional error, or if my testing missed the exception.

commented

It seems that the CreeperBlock.newBlock is returning null. That only happens for TNT, Fire or AIR, but it can happen, as this is uncontrolled input. So I suggest to add a null check before adding it to the replace list.
Oh, and by the way, there's no need to have the variable processList, you can directly refer to the event's blocklist.

commented

Oh, and by the way, there's no need to have the variable processList, you can directly refer to the event's blocklist.

It was a defensive copy of the list since people can setBlocks . It may not be needed but I felt better having it there.

commented

It was a defensive copy of the list since people can setBlocks . It may
not be needed but I felt better having it there.

The people can setBlocks, true, but once the call comes back after throwing
the event, no one will change it, so it's ok.