13
0
geforkt von Mirrors/Paper

[Bleeding] Fix formatting of optional arguments.

By: t00thpick1 <t00thpick1dirko@gmail.com>
Dieser Commit ist enthalten in:
Bukkit/Spigot 2014-02-08 15:22:45 -05:00
Ursprung 04d5aec52c
Commit 2ee5a01e78

Datei anzeigen

@ -91,26 +91,23 @@ public class FormattedCommandAlias extends Command {
throw new IllegalArgumentException("Missing required argument " + (position + 1)); throw new IllegalArgumentException("Missing required argument " + (position + 1));
} }
String replacement = null; StringBuilder replacement = new StringBuilder();
if (rest && position < args.length) { if (rest && position < args.length) {
StringBuilder builder = new StringBuilder();
for (int i = position; i < args.length; i++) { for (int i = position; i < args.length; i++) {
if (i != position) { if (i != position) {
builder.append(' '); replacement.append(' ');
} }
builder.append(args[i]); replacement.append(args[i]);
} }
replacement = builder.toString();
} else if (position < args.length) { } else if (position < args.length) {
replacement = args[position]; replacement.append(args[position]);
} }
if (replacement != null && replacement.length() > 0) { formatString = formatString.substring(0, start) + replacement.toString() + formatString.substring(end);
formatString = formatString.substring(0, start) + replacement + formatString.substring(end);
// Move index past the replaced data so we don't process it again // Move index past the replaced data so we don't process it again
index = start + replacement.length(); index = start + replacement.length();
}
// Move to the next replacement token
index = formatString.indexOf("$", index); index = formatString.indexOf("$", index);
} }