Fixed an NPE that may occur with random chances on a player without loaded data

Also correct changelog version
This commit is contained in:
Shane Freeder 2019-07-29 18:41:28 +01:00
parent 1e2f11f4f9
commit ac29c51d6e
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
2 changed files with 14 additions and 10 deletions

View File

@ -1,9 +1,8 @@
Version 2.1.101
mcnotify command now checks that it's being executed by a player
Fixed some concurrency concerns around BleedTasks
Version 2.1.100
Corrected some mistakes made in the updated Russian locale (thanks myfbone!)
mcnotify command now checks that it's being executed by a player
Fixed some concurrency concerns around BleedTasks
Fixed an NPE that may occur with random chances on a player without loaded data
Version 2.1.99
MASSIVE update to the Russian locale (ru) credit to myfbone

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.util.random;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.util.Permissions;
@ -21,10 +22,12 @@ public class RandomChanceSkill implements RandomChanceExecution {
this.subSkillType = subSkillType;
this.probabilityCap = RandomChanceUtil.LINEAR_CURVE_VAR;
if(player != null)
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(primarySkillType);
else
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (player != null && mcMMOPlayer != null) {
this.skillLevel = mcMMOPlayer.getSkillLevel(primarySkillType);
} else {
this.skillLevel = 0;
}
if(player != null)
isLucky = Permissions.lucky(player, primarySkillType);
@ -42,10 +45,12 @@ public class RandomChanceSkill implements RandomChanceExecution {
this.primarySkillType = subSkillType.getParentSkill();
this.subSkillType = subSkillType;
if(player != null)
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(primarySkillType);
else
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (player != null && mcMMOPlayer != null) {
this.skillLevel = mcMMOPlayer.getSkillLevel(primarySkillType);
} else {
this.skillLevel = 0;
}
if(player != null)
isLucky = Permissions.lucky(player, primarySkillType);