.
Some checks failed
Build and Deploy artifact / build (push) Failing after 1m11s

This commit is contained in:
kento2 2026-08-10 00:43:37 +02:00
parent 2c058fc84c
commit 7a0e9f8b63
5 changed files with 14 additions and 16 deletions

View file

@ -27,17 +27,14 @@ public class CommandHandler<T> {
public void invoke(RootLiteral<T> rootLiteral, T sender, Stream<String> args) {
var walkResult = nodeTreeWalker.walk(rootLiteral, sender, args.iterator());
if (!walkResult.isValidUsage()) {
sendMessageMethod.send(sender, rootLiteral.messageStyle().err(walkResult.message()));
sendMessageMethod.send(sender, rootLiteral.style().err(walkResult.message()));
return;
}
requireNonNull(walkResult.lastLiteral().executor())
.execute(walkResult.ctx())
.whenComplete((result, ex) -> {
if (ex != null)
sendMessageMethod.send(sender, rootLiteral.messageStyle().exception(ex));
result.ifFailure(err ->
sendMessageMethod.send(sender, rootLiteral.messageStyle().err(err)));
.execute(rootLiteral.style(), walkResult.ctx())
.exceptionally(ex -> {
sendMessageMethod.send(sender, rootLiteral.style().exception(ex));
return null;
});
}

View file

@ -1,10 +1,10 @@
package de.kentoj.kencommandapi.api.invocation;
import com.leakyabstractions.result.api.Result;
import de.kentoj.kencommandapi.api.platform.MessageStyle;
import java.util.concurrent.CompletableFuture;
public interface CommandExecutor<T> {
CompletableFuture<Result<Object, String>> execute(CommandContext<T> ctx);
CompletableFuture<Void> execute(MessageStyle style, CommandContext<T> ctx);
}

View file

@ -1,14 +1,15 @@
package de.kentoj.kencommandapi.api.invocation;
import com.leakyabstractions.result.api.Result;
import de.kentoj.kencommandapi.api.platform.MessageStyle;
import java.util.concurrent.CompletableFuture;
public interface SyncCommandExecutor<T> extends CommandExecutor<T> {
Result<Object, String> executeSync(CommandContext<T> ctx);
void executeSync(MessageStyle style, CommandContext<T> ctx);
default CompletableFuture<Result<Object, String>> execute(CommandContext<T> ctx) {
return CompletableFuture.completedFuture(this.executeSync(ctx));
default CompletableFuture<Void> execute(MessageStyle style, CommandContext<T> ctx) {
this.executeSync(style, ctx);
return CompletableFuture.completedFuture(null);
}
}

View file

@ -4,5 +4,5 @@ import de.kentoj.kencommandapi.api.platform.MessageStyle;
public sealed interface RootLiteral<T> extends Literal<T> permits RootLiteralImpl {
MessageStyle messageStyle();
MessageStyle style();
}

View file

@ -15,7 +15,7 @@ record RootLiteralImpl<T>(
List<CommandArgumentSpec<T, ?>> arguments,
CommandExecutor<T> executor,
@Nullable String permission,
MessageStyle messageStyle
MessageStyle style
) implements RootLiteral<T> {
@Override
public @Nullable Literal<T> getLiteral(@NotNull String name) {