mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
* Add null check to XP gain handler, fixes #4663 Co-authored-by: Robert Alan Chapton <nossr50@gmail.com>
This commit is contained in:
parent
cf67e3502a
commit
519d469cb2
@ -379,14 +379,18 @@ public final class EventUtils {
|
||||
}
|
||||
|
||||
public static boolean handleXpGainEvent(Player player, PrimarySkillType skill, float xpGained, XPGainReason xpGainReason) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
if(mmoPlayer == null)
|
||||
return true;
|
||||
|
||||
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skill, xpGained, xpGainReason);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
boolean isCancelled = event.isCancelled();
|
||||
|
||||
if (!isCancelled) {
|
||||
UserManager.getPlayer(player).addXp(skill, event.getRawXpGained());
|
||||
UserManager.getPlayer(player).getProfile().registerXpGain(skill, event.getRawXpGained());
|
||||
mmoPlayer.addXp(skill, event.getRawXpGained());
|
||||
mmoPlayer.getProfile().registerXpGain(skill, event.getRawXpGained());
|
||||
}
|
||||
|
||||
return !isCancelled;
|
||||
|
Loading…
Reference in New Issue
Block a user