Adjust how we get the usage strings for the /skillname commands

This commit is contained in:
GJ 2013-02-05 08:50:47 -05:00
parent 03f96daba3
commit 0de7e22408
3 changed files with 41 additions and 30 deletions

View File

@ -59,6 +59,8 @@ public final class CommandRegistrationHelper {
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName))); command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName)));
command.setPermission("mcmmo.commands." + commandName); command.setPermission("mcmmo.commands." + commandName);
command.setPermissionMessage(permissionsMessage); command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", localizedName));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.2", localizedName, "?", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"));
switch (skill) { switch (skill) {
case ACROBATICS: case ACROBATICS:

View File

@ -74,9 +74,7 @@ public abstract class SkillCommand implements CommandExecutor {
statsDisplay(); statsDisplay();
SkillGuide.grabGuidePageForSkill(skill, player, args); return SkillGuide.grabGuidePageForSkill(skill, player, args);
return true;
} }
protected String calculateRank(int maxLevel, int rankChangeLevel) { protected String calculateRank(int maxLevel, int rankChangeLevel) {

View File

@ -55,44 +55,55 @@ public final class SkillGuide {
} }
} }
public static void grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) { public static boolean grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) {
String skillName = skilltype.toString(); String skillName = skilltype.toString();
String capitalized = Misc.getCapitalized(skillName); String capitalized = Misc.getCapitalized(skillName);
String localized = SkillTools.localizeSkillName(skilltype); String localized = SkillTools.localizeSkillName(skilltype);
player.sendMessage(LocaleLoader.getString("Guides.Available", localized, localized.toLowerCase())); player.sendMessage(LocaleLoader.getString("Guides.Available", localized, localized.toLowerCase()));
if (args.length >= 1 && args[0].equals("?")) { String address = "Guides." + capitalized;
String address = "Guides." + capitalized;
switch (args.length) {
case 0:
// We have to specify this, otherwise we get the usage string every time we call /skillname...
return true;
case 1:
if (!args[0].equals("?")) {
return false;
}
SkillGuide.clearChat(player);
for (String target : SkillGuide.grabPageContents(localized, address, 1)) {
player.sendMessage(target);
}
return true;
case 2:
int totalPages = SkillGuide.getTotalPageNumber(address); int totalPages = SkillGuide.getTotalPageNumber(address);
if (args.length == 1) { if (!Misc.isInt(args[1])) {
SkillGuide.clearChat(player); player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid"));
return true;
for (String target : SkillGuide.grabPageContents(localized, address, 1)) {
player.sendMessage(target);
}
} }
else {
if (!Misc.isInt(args[1])) {
player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid"));
}
if (Misc.getInt(args[1]) <= totalPages) { if (Misc.getInt(args[1]) > totalPages) {
SkillGuide.clearChat(player); player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages));
return true;
for (String target : SkillGuide.grabPageContents(localized, address, Misc.getInt(args[1]))) {
player.sendMessage(target);
}
}
else {
player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages));
}
} }
}
// We have to specify this, else we get the usage string every time we call /skillname... SkillGuide.clearChat(player);
else if (args.length != 0) {
player.sendMessage(LocaleLoader.getString("Guides.Usage", localized.toLowerCase())); for (String target : SkillGuide.grabPageContents(localized, address, Misc.getInt(args[1]))) {
player.sendMessage(target);
}
return true;
default:
return false;
} }
} }
} }