Null config path

Discussion in 'Plugin Development' started by BlazingBroGamer, Jun 28, 2014.

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

    BlazingBroGamer

    So I am making a plugin, which uses the config api which is already implemented into bukkit, but then I run into a problem, that I can make the paths itself, and save it, but it shows up as null when I load it.
    Code:
    Caused by: java.lang.NullPointerException
    at me.BlazingBroGamer.Mondaiji.Control.PlayerControl.isHost([B]PlayerControl.java:11[/B]) ~[?:?]
    at me.BlazingBroGamer.Mondaiji.Mondaiji.onCommand(Mondaiji.java:94) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Spigot-1493]
     
    ... 13 more
    
    The problem is in PlayerControl.java:11.
    Code:
    //This is how I check the boolean.
    public boolean isHost(Player p){
    return m.getConfig().getBoolean(p.getName() + ".IsHost");
    }
    
    Then I check the config, and it is null. I don't really know whats wrong.
     
  2. Offline

    Traks

    I think the 'm' variable or 'p' variable is null, where/how did you declare them?
     
  3. Offline

    BlazingBroGamer

    Traks
    m is the instance of the main config
    Code:
    public static Main getInstance(){
    //Set it to this on enable, and set it to null on disable, so no problem there
    returnplugin;
     
    }
    
    and p is the Player (Sorry I forgot to add [Player p] to the isHost)
     
  4. Offline

    Traks

    Could you show the complete source code?
     
  5. Offline

    mythbusterma

    Just a note, don't use the player's name to store an association, use their UUID instead. Also, make sure "p" isn't null, just do some simple checks before.
     
Thread Status:
Not open for further replies.

Share This Page