[solved]Why is this null

Discussion in 'Plugin Development' started by Mike111177, Jun 16, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Mike111177

    i have been working on this class all day and when i finally got around to testing it this is what came up
    Code:
    
     [SEVERE] Sat Jun 16 19:50:11 EDT 2012 Command /sts spectate chris  used by Mike111177 generated an exception.
    java.lang.NullPointerException
    	at net.othercraft.steelsecurity.listeners.SpectateManager.specCmd(SpectateManager.java:99)
    	at net.othercraft.steelsecurity.commands.Sts.command(Sts.java:198)
    	at net.othercraft.steelsecurity.commands.Sts.handleCommand(Sts.java:231)
    	at net.othercraft.steelsecurity.utils.SSCmdExe.onCommand(SSCmdExe.java:41)
    	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40)
    	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:166)
    	at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:479)
    	at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:821)
    	at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:781)
    	at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:764)
    	at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:34)
    	at net.minecraft.server.NetworkManager.b(NetworkManager.java:229)
    	at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:113)
    	at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:78)
    	at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:567)
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:459)
    	at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    
    all of the scource is at https://github.com/Mike111177/Steel-Security please help.
     
  2. Offline

    Mitsugaru

    One of two things I can think of... either:
    A) Seems like your Player object is null, perhaps it didn't find the exact name given?
    B) The player key given is not in your spectators hashmap, and thus returns null.
     
  3. Offline

    Jnorr44

    Line 99 of SpectateManager

    Something is wrong there, you need to show the code.
     
  4. I see mutch Map<Player,Boolean>
    1: dont use Players as keys, unsafe and memory consuming
    2: An Set<T> is better to use than an map<T,boolean>, because it takes up less space and have faster functions (and dont give nulls when the object is not inside it, just true or false
     
Thread Status:
Not open for further replies.

Share This Page