Interface Condition<T extends PermissionHolder,​U extends PermissionHolder>

Type Parameters:
T - the input holder type
U - the outputted holder type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Condition<T extends PermissionHolder,​U extends PermissionHolder>
A condition that must be satisfied in order for a command to run.

Conditions are transformative - they have an input and an output type. For example, isPlayer() accepts a PermissionHolder and outputs a SquirtgunPlayer, this means that a CommandNode of type SquirtgunPlayer can be chained after one of type PermissionHolder. If the condition is not met, then a message is displayed.

  • Method Details

    • isPlayer

      A condition ensuring the target is a SquirtgunPlayer.
    • isConsole

      A condition ensuring the target is the console.
    • alwaysTrue

      static <V extends PermissionHolder> Condition<V,​V> alwaysTrue()
      A condition that will always pass, carrying out no casting.
    • hasPermission

      static <V extends PermissionHolder> Condition<V,​V> hasPermission(String permission)
      A condition that checks for a permission.
    • test

      Condition.Result<U> test(T target, CommandContext context)
      Test the condition.
      Parameters:
      target - the target to test against
      context - the command context
      Returns:
      a Condition.Result<U extends PermissionHolder> that has a non-null result when successful, and a non-null error when not
    • and

      default <V extends U> Condition<T,​V> and(Condition<? super U,​V> other)
      Combines two conditions with the same output type and a contravariant input type in such a way that the test passes when both tests are successful.
      Parameters:
      other - the second test
      Returns:
      a condition that passes when both conditions pass
    • or

      default Condition<T,​U> or(Condition<? super T,​? extends U> other)
      Combines two conditions with the same output type and a contravariant input type in such a way that the test passes when either or both tests are successful.
      Parameters:
      other - the second test
      Returns:
      a condition that passes when either or both conditions pass