19
19
*/
20
20
public abstract class CommandLink <T > {
21
21
protected final Set <CommandNode <?>> children = new HashSet <>();
22
- protected final List <Function < CommandContext , Result < None , String >> > requires = new ArrayList <>();
22
+ protected final List <Require > requires = new ArrayList <>();
23
23
24
24
protected Consumer <CommandContext > executor ;
25
25
26
26
/**
27
27
* Requires the context in which the command is executed in to pass the {@code requires} check
28
- * @param requires A function that determines if a {@code CommandContext} can run the command
28
+ * @param require A function that determines if a {@code CommandContext} can run the command
29
29
* @return Itself, for chaining
30
30
*/
31
- public T requires (@ NotNull Function < CommandContext , Result < None , String >> requires ) {
32
- this .requires .add (requires );
31
+ public T requires (@ NotNull Require require ) {
32
+ this .requires .add (require );
33
33
return getThis ();
34
34
}
35
35
36
36
/**
37
37
* Requires the sender to be a {@code Player}
38
- * @see #requires(Function )
38
+ * @see #requires(Require )
39
39
* @return Itself, for chaining
40
40
*/
41
41
public T requiresPlayer () {
@@ -44,7 +44,7 @@ public T requiresPlayer() {
44
44
45
45
/**
46
46
* Requires the sender to be an {@code Entity}
47
- * @see #requires(Function )
47
+ * @see #requires(Require )
48
48
* @return Itself, for chaining
49
49
*/
50
50
public T requiresEntity () {
@@ -80,4 +80,10 @@ public Consumer<CommandContext> getExecutor() {
80
80
}
81
81
82
82
protected abstract @ NotNull T getThis ();
83
+
84
+ /**
85
+ * A function that defines a command requirement.
86
+ * This interface is basically a shorthand for {@code Function<CommandContext, Result<None, String>>}
87
+ */
88
+ public interface Require extends Function <CommandContext , Result <None , String >> { }
83
89
}
0 commit comments