mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56: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) {
|
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);
|
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skill, xpGained, xpGainReason);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
boolean isCancelled = event.isCancelled();
|
boolean isCancelled = event.isCancelled();
|
||||||
|
|
||||||
if (!isCancelled) {
|
if (!isCancelled) {
|
||||||
UserManager.getPlayer(player).addXp(skill, event.getRawXpGained());
|
mmoPlayer.addXp(skill, event.getRawXpGained());
|
||||||
UserManager.getPlayer(player).getProfile().registerXpGain(skill, event.getRawXpGained());
|
mmoPlayer.getProfile().registerXpGain(skill, event.getRawXpGained());
|
||||||
}
|
}
|
||||||
|
|
||||||
return !isCancelled;
|
return !isCancelled;
|
||||||
|
Loading…
Reference in New Issue
Block a user