Solved Another random NullPointerException

Discussion in 'Plugin Development' started by TigerHix, Jul 18, 2013.

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

    TigerHix

    Code:java
    1. public HashMap <String, SuperPlayer> players = new HashMap <String, SuperPlayer>();


    Code:java
    1. @EventHandler
    2. public void onJoin(PlayerJoinEvent evt) {
    3.  
    4. Player p = evt.getPlayer();
    5.  
    6. // Check if player in players HashMap
    7.  
    8. if (Main.players.containsKey(p.getName())) {
    9. p.sendMessage("Profile not found. Creating a profile for you..");
    10. Main.players.put(p.getName(), new SuperPlayer());
    11. } else {
    12. p.sendMessage("Profile found. Loading your profile..");
    13. }
    14.  
    15. }


    And when player joins, Bukkit throws a NullPointerException.
    I have totally no ideas on this issue. How can I solve it?

    Problem solved.

    I forgot to set the instance of Main class.

    *facepalm*

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

Share This Page