mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-21 05:44:17 +00:00
[Bleeding] Fix formatting of optional arguments.
This commit is contained in:
parent
b5f5619834
commit
a9bd79aa0d
1 changed files with 8 additions and 11 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue