Fix CommandPart Validator for varargs part
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-06-16 23:02:13 +02:00
Ursprung 09a9d8980b
Commit fc976acdd4

Datei anzeigen

@ -92,12 +92,17 @@ class CommandPart<T> {
if (varArgType != null) {
Object array = Array.newInstance(varArgType, args.length - startIndex);
for (int i = startIndex; i < args.length; i++) {
CheckArgumentResult validArgument = checkArgument(errors, null, sender, args, i);
CheckArgumentResult validArgument = checkArgument(null, null, sender, args, i);
if (!validArgument.success) {
throw new CommandParseException();
}
Array.set(array, i - startIndex, validArgument.value);
}
if (validator != null && !validator.validate(sender, array, (s, objects) -> {
errors.accept(() -> command.sendMessage(sender, s, objects));
})) {
throw new CommandParseException();
}
current.add(array);
return;
}
@ -195,7 +200,7 @@ class CommandPart<T> {
private CheckArgumentResult checkArgument(Consumer<Runnable> errors, GuardCheckType guardCheckType, T sender, String[] args, int index) {
try {
Object value = typeMapper.map(sender, Arrays.copyOf(args, index), args[index]);
if (validator != null) {
if (validator != null && errors != null) {
if (!validator.validate(sender, value, (s, objects) -> {
errors.accept(() -> {
command.sendMessage(sender, s, objects);