Interface Condition<T extends PermissionHolder,U extends PermissionHolder>
- Type Parameters:
T- the input holder typeU- 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.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <V extends PermissionHolder>
Condition<V,V>A condition that will always pass, carrying out no casting.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.static <V extends PermissionHolder>
Condition<V,V>hasPermission(String permission)A condition that checks for a permission.static Condition<PermissionHolder,PermissionHolder>A condition ensuring the target is the console.static Condition<PermissionHolder,SquirtgunPlayer>isPlayer()A condition ensuring the target is aSquirtgunPlayer.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.test(T target, CommandContext context)Test the condition.
-
Method Details
-
isPlayer
A condition ensuring the target is aSquirtgunPlayer. -
isConsole
A condition ensuring the target is the console. -
alwaysTrue
A condition that will always pass, carrying out no casting. -
hasPermission
A condition that checks for a permission. -
test
Test the condition.- Parameters:
target- the target to test againstcontext- 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
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
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
-