Fix CommandPart Validator for varargs part
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Dieser Commit ist enthalten in:
Ursprung
fc976acdd4
Commit
43728d8143
@ -72,7 +72,10 @@ public abstract class AbstractSWCommand<T> {
|
|||||||
List<Runnable> errors = new ArrayList<>();
|
List<Runnable> errors = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
if (!commandList.stream().anyMatch(s -> s.invoke(errors::add, sender, alias, args))) {
|
if (!commandList.stream().anyMatch(s -> s.invoke(errors::add, sender, alias, args))) {
|
||||||
|
if (!errors.isEmpty()) {
|
||||||
errors.forEach(Runnable::run);
|
errors.forEach(Runnable::run);
|
||||||
|
return;
|
||||||
|
}
|
||||||
commandHelpList.stream().anyMatch(s -> s.invoke((ignore) -> {}, sender, alias, args));
|
commandHelpList.stream().anyMatch(s -> s.invoke((ignore) -> {}, sender, alias, args));
|
||||||
}
|
}
|
||||||
} catch (CommandNoHelpException e) {
|
} catch (CommandNoHelpException e) {
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.command;
|
package de.steamwar.command;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
public interface AbstractTypeMapper<K, T> extends AbstractValidator<K, T> {
|
public interface AbstractTypeMapper<K, T> extends AbstractValidator<K, T> {
|
||||||
/**
|
/**
|
||||||
@ -29,7 +28,7 @@ public interface AbstractTypeMapper<K, T> extends AbstractValidator<K, T> {
|
|||||||
T map(K sender, String[] previousArguments, String s);
|
T map(K sender, String[] previousArguments, String s);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default boolean validate(K sender, T value, BiConsumer<String, Object[]> messageSender) {
|
default boolean validate(K sender, T value, MessageSender messageSender) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.command;
|
package de.steamwar.command;
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface AbstractValidator<K, T> {
|
public interface AbstractValidator<K, T> {
|
||||||
|
|
||||||
@ -32,5 +30,10 @@ public interface AbstractValidator<K, T> {
|
|||||||
* @param messageSender The message sender to send messages to the player. Never send messages directly to the player.
|
* @param messageSender The message sender to send messages to the player. Never send messages directly to the player.
|
||||||
* @return The result of the validation.
|
* @return The result of the validation.
|
||||||
*/
|
*/
|
||||||
boolean validate(K sender, T value, BiConsumer<String, Object[]> messageSender);
|
boolean validate(K sender, T value, MessageSender messageSender);
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
interface MessageSender {
|
||||||
|
void send(String s, Object... args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren