Fixed Argument#useRemaining creating an empty array

This commit is contained in:
themode 2020-11-03 23:31:26 +01:00
parent b575d6df57
commit b84bcde84d

View File

@ -110,6 +110,7 @@ public class CommandDispatcher {
final String[] argsValues = new String[arguments.length];
boolean syntaxCorrect = true;
// The current index in the raw command string arguments
int argIndex = 0;
boolean useRemaining = false;
@ -126,6 +127,9 @@ public class CommandDispatcher {
StringBuilder argValue = new StringBuilder();
if (useRemaining) {
final boolean hasArgs = args.length > argIndex;
// Verify if there is any string part available
if (hasArgs) {
// Argument is supposed to take the rest of the command input
for (int i = argIndex; i < args.length; i++) {
final String arg = args[i];
@ -141,6 +145,7 @@ public class CommandDispatcher {
correct = true;
argsValues[argIndex] = argValueString;
}
}
} else {
// Argument is either single-word or can accept optional delimited space(s)
for (int i = argIndex; i < args.length; i++) {