NullPointerException error on Maps

Discussion in 'Plugin Development' started by Jaker232, Jan 27, 2014.

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

    Jaker232

    Alright, so I'm fulfilling a plugin request. I've gotten around most of the features and decided to give a shot. However, the error I'm getting is passing event to the plugin error, caused by a NullPointerException on line 28 in my Listener class. When I go there, I have this line.
    Code:java
    1.  
    2. if(!db.isInMemory(b.getLocation())) {
    3.  


    I have a class variable that manages the plugin's main functionality, automatically restoring ores. However, isInMemory is a boolean and uses the Location parameter. This is what I have for the method:
    Code:java
    1.  
    2.  
    3. public boolean isInMemory(Location locBlock) {
    4. if(ore.containsKey(locBlock) && time.containsKey(locBlock)) {
    5. return true;
    6. } else {
    7. return false;
    8. }
    9. }
    10.  

    What I don't get is, the containsKey if I remember should at least return true or false, not null. I do not know what is going on. Does anyone have an idea?
     
  2. Offline

    Jake6177

    You're checking maps that the method doesn't know about? Unless it's somewhere else in the class.

    Another idea..is "b" actually defined? is db?
     
  3. Offline

    Jaker232

    Db and b is defined. The maps are defined outside the class and are initialized in the constructor.
     
Thread Status:
Not open for further replies.

Share This Page