CustomSpawners

CustomSpawners

60.3k Downloads

Null Pointer Exception

Arrorn opened this issue ยท 1 comments

commented

In the SpawnableEntities class for the getType method you're using the toString method for the EntityType rather than the getName method. This is causing a Null Pointer exception when you try to get the info for a CaveSpider SpawnableEntity because Cave_Spider does not equal CaveSpider thus returns null. Also, with every other entity that in the EntityType has an underscore, e.i. PigZombie.
https://github.com/thebiologist13/CustomSpawners/blob/master/CustomSpawners/src/com/github/thebiologist13/SpawnableEntity.java#L225

2013-01-11 22:29:45 [INFO] Arrorn issued server command: /cse info
2013-01-11 22:29:45 [SEVERE] java.lang.NullPointerException
2013-01-11 22:29:45 [SEVERE]    at com.github.thebiologist13.commands.entities.EntityInfoCommand.getInfo(EntityInfoCommand.java:137)
2013-01-11 22:29:45 [SEVERE]    at com.github.thebiologist13.commands.entities.EntityInfoCommand.run(EntityInfoCommand.java:104)
2013-01-11 22:29:45 [SEVERE]    at com.github.thebiologist13.EntitiesExecutor.onCommand(EntitiesExecutor.java:226)
2013-01-11 22:29:45 [SEVERE]    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
2013-01-11 22:29:45 [SEVERE]    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186)
2013-01-11 22:29:45 [SEVERE]    at org.bukkit.craftbukkit.v1_4_6.CraftServer.dispatchCommand(CraftServer.java:514)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.PlayerConnection.handleCommand(PlayerConnection.java:979)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.PlayerConnection.chat(PlayerConnection.java:897)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.PlayerConnection.a(PlayerConnection.java:852)
2013-01-11 22:29:45 [SEVERE]    at org.getspout.spout.SpoutPlayerConnection.a(SpoutPlayerConnection.java:121)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.Packet3Chat.handle(Packet3Chat.java:44)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.NetworkManager.b(NetworkManager.java:290)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.PlayerConnection.d(PlayerConnection.java:112)
2013-01-11 22:29:45 [SEVERE]    at org.getspout.spout.SpoutPlayerConnection.d(SpoutPlayerConnection.java:196)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.ServerConnection.b(SourceFile:39)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.DedicatedServerConnection.b(SourceFile:30)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.MinecraftServer.r(MinecraftServer.java:598)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.DedicatedServer.r(DedicatedServer.java:224)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.MinecraftServer.q(MinecraftServer.java:494)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:427)
2013-01-11 22:29:45 [SEVERE]    at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)
commented

I've been messing around with various solutions to this null pointer exception because using getName doesn't always work because not all entities have names... you have parseEntity functions for going from name to type and type to name in the CustomSpawners Class if you just make those static functions and then wherever you need to convert from string to type or vice versa use that it seems to work.