Make /quests top argument optional, fixes #614

This commit is contained in:
BuildTools 2019-01-02 18:31:24 -05:00
parent 90511df08f
commit 6abe86ddd7

View File

@ -320,7 +320,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
commands.put(Lang.get("COMMAND_EDITOR"), 1); // editor commands.put(Lang.get("COMMAND_EDITOR"), 1); // editor
commands.put(Lang.get("COMMAND_EVENTS_EDITOR"), 1); // events commands.put(Lang.get("COMMAND_EVENTS_EDITOR"), 1); // events
commands.put(Lang.get("COMMAND_STATS"), 1); // stats commands.put(Lang.get("COMMAND_STATS"), 1); // stats
commands.put(Lang.get("COMMAND_TOP"), 2); // top [number] commands.put(Lang.get("COMMAND_TOP"), 2); // top {number}
commands.put(Lang.get("COMMAND_INFO"), 1); // info commands.put(Lang.get("COMMAND_INFO"), 1); // info
commands.put(Lang.get("COMMAND_JOURNAL"), 1); // journal commands.put(Lang.get("COMMAND_JOURNAL"), 1); // journal
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_STATS"), 2); // stats [player] adminCommands.put(Lang.get("COMMAND_QUESTADMIN_STATS"), 2); // stats [player]
@ -1378,16 +1378,20 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
private boolean questsTop(final CommandSender cs, String[] args) { private boolean questsTop(final CommandSender cs, String[] args) {
if (args.length == 1 || args.length > 2) { if (args.length > 2) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_TOP_USAGE")); cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_TOP_USAGE"));
} else { } else {
int topNumber; int topNumber;
if (args.length == 1) {
topNumber = 5; // default
} else {
try { try {
topNumber = Integer.parseInt(args[1]); topNumber = Integer.parseInt(args[1]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum")); cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
return true; return true;
} }
}
if (topNumber < 1) { if (topNumber < 1) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputPosNum")); cs.sendMessage(ChatColor.YELLOW + Lang.get("inputPosNum"));
return true; return true;