[NPE] Null checker

Discussion in 'Spigot Plugin Development' started by Hugmanrique, Jun 17, 2015.

Thread Status:
Not open for further replies.
  1. Hi, in a void method I have put a null checker like this:
    PHP:
    if (plugin.getAjustes().ajustesCooldown.get(p) == null)
    The console says there's a Null Pointer Exception in that line, I don't know how to fix it
     
  2. Any chance that plugin is null?
     
  3. Everything in that line could be null.
    Please provide all variables (plugin, getAjustes(), ajustesCooldown) and where you assign them.
     
    • Useful Useful x 1
  4. Just add multiple if statements to test:

    Code (Text):
    if (plugin == null) {
    Bukkit.broadcastMessage("1");
    }
    if (plugin.getAjustes() == null) {
    Bukkit.broadcastMessage("2");
    }
    etc.
     
    • Agree Agree x 2
    • Useful Useful x 1
  5. Well, thanks for all of your help. The problem was getAjustes() wasn't initialized and was causing a NPE.
     
Thread Status:
Not open for further replies.