2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.commands.experience;
|
|
|
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
|
2013-05-21 15:31:25 +02:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
2013-08-23 17:49:56 +02:00
|
|
|
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
|
2013-05-21 15:31:25 +02:00
|
|
|
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.util.Permissions;
|
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
public class MmoeditCommand extends ExperienceCommand {
|
2013-03-01 06:52:01 +01:00
|
|
|
@Override
|
2013-03-12 21:25:42 +01:00
|
|
|
protected boolean permissionsCheckSelf(CommandSender sender) {
|
|
|
|
return Permissions.mmoedit(sender);
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
@Override
|
|
|
|
protected boolean permissionsCheckOthers(CommandSender sender) {
|
|
|
|
return Permissions.mmoeditOthers(sender);
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
@Override
|
|
|
|
protected void handleCommand(SkillType skill) {
|
|
|
|
profile.modifySkill(skill, value);
|
2013-05-21 15:31:25 +02:00
|
|
|
|
2013-08-23 17:49:56 +02:00
|
|
|
if (player == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int skillLevel = profile.getSkillLevel(skill);
|
|
|
|
|
|
|
|
if (value > skillLevel) {
|
|
|
|
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - skillLevel));
|
|
|
|
}
|
|
|
|
else if (value < skillLevel) {
|
|
|
|
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, skillLevel - value));
|
2013-05-21 15:31:25 +02:00
|
|
|
}
|
2013-03-12 21:25:42 +01:00
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
@Override
|
|
|
|
protected void handlePlayerMessageAll() {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value));
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
@Override
|
|
|
|
protected void handlePlayerMessageSkill() {
|
2013-10-15 19:03:33 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getSkillName(), value));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|