2012-01-09 20:00:13 +01:00
|
|
|
package com.gmail.nossr50.commands.general;
|
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
2012-04-04 16:34:35 +02:00
|
|
|
import org.bukkit.OfflinePlayer;
|
2012-01-09 20:00:13 +01:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.Users;
|
|
|
|
import com.gmail.nossr50.m;
|
2012-04-04 16:34:35 +02:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import com.gmail.nossr50.commands.CommandHelper;
|
2012-01-09 20:00:13 +01:00
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
2012-04-04 16:34:35 +02:00
|
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
2012-01-09 20:00:13 +01:00
|
|
|
import com.gmail.nossr50.locale.mcLocale;
|
|
|
|
import com.gmail.nossr50.skills.Skills;
|
|
|
|
|
|
|
|
public class MmoeditCommand implements CommandExecutor {
|
2012-04-04 16:34:35 +02:00
|
|
|
private final mcMMO plugin;
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-04-04 16:34:35 +02:00
|
|
|
public MmoeditCommand(mcMMO instance) {
|
|
|
|
this.plugin = instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
OfflinePlayer modifiedPlayer;
|
|
|
|
PlayerProfile PP;
|
|
|
|
int newValue;
|
|
|
|
SkillType skill;
|
|
|
|
String skillName;
|
2012-04-19 05:34:46 +02:00
|
|
|
String usage = ChatColor.RED + "Proper usage is /mmoedit [player] <skill> <level>"; //TODO: Needs more locale.
|
2012-04-04 16:34:35 +02:00
|
|
|
|
|
|
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
|
|
|
|
return true;
|
2012-02-11 15:01:46 +01:00
|
|
|
}
|
2012-04-04 16:34:35 +02:00
|
|
|
|
|
|
|
switch (args.length) {
|
|
|
|
case 2:
|
|
|
|
if (sender instanceof Player) {
|
|
|
|
if (m.isInt(args[1]) && Skills.isSkill(args[0])) {
|
|
|
|
modifiedPlayer = (Player) sender;
|
|
|
|
newValue = Integer.valueOf(args[1]);
|
|
|
|
skill = Skills.getSkillType(args[0]);
|
|
|
|
PP = Users.getProfile(modifiedPlayer);
|
|
|
|
|
|
|
|
if (skill.equals(SkillType.ALL)) {
|
|
|
|
skillName = "all skills";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
skillName = m.getCapitalized(skill.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
PP.modifySkill(skill, newValue);
|
|
|
|
sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
|
|
|
}
|
|
|
|
}
|
2012-04-04 22:12:13 +02:00
|
|
|
else {
|
|
|
|
sender.sendMessage(usage);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2012-04-04 16:34:35 +02:00
|
|
|
|
|
|
|
case 3:
|
|
|
|
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
|
|
|
String playerName = modifiedPlayer.getName();
|
|
|
|
PP = Users.getProfile(modifiedPlayer);
|
|
|
|
|
|
|
|
if (!PP.isLoaded()) {
|
|
|
|
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
|
|
|
|
return true;
|
2012-03-22 21:42:44 +01:00
|
|
|
}
|
2012-04-04 16:34:35 +02:00
|
|
|
|
|
|
|
if (m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
|
|
|
newValue = Integer.valueOf(args[2]);
|
|
|
|
skill = Skills.getSkillType(args[1]);
|
|
|
|
String message;
|
|
|
|
|
|
|
|
Users.getProfile(modifiedPlayer).modifySkill(skill, newValue);
|
|
|
|
|
|
|
|
if (skill.equals(SkillType.ALL)) {
|
|
|
|
skillName = "all skills";
|
|
|
|
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
skillName = m.getCapitalized(skill.toString());
|
|
|
|
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
|
|
|
|
}
|
|
|
|
|
|
|
|
sender.sendMessage(message);
|
|
|
|
|
|
|
|
if (modifiedPlayer.isOnline()) {
|
|
|
|
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
|
|
|
}
|
|
|
|
}
|
2012-04-04 22:12:13 +02:00
|
|
|
else {
|
|
|
|
sender.sendMessage(usage);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2012-04-04 16:34:35 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
sender.sendMessage(usage);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|