Fixing an issue with mmoedit triggering notifications for skills already unlocked

This commit is contained in:
nossr50 2019-03-30 17:44:06 -07:00
parent f1ecef310c
commit 456e64456d
3 changed files with 19 additions and 1 deletions

View File

@ -153,6 +153,8 @@ Version 2.2.0
Version 2.1.31
Fixed a bug where certain SubSkills did not properly send unlock or rank up notifications
Fixed a bug where unlock notifications would send simultaneously for a specific skill (still happens if mmoedit changes all skill levels on a player at once)
Fixed NPE with grabbing offline player skill ranks through certain API methods (thanks Ineusia)
Updated German language locale (thanks OverCrave)
Version 2.1.30
Fixed double drops behaving oddly

View File

@ -36,7 +36,7 @@ public class MmoeditCommand extends ExperienceCommand {
return;
}
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND);
EventUtils.handleLevelChangeEventEdit(player, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND, skillLevel);
}
@Override

View File

@ -198,6 +198,22 @@ public class EventUtils {
return !isCancelled;
}
public static boolean handleLevelChangeEventEdit(Player player, PrimarySkillType skill, int levelsChanged, float xpRemoved, boolean isLevelUp, XPGainReason xpGainReason, int oldLevel) {
McMMOPlayerLevelChangeEvent event = isLevelUp ? new McMMOPlayerLevelUpEvent(player, skill, levelsChanged - oldLevel, xpGainReason) : new McMMOPlayerLevelDownEvent(player, skill, levelsChanged, xpGainReason);
mcMMO.p.getServer().getPluginManager().callEvent(event);
boolean isCancelled = event.isCancelled();
if (isCancelled) {
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
profile.modifySkill(skill, profile.getSkillLevel(skill) - (isLevelUp ? levelsChanged : -levelsChanged));
profile.addXp(skill, xpRemoved);
}
return !isCancelled;
}
/**
* Simulate a block break event.
*