mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Adjust how we get the usage strings for the /skillname commands
This commit is contained in:
parent
03f96daba3
commit
0de7e22408
@ -59,6 +59,8 @@ public final class CommandRegistrationHelper {
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName)));
|
||||
command.setPermission("mcmmo.commands." + commandName);
|
||||
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) {
|
||||
case ACROBATICS:
|
||||
|
@ -74,9 +74,7 @@ public abstract class SkillCommand implements CommandExecutor {
|
||||
|
||||
statsDisplay();
|
||||
|
||||
SkillGuide.grabGuidePageForSkill(skill, player, args);
|
||||
|
||||
return true;
|
||||
return SkillGuide.grabGuidePageForSkill(skill, player, args);
|
||||
}
|
||||
|
||||
protected String calculateRank(int maxLevel, int rankChangeLevel) {
|
||||
|
@ -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 capitalized = Misc.getCapitalized(skillName);
|
||||
String localized = SkillTools.localizeSkillName(skilltype);
|
||||
player.sendMessage(LocaleLoader.getString("Guides.Available", localized, localized.toLowerCase()));
|
||||
|
||||
if (args.length >= 1 && args[0].equals("?")) {
|
||||
String address = "Guides." + capitalized;
|
||||
int totalPages = SkillGuide.getTotalPageNumber(address);
|
||||
|
||||
if (args.length == 1) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
int totalPages = SkillGuide.getTotalPageNumber(address);
|
||||
|
||||
if (!Misc.isInt(args[1])) {
|
||||
player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.getInt(args[1]) > totalPages) {
|
||||
player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Misc.getInt(args[1]) <= totalPages) {
|
||||
SkillGuide.clearChat(player);
|
||||
|
||||
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...
|
||||
else if (args.length != 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Guides.Usage", localized.toLowerCase()));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user