Add "legacy" wrapper

Not sure if we want this long-term or not, but we'll keep it for now
This commit is contained in:
MD 2023-06-07 01:24:27 +01:00
parent c7a271b92b
commit 6d9b04f0db

View File

@ -82,7 +82,11 @@ public abstract class EssentialsCommandNode<T> {
} }
public void execute(final RunHandler<T> runHandler) { public void execute(final RunHandler<T> runHandler) {
this.execute(runHandler, ctx -> new ArrayList<>()); this.execute(runHandler, ctx -> Collections.emptyList());
}
public void execute(final LegacyRunHandler<T> runHandler) {
this.execute(runHandler, ctx -> Collections.emptyList());
} }
public void execute(final RunHandler<T> runHandler, final List<String> tabValues) { public void execute(final RunHandler<T> runHandler, final List<String> tabValues) {
@ -225,6 +229,17 @@ public abstract class EssentialsCommandNode<T> {
void handle(WalkContext<T> ctx) throws Exception; void handle(WalkContext<T> ctx) throws Exception;
} }
// todo: not sure whether to keep or to rewrite usages
@Deprecated
public interface LegacyRunHandler<T> extends RunHandler<T> {
@Override
default void handle(WalkContext<T> ctx) throws Exception {
handle(ctx.server, ctx.sender, ctx.label, ctx.args);
}
void handle(Server server, T sender, String label, String[] args) throws Exception;
}
public interface TabHandler<T> { public interface TabHandler<T> {
List<String> handle(WalkContext<T> ctx) throws Exception; List<String> handle(WalkContext<T> ctx) throws Exception;
} }