mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	Fixing an issue with mmoedit triggering notifications for skills already unlocked
This commit is contained in:
		@@ -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.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user