Fix CommandPart Validator for varargs part
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
09a9d8980b
Commit
fc976acdd4
@ -92,12 +92,17 @@ class CommandPart<T> {
|
|||||||
if (varArgType != null) {
|
if (varArgType != null) {
|
||||||
Object array = Array.newInstance(varArgType, args.length - startIndex);
|
Object array = Array.newInstance(varArgType, args.length - startIndex);
|
||||||
for (int i = startIndex; i < args.length; i++) {
|
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) {
|
if (!validArgument.success) {
|
||||||
throw new CommandParseException();
|
throw new CommandParseException();
|
||||||
}
|
}
|
||||||
Array.set(array, i - startIndex, validArgument.value);
|
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);
|
current.add(array);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -195,7 +200,7 @@ class CommandPart<T> {
|
|||||||
private CheckArgumentResult checkArgument(Consumer<Runnable> errors, GuardCheckType guardCheckType, T sender, String[] args, int index) {
|
private CheckArgumentResult checkArgument(Consumer<Runnable> errors, GuardCheckType guardCheckType, T sender, String[] args, int index) {
|
||||||
try {
|
try {
|
||||||
Object value = typeMapper.map(sender, Arrays.copyOf(args, index), args[index]);
|
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) -> {
|
if (!validator.validate(sender, value, (s, objects) -> {
|
||||||
errors.accept(() -> {
|
errors.accept(() -> {
|
||||||
command.sendMessage(sender, s, objects);
|
command.sendMessage(sender, s, objects);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren