Don't process null McMMOPlayer events

Fixes #4499
This commit is contained in:
nossr50 2021-04-23 10:20:20 -07:00
parent 6d0fe4fb58
commit 9b4070d971
2 changed files with 13 additions and 0 deletions

View File

@ -1,4 +1,5 @@
Version 2.1.196 Version 2.1.196
Fixed a possible null error for our SelfListener
Crossbows can now be fished up with enchantments Crossbows can now be fished up with enchantments
NOTES: NOTES:

View File

@ -33,6 +33,13 @@ public class SelfListener implements Listener {
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) { public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PrimarySkillType skill = event.getSkill(); PrimarySkillType skill = event.getSkill();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//TODO: Handle proper validation at the event level
if(mcMMOPlayer == null || !mcMMOPlayer.getProfile().isLoaded())
return;
if(player.isOnline()) { if(player.isOnline()) {
//Players can gain multiple levels especially during xprate events //Players can gain multiple levels especially during xprate events
for(int i = 0; i < event.getLevelsGained(); i++) for(int i = 0; i < event.getLevelsGained(); i++)
@ -73,6 +80,11 @@ public class SelfListener implements Listener {
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) { public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//TODO: Handle proper validation at the event level
if(mcMMOPlayer == null || !mcMMOPlayer.getProfile().isLoaded())
return;
PrimarySkillType primarySkillType = event.getSkill(); PrimarySkillType primarySkillType = event.getSkill();
if(mcMMOPlayer.isDebugMode()) { if(mcMMOPlayer.isDebugMode()) {