Fixed syntax starting with an unspecified length argument

This commit is contained in:
Felix Cravic 2020-11-26 00:57:01 +01:00
parent 02ccb42695
commit 431d20ef73

View File

@ -121,7 +121,7 @@ public class CommandDispatcher {
for (CommandSyntax syntax : syntaxes) { for (CommandSyntax syntax : syntaxes) {
final Argument<?>[] arguments = syntax.getArguments(); final Argument<?>[] arguments = syntax.getArguments();
final String[] argsValues = new String[arguments.length]; final String[] argsValues = new String[Byte.MAX_VALUE];
boolean syntaxCorrect = true; boolean syntaxCorrect = true;
// The current index in the raw command string arguments // The current index in the raw command string arguments
@ -157,22 +157,22 @@ public class CommandDispatcher {
correctionResult = argument.getCorrectionResult(argValueString); correctionResult = argument.getCorrectionResult(argValueString);
if (correctionResult == Argument.SUCCESS) { if (correctionResult == Argument.SUCCESS) {
correct = true; correct = true;
argsValues[argIndex] = argValueString; argsValues[argCount] = argValueString;
} }
} }
} else { } else {
// Argument is either single-word or can accept optional delimited space(s) // Argument is either single-word or can accept optional delimited space(s)
for (int i = argIndex; i < args.length; i++) { for (int i = argIndex; i < args.length; i++) {
final String arg = args[i]; final String rawArg = args[i];
argValue.append(arg); argValue.append(rawArg);
final String argValueString = argValue.toString(); final String argValueString = argValue.toString();
correctionResult = argument.getCorrectionResult(argValueString); correctionResult = argument.getCorrectionResult(argValueString);
if (correctionResult == Argument.SUCCESS) { if (correctionResult == Argument.SUCCESS) {
correct = true; correct = true;
argsValues[argIndex] = argValueString; argsValues[argCount] = argValueString;
argIndex = i + 1; argIndex = i + 1;
break; break;
} else { } else {