From 11dadd7417880a5edb69060b855960130c5c1c87 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 5 Dec 2011 09:36:15 +0100 Subject: [PATCH] Simplified CommandsManager.getUsage. --- .../util/commands/CommandsManager.java | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java index 8bbdb8f3c..69b18d0e5 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java @@ -244,25 +244,18 @@ public Map getCommands() { protected String getUsage(String[] args, int level, Command cmd) { StringBuilder command = new StringBuilder(); - command.append("/"); + command.append('/'); for (int i = 0; i <= level; ++i) { - command.append(args[i] + " "); + command.append(args[i]); + command.append(' '); } if (cmd.flags().length() > 0) { - List flagChars = new ArrayList(); - char[] flags = cmd.flags().toCharArray(); - for (int i = 0; i < flags.length; ++i) { - if (flags.length > i + 1 && flags[i + 1] == ':') { - i++; - continue; - } - flagChars.add(flags[i]); - } - if (flagChars.size() > 0) { + String flags = cmd.flags().replaceAll(".:", ""); + if (flags.length() > 0) { command.append("[-"); - for (char character : flagChars) { - command.append(character); + for (int i = 0; i < flags.length(); ++i) { + command.append(flags.charAt(i)); } command.append("] "); }