Make /mctop [skillname] work for localized skillnames

This commit is contained in:
GJ 2013-01-16 00:06:14 -05:00
parent 037fd890dc
commit 7fa1a8c6c7
2 changed files with 45 additions and 15 deletions

View File

@ -37,6 +37,9 @@ public class MctopCommand implements CommandExecutor {
else if (Skills.isSkill(args[0])) {
flatfileDisplay(1, args[0].toUpperCase(), sender);
}
else if (Skills.isLocalizedSkill(args[0])) {
flatfileDisplay(1, Skills.translateLocalizedSkill(args[0]).toUpperCase(), sender);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
}
@ -44,13 +47,16 @@ public class MctopCommand implements CommandExecutor {
return true;
case 2:
if (!Skills.isSkill(args[0])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (Misc.isInt(args[1])) {
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
if (Skills.isSkill(args[0])) {
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
}
else if (Skills.isLocalizedSkill(args[0])) {
flatfileDisplay(Integer.valueOf(args[1]), Skills.translateLocalizedSkill(args[0]).toUpperCase(), sender);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
}
}
else {
sender.sendMessage(usage);
@ -78,6 +84,9 @@ public class MctopCommand implements CommandExecutor {
else if (Skills.isSkill(args[0])) {
sqlDisplay(1, args[0].toLowerCase(), sender);
}
else if (Skills.isLocalizedSkill(args[0])) {
sqlDisplay(1, Skills.translateLocalizedSkill(args[0]).toLowerCase(), sender);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
}
@ -85,13 +94,16 @@ public class MctopCommand implements CommandExecutor {
return true;
case 2:
if (!Skills.isSkill(args[0])) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (Misc.isInt(args[1])) {
sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
if (Skills.isSkill(args[0])) {
sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
}
else if (Skills.isLocalizedSkill(args[0])) {
sqlDisplay(Integer.valueOf(args[1]), Skills.translateLocalizedSkill(args[0]).toLowerCase(), sender);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
}
}
else {
sender.sendMessage(usage);
@ -110,7 +122,7 @@ public class MctopCommand implements CommandExecutor {
SkillType skillType = SkillType.getSkill(skill);
String[] info = Leaderboard.retrieveInfo(skillType, page);
if (skill.equals("ALL")) {
if (skill.equalsIgnoreCase("ALL")) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {

View File

@ -13,9 +13,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.PlayerStat;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
@ -296,6 +294,26 @@ public class Skills {
return false;
}
public static boolean isLocalizedSkill(String skillName) {
for (SkillType skill : SkillType.values()) {
if (skillName.equalsIgnoreCase(LocaleLoader.getString(Misc.getCapitalized(skill.toString() + ".SkillName")))) {
return true;
}
}
return false;
}
public static String translateLocalizedSkill(String skillName) {
for (SkillType skill : SkillType.values()) {
if (skillName.equalsIgnoreCase(LocaleLoader.getString(Misc.getCapitalized(skill.toString() + ".SkillName")))) {
return skill.toString();
}
}
return null;
}
/**
* Check if the player has any combat skill permissions.
*