Ver código fonte

NPE fix for McMMOPlayerExperienceEvent

nossr50 4 anos atrás
pai
commit
49f1154e65

+ 1 - 0
Changelog.txt

@@ -6,6 +6,7 @@ Version 2.1.182
     Added some safety so that mcMMO automatic save interval is never more frequent than 1 minute
     Removed a few silent exceptions for scoreboards & mcMMO
     Added warning about UltraPermissions to mcMMO
+    Fixed a potential NPE in McMMOPlayerExperienceEvent
 
 Version 2.1.181
     mcMMO no longer pointlessly tries to check for missing UUIDs for FlatFile database

+ 7 - 1
src/main/java/com/gmail/nossr50/events/experience/McMMOPlayerExperienceEvent.java

@@ -29,7 +29,13 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
     protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill, XPGainReason xpGainReason) {
         super(player);
         this.skill = skill;
-        this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
+
+        if(UserManager.getPlayer(player) != null) {
+            this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
+        } else {
+            this.skillLevel = 0;
+        }
+
         this.xpGainReason = xpGainReason;
     }
 

+ 5 - 4
src/main/java/com/gmail/nossr50/mcMMO.java

@@ -74,10 +74,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class mcMMO extends JavaPlugin {
-    public static final String ULTRA_PERMISSONS = "UltraPermissons";
-    public static final String UP_WARNING_2 = "Stop using " + ULTRA_PERMISSONS + " with mcMMO immediately!";
-    public static final String UP_WARNING_1 = "mcMMO has detected " + ULTRA_PERMISSONS + " on your server, users have reported a severe plugin conflict between these two plugins which severely degrades server performance";
-    public static final String UP_WARNING_3 = "The author of UltraPermissions has passed away and its unlikely this issue will ever be solved";
     /* Managers */
     private static PlatformManager platformManager;
     private static ChunkManager       placeStore;
@@ -152,6 +148,11 @@ public class mcMMO extends JavaPlugin {
 
     public static FixedMetadataValue metadataValue;
 
+    public static final String ULTRA_PERMISSONS = "UltraPermissons";
+    public static final String UP_WARNING_2 = "Stop using " + ULTRA_PERMISSONS + " with mcMMO immediately!";
+    public static final String UP_WARNING_1 = "mcMMO has detected " + ULTRA_PERMISSONS + " on your server, users have reported a severe plugin conflict between these two plugins which severely degrades server performance";
+    public static final String UP_WARNING_3 = "The author of UltraPermissions has passed away and its unlikely this issue will ever be solved";
+
     public mcMMO() {
         p = this;
     }