package com.gmail.nossr50.commands.experience; import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class AddLevelsCommand extends ExperienceCommand { public AddLevelsCommand(mcMMO pluginRef) { super(pluginRef); } @Override protected boolean permissionsCheckSelf(CommandSender sender) { return pluginRef.getPermissionTools().addlevels(sender); } @Override protected boolean permissionsCheckOthers(CommandSender sender) { return pluginRef.getPermissionTools().addlevelsOthers(sender); } @Override protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) { double xpRemoved = profile.getSkillXpLevelRaw(skill); profile.addLevels(skill, value); if (player == null) { profile.scheduleAsyncSave(); return; } pluginRef.getEventManager().tryLevelChangeEvent(player, skill, value, xpRemoved, true, XPGainReason.COMMAND); } @Override protected void handlePlayerMessageAll(Player player, int value) { player.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardAll.1", value)); } @Override protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) { player.sendMessage(pluginRef.getLocaleManager().getString("Commands.addlevels.AwardSkill.1", value, pluginRef.getSkillTools().getLocalizedSkillName(skill))); } }