Skip to content

Commit f8d878e

Browse files
created custom Executor class to use when creating executors
1 parent cc2e6ce commit f8d878e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/main/java/com/datasiqn/commandcore/command/builder/CommandLink.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class CommandLink<T> {
1919
protected final Set<CommandNode<?>> children = new HashSet<>();
2020
protected final List<Requirement> requires = new ArrayList<>();
2121

22-
protected Consumer<CommandContext> executor;
22+
protected Executor executor;
2323

2424
/**
2525
* Requires the context in which the command is executed in to pass the {@code requires} check
@@ -64,7 +64,7 @@ public T then(@NotNull CommandNode<?> node) {
6464
* @param executor The executor
6565
* @return The builder, for chaining
6666
*/
67-
public T executes(@NotNull Consumer<CommandContext> executor) {
67+
public T executes(@NotNull Executor executor) {
6868
this.executor = executor;
6969
return getThis();
7070
}
@@ -82,12 +82,18 @@ public T executes(@NotNull Consumer<CommandContext> executor) {
8282
* Gets the executor
8383
* @return The executor
8484
*/
85-
public Consumer<CommandContext> getExecutor() {
85+
public Executor getExecutor() {
8686
return executor;
8787
}
8888

8989
protected abstract @NotNull T getThis();
9090

91+
/**
92+
* A function that defines a command executor
93+
* This interface is basically a shorthand for {@code Consumer<CommandContext>}
94+
*/
95+
public interface Executor extends Consumer<CommandContext> { }
96+
9197
/**
9298
* A function that defines a command requirement.
9399
* This interface is basically a shorthand for {@code Function<CommandContext, Result<None, String>>}

0 commit comments

Comments
 (0)