NPE at a HashMap

Discussion in 'Spigot Plugin Development' started by TheGamerPlayz, May 20, 2016.

  1. Just changed it to UUID and still getting the same error
     
    • Agree Agree x 1
  2. You're creating a new Map every time your method gets called, the player value doesn't exist when being pulled from the map.

    EDIT: sniped
     
    • Like Like x 1
  3. I moved it out of the event and it is still appearing

    Code (Text):

    [09:19:22 ERROR]: Could not pass event PlayerMoveEvent to FlagPvP v2.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:270) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PacketPlayInFlying$PacketPlayInPosition.a(SourceFile:57) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_73]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_73]
            at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_73]
    Caused by: java.lang.NullPointerException
            at FlagPvP.Listeners.StartCount.onPlayerMove(StartCount.java:48) ~[?:?]
            at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source) ~[?:?]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_73]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_73]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            ... 15 more
     
     
  4. Populate the map with relevant information, or do null checks for missing values. This is a pretty easy thing to solve :/
     
  5. I tried their names and their UUID's and nothing has worked so far, any suggestions as to what I should try?
     
  6. do null checks for missing values.

    Creds: Msrules123
     
  7. But how could the values be missing to begin with?
     
  8. As stated above, make sure you check if the map actually contains a UUID first. Make sure you're putting UUID in the map in place of the Player, as well as storing the UUID and not the player's name.