Solved Why is this null (V2)

Discussion in 'Spigot Plugin Development' started by gluebaby, May 26, 2017.

  1. Code (Text):
    Caused by: java.lang.NullPointerException
        at me.undeadguppy.gEnderGames.arena.Arena.containsPlayer(Arena.java:135) ~[?:?]
        at me.undeadguppy.gEnderGames.arena.Game.isInArena(Game.java:70) ~[?:?]
        at me.undeadguppy.gEnderGames.cmd.ArenaQuit.onCommand(ArenaQuit.java:20) ~[?:?]
        at me.undeadguppy.gEnderGames.cmd.CommandManager.onCommand(CommandManager.java:56) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
        ... 15 more
    >
     
    Code (Text):
        public boolean containsPlayer(Player p) {
            return (!players.isEmpty()) ? players.containsKey(p.getUniqueId()) : true;
        }
    Code (Text):
    if (Game.getInstance().isInArena(p)) {
    Here's the isInArena method from the previous line.
    Code (Text):
    public boolean isInArena(Player p) {
            for (Arena arena : arenas) {
                if (arena.containsPlayer(p)) {
                    return true;
                }
            }
            return true;
        }
     
  2. Is the list of players null?

    Also the last line of your code should be return false not return true
     
    #2 Aubameyang, May 26, 2017
    Last edited by a moderator: May 27, 2017
  3. FUCK ME.

    Another damn serialization error. Why must this happen to me twice in a row ;-;.