Solved An NPE that I can't solve...

Discussion in 'Plugin Development' started by KeybordPiano459, Dec 29, 2012.

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

    KeybordPiano459

    I'm getting an NPE on line 20 of CreatePlayerConfigJoin.java. That class is right here - http://pastebin.com/BBxvcUcJ

    The method that it's calling is right here - http://pastebin.com/DZhhqJ19

    Why am I getting an NPE there and how do I solve it? =/ Don't link me to that post on solving an NPE, I don't know what I would put a null check for =/
     
  2. Offline

    RealDope

    Add the following lines right before Line 20:

    Code:JAVA
    1.  
    2. System.out.println(plugin.getDataFolder());
    3. System.out.println(File.separator);
    4. System.out.pritnln(player.getName());
    5.  


    As I see it, the only one that has any chance of being null is plugin.getDataFolder()
     
  3. Offline

    KeybordPiano459

    Well I deleted the folder, and it regenerated, so that's not it, but I'll report the debug stuff in a sec.

    RealDope
    I'm getting an NPE on the line where the data folder should be printed...

    Also, this is in my onEnable():
    Code:java
    1. File folder = new File("plugins" + File.separator + "kEssentials");
    2. folder.mkdirs();


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  4. Offline

    Sagacious_Zed Bukkit Docs

    this means plugin is null... as you can safely print out a null object.
     
  5. Offline

    KeybordPiano459

  6. Offline

    Sagacious_Zed Bukkit Docs

    Doing a sanity check is not a bad idea.
     
  7. Offline

    KeybordPiano459

    Sagacious_Zed
    I just put in the null check, I'm not getting an NPE, but the file isn't being generated either =/

    Nevermind, I just messed around with the constructor a bit and got it to work :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
Thread Status:
Not open for further replies.

Share This Page