Browse Source

NPE prevention for Users.getProfile()

bm01 13 năm trước cách đây
mục cha
commit
4469637f27

+ 3 - 1
src/main/java/com/gmail/nossr50/util/Users.java

@@ -97,7 +97,9 @@ public class Users {
      * @return the player's profile
      * @return the player's profile
      */
      */
     public static PlayerProfile getProfile(String playerName) {
     public static PlayerProfile getProfile(String playerName) {
-        return players.get(playerName).getProfile();
+        McMMOPlayer mcmmoPlayer = players.get(playerName);
+
+        return (mcmmoPlayer != null) ? mcmmoPlayer.getProfile() : null;
     }
     }
 
 
     /**
     /**