Solved HashMap getting nullpointer

Discussion in 'Plugin Development' started by boardinggamer, Nov 20, 2013.

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

    boardinggamer

    Code:java
    1. if (!plugin.signs.isEmpty()){
    2. for (Block block : plugin.signs.keySet()){
    3.  
    4. int time = plugin.signs.get(block);
    5.  
    6. if (time == 15){
    7.  
    8. Sign sign = (Sign) block.getState();
    9. sign.setLine(1, "");
    10. sign.setLine(2, "");
    11. sign.setLine(3, "");
    12. plugin.signs.remove(block);
    13.  
    14. } else {
    15.  
    16. time++;
    17. plugin.signs.put(block, time);
    18.  
    19. }
    20.  
    21. }
    22.  
    23. }


    that first line keeps giving me a nullpointer.

    This is my onEnable part. Am I missing something there?
    Code:java
    1. public HashMap<Block, Integer> signs = new HashMap<Block, Integer>();
    2.  
    3. public void onEnable(){
    4.  
    5. PluginManager pm = getServer().getPluginManager();
    6. pm.registerEvents(this, this);
    7.  
    8. getServer().getScheduler().scheduleSyncRepeatingTask(this, new Task_ClearSigns(this), 20L, 20L);
    9.  
    10. }
     
  2. Offline

    adam753

    It's not the hashmap that's null, it's the plugin variable.
    Or at least.. Probably?
     
  3. Offline

    boardinggamer

    Oh wow you were right. I feel stupid now xD
    Thanks
     
Thread Status:
Not open for further replies.

Share This Page