mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-04 02:53:43 +01:00 
			
		
		
		
	Fire McMMOPlayerLevelUp events for our experience commands, when
applicable. Fixes #921
This commit is contained in:
		@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.gmail.nossr50.mcMMO;
 | 
			
		||||
import com.gmail.nossr50.datatypes.skills.SkillType;
 | 
			
		||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
 | 
			
		||||
import com.gmail.nossr50.locale.LocaleLoader;
 | 
			
		||||
import com.gmail.nossr50.util.Permissions;
 | 
			
		||||
import com.gmail.nossr50.util.skills.SkillUtils;
 | 
			
		||||
@@ -21,6 +23,10 @@ public class AddlevelsCommand extends ExperienceCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void handleCommand(SkillType skill) {
 | 
			
		||||
        profile.addLevels(skill, value);
 | 
			
		||||
 | 
			
		||||
        if (player != null) {
 | 
			
		||||
            mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.gmail.nossr50.mcMMO;
 | 
			
		||||
import com.gmail.nossr50.datatypes.skills.SkillType;
 | 
			
		||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
 | 
			
		||||
import com.gmail.nossr50.locale.LocaleLoader;
 | 
			
		||||
import com.gmail.nossr50.util.Permissions;
 | 
			
		||||
import com.gmail.nossr50.util.skills.SkillUtils;
 | 
			
		||||
@@ -21,6 +23,10 @@ public class MmoeditCommand extends ExperienceCommand {
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void handleCommand(SkillType skill) {
 | 
			
		||||
        profile.modifySkill(skill, value);
 | 
			
		||||
 | 
			
		||||
        if (player != null) {
 | 
			
		||||
            mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - profile.getSkillLevel(skill)));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -3,8 +3,10 @@ package com.gmail.nossr50.commands.experience;
 | 
			
		||||
import org.bukkit.command.Command;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
 | 
			
		||||
import com.gmail.nossr50.mcMMO;
 | 
			
		||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
 | 
			
		||||
import com.gmail.nossr50.datatypes.skills.SkillType;
 | 
			
		||||
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
 | 
			
		||||
import com.gmail.nossr50.locale.LocaleLoader;
 | 
			
		||||
import com.gmail.nossr50.util.Permissions;
 | 
			
		||||
import com.gmail.nossr50.util.commands.CommandUtils;
 | 
			
		||||
@@ -84,13 +86,11 @@ public class SkillresetCommand extends ExperienceCommand {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected boolean permissionsCheckSelf(CommandSender sender) {
 | 
			
		||||
        // TODO Auto-generated method stub
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected boolean permissionsCheckOthers(CommandSender sender) {
 | 
			
		||||
        // TODO Auto-generated method stub
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -102,6 +102,10 @@ public class SkillresetCommand extends ExperienceCommand {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        profile.modifySkill(skill, 0);
 | 
			
		||||
 | 
			
		||||
        if (player != null) {
 | 
			
		||||
            mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, 0 - profile.getSkillLevel(skill)));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
 | 
			
		||||
 | 
			
		||||
    public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) {
 | 
			
		||||
        super(player, skill);
 | 
			
		||||
        this.setLevelsGained(levelsGained);
 | 
			
		||||
        this.levelsGained = levelsGained;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user