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
            at$1.execute( ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.RegisteredListener.callEvent( ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.fireEvent( [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.callEvent( [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.PlayerConnection.a( [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$ [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at java.util.concurrent.Executors$ Source) [?:1.8.0_73]
            at 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( [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B( [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A( [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
            at Source) [?:1.8.0_73]
    Caused by: java.lang.NullPointerException
            at FlagPvP.Listeners.StartCount.onPlayerMove( ~[?:?]
            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$1.execute( ~[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.