diff --git a/src/de/steamwar/command/AbstractSWCommand.java b/src/de/steamwar/command/AbstractSWCommand.java index d9a721f..012d96a 100644 --- a/src/de/steamwar/command/AbstractSWCommand.java +++ b/src/de/steamwar/command/AbstractSWCommand.java @@ -72,7 +72,10 @@ public abstract class AbstractSWCommand { List errors = new ArrayList<>(); try { if (!commandList.stream().anyMatch(s -> s.invoke(errors::add, sender, alias, args))) { - errors.forEach(Runnable::run); + if (!errors.isEmpty()) { + errors.forEach(Runnable::run); + return; + } commandHelpList.stream().anyMatch(s -> s.invoke((ignore) -> {}, sender, alias, args)); } } catch (CommandNoHelpException e) { diff --git a/src/de/steamwar/command/AbstractTypeMapper.java b/src/de/steamwar/command/AbstractTypeMapper.java index ca8c50b..4a340d8 100644 --- a/src/de/steamwar/command/AbstractTypeMapper.java +++ b/src/de/steamwar/command/AbstractTypeMapper.java @@ -20,7 +20,6 @@ package de.steamwar.command; import java.util.Collection; -import java.util.function.BiConsumer; public interface AbstractTypeMapper extends AbstractValidator { /** @@ -29,7 +28,7 @@ public interface AbstractTypeMapper extends AbstractValidator { T map(K sender, String[] previousArguments, String s); @Override - default boolean validate(K sender, T value, BiConsumer messageSender) { + default boolean validate(K sender, T value, MessageSender messageSender) { return true; } diff --git a/src/de/steamwar/command/AbstractValidator.java b/src/de/steamwar/command/AbstractValidator.java index a12c0e4..60efd19 100644 --- a/src/de/steamwar/command/AbstractValidator.java +++ b/src/de/steamwar/command/AbstractValidator.java @@ -19,8 +19,6 @@ package de.steamwar.command; -import java.util.function.BiConsumer; - @FunctionalInterface public interface AbstractValidator { @@ -32,5 +30,10 @@ public interface AbstractValidator { * @param messageSender The message sender to send messages to the player. Never send messages directly to the player. * @return The result of the validation. */ - boolean validate(K sender, T value, BiConsumer messageSender); + boolean validate(K sender, T value, MessageSender messageSender); + + @FunctionalInterface + interface MessageSender { + void send(String s, Object... args); + } }