diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/bukkit/command/FormattedCommandAlias.java | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/main/java/org/bukkit/command/FormattedCommandAlias.java b/src/main/java/org/bukkit/command/FormattedCommandAlias.java index 250f6ecf..7e5df7cd 100644 --- a/src/main/java/org/bukkit/command/FormattedCommandAlias.java +++ b/src/main/java/org/bukkit/command/FormattedCommandAlias.java @@ -91,26 +91,23 @@ public class FormattedCommandAlias extends Command { throw new IllegalArgumentException("Missing required argument " + (position + 1)); } - String replacement = null; + StringBuilder replacement = new StringBuilder(); if (rest && position < args.length) { - StringBuilder builder = new StringBuilder(); for (int i = position; i < args.length; i++) { if (i != position) { - builder.append(' '); + replacement.append(' '); } - builder.append(args[i]); + replacement.append(args[i]); } - replacement = builder.toString(); } else if (position < args.length) { - replacement = args[position]; + replacement.append(args[position]); } - if (replacement != null && replacement.length() > 0) { - formatString = formatString.substring(0, start) + replacement + formatString.substring(end); - // Move index past the replaced data so we don't process it again - index = start + replacement.length(); - } + formatString = formatString.substring(0, start) + replacement.toString() + formatString.substring(end); + // Move index past the replaced data so we don't process it again + index = start + replacement.length(); + // Move to the next replacement token index = formatString.indexOf("$", index); } |