mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Cleanup of AddXP command
This commit is contained in:
parent
c8b30b6714
commit
00e5e75092
@ -45,10 +45,16 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
modifiedPlayer = (Player) sender;
|
||||
levels = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
}
|
||||
else {
|
||||
skillName = m.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified."); //TODO: Needs more locale.
|
||||
sender.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -64,17 +70,24 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
if (modifiedPlayer != null && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
levels = Integer.valueOf(args[2]);
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
}
|
||||
else {
|
||||
skillName = m.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified for " + playerName + "."); //TODO: Use locale
|
||||
modifiedPlayer.sendMessage(ChatColor.RED + skillName + " has been modified."); //TODO: Needs more locale.
|
||||
}
|
||||
else {
|
||||
System.out.println(m.getCapitalized(skill.toString()) + " has been modified for " + playerName + "."); //TODO: Use locale
|
||||
System.out.println(skillName + " has been modified for " + playerName + "."); //TODO: Use locale
|
||||
}
|
||||
|
||||
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -10,6 +10,7 @@ import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
|
||||
@ -22,64 +23,99 @@ public class AddxpCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = null;
|
||||
Player sendingPlayer;
|
||||
Player modifiedPlayer;
|
||||
int xp;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
sendingPlayer = (Player) sender;
|
||||
|
||||
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
|
||||
sender.sendMessage("This command requires permissions."); //TODO: Needs more locale.
|
||||
if (sendingPlayer != null && !mcPermissions.getInstance().mmoedit(sendingPlayer)) {
|
||||
sendingPlayer.sendMessage(mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
if (args.length < 2) {
|
||||
// No console aliasing yet
|
||||
// System.out.println("Usage is /"+LoadProperties.addxp+" playername skillname xp");
|
||||
System.out.println("Usage is /addxp playername skillname xp");
|
||||
return true;
|
||||
} else if (args.length == 3) {
|
||||
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
int newvalue = Integer.valueOf(args[2]);
|
||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).addXPOverride(Skills.getSkillType(args[1]), newvalue);
|
||||
plugin.getServer().getPlayer(args[0]).sendMessage(ChatColor.GREEN + "Experience granted!"); //TODO: Needs more locale.
|
||||
System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + ".");
|
||||
Skills.XpCheckAll(plugin.getServer().getPlayer(args[0]));
|
||||
}
|
||||
} else {
|
||||
// No console aliasing yet
|
||||
// System.out.println("Usage is /"+LoadProperties.addxp+" playername skillname xp");
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (sender instanceof Player) {
|
||||
if (m.isInt(args[1]) && Skills.isSkill(args[0])) {
|
||||
modifiedPlayer = (Player) sender;
|
||||
xp = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
|
||||
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
}
|
||||
else {
|
||||
skillName = m.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
Skills.XpCheckAll(modifiedPlayer);
|
||||
}
|
||||
else {
|
||||
Skills.XpCheckSkill(skill, modifiedPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.out.println("Usage is /addxp playername skillname xp"); //TODO: Needs more locale.
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
|
||||
if (modifiedPlayer != null && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
xp = Integer.valueOf(args[2]);
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
|
||||
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
}
|
||||
else {
|
||||
skillName = m.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
if (!mcPermissions.getInstance().mmoedit(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified for " + playerName + "."); //TODO: Use locale
|
||||
}
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /addxp playername skillname xp"); //TODO: Needs more locale.
|
||||
return true;
|
||||
else {
|
||||
System.out.println(skillName + " has been modified for " + playerName + "."); //TODO: Use locale
|
||||
}
|
||||
if (args.length == 3) {
|
||||
if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
int newvalue = Integer.valueOf(args[2]);
|
||||
Users.getProfile(plugin.getServer().getPlayer(args[0])).addXP(Skills.getSkillType(args[1]), newvalue);
|
||||
plugin.getServer().getPlayer(args[0]).sendMessage(ChatColor.GREEN + "Experience granted!"); //TODO: Needs more locale.
|
||||
player.sendMessage(ChatColor.RED + args[1] + " has been modified."); //TODO: Needs more locale.
|
||||
Skills.XpCheckAll(plugin.getServer().getPlayer(args[0]));
|
||||
|
||||
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
Skills.XpCheckAll(modifiedPlayer);
|
||||
}
|
||||
else {
|
||||
Skills.XpCheckSkill(skill, modifiedPlayer);
|
||||
}
|
||||
} else if (args.length == 2 && m.isInt(args[1]) && Skills.isSkill(args[0])) {
|
||||
int newvalue = Integer.valueOf(args[1]);
|
||||
Users.getProfile(player).addXP(Skills.getSkillType(args[0]), newvalue);
|
||||
player.sendMessage(ChatColor.GREEN + "Experience granted!"); //TODO: Needs more locale.
|
||||
player.sendMessage(ChatColor.RED + args[0] + " has been modified."); //TODO: Needs more locale.
|
||||
Skills.XpCheckAll(plugin.getServer().getPlayer(args[0]));
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /addxp playername skillname xp"); //TODO: Needs more locale.
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage is /addxp playername skillname xp"); //TODO: Needs more locale.
|
||||
}
|
||||
else {
|
||||
System.out.println("Usage is /addxp playername skillname xp"); //TODO: Needs more locale.
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user