1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2025-03-27 20:29:44 +01:00

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 57b31b60b3
commit b125600dac
3 changed files with 19 additions and 1 deletions
Changelog.txt
src/main/java/com/gmail/nossr50
commands/experience
util

@ -10,6 +10,8 @@ Key:
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

@ -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

@ -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.
*