Solved Null Pointer Exception

Discussion in 'Plugin Development' started by 1SmallVille1, Mar 29, 2013.

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

    1SmallVille1

    Hey guys, so I'm working on a plugin that works very similarly to an economy plugin, and I was wondering how I would check if a player has an account. What I do is I create a file that stores all the account info like <playername>.account: (their amount) but when I check to see if they have an account I use :
    Code:
    if (settings.getAccounts().get(pname) != null) {
     
    }
    but it doesn't work. It passes an NPE even though I check to see if it's null.
     
  2. Offline

    caseif

    Well, this means that either settings, the value returned from getAccounts(), or pname is null. Check each of those and make appropriate changes.
     
  3. Offline

    1SmallVille1

    welll I know that the .get(pname) is null but I thought that was covered with the != null check
     
  4. Offline

    caseif

    Check the other values.
     
  5. Offline

    1SmallVille1

    ok thanks, my .getAccounts() was null. Thank you
     
Thread Status:
Not open for further replies.

Share This Page