currently refactoring a lot.

This commit is contained in:
kento2 2026-07-04 01:04:01 +02:00
parent fe0b04c7d1
commit 9aa138058c
32 changed files with 484 additions and 254 deletions

View file

@ -2,8 +2,9 @@ package de.kentoj.kencommandapi;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.ProxyServer;
import de.kentoj.kencommandapi.api.CommandNode;
import de.kentoj.kencommandapi.internal.parser.CommandParser;
import de.kentoj.kencommandapi.api.CommandHandler;
import de.kentoj.kencommandapi.api.node.RootCommandNode;
import de.kentoj.kencommandapi.api.parser.CommandParser;
import lombok.RequiredArgsConstructor;
import java.util.Arrays;
@ -12,13 +13,17 @@ import java.util.Arrays;
public class CommandAPI {
private final ProxyServer server;
private final CommandParser<CommandSource> commandParser = new CommandParser<>(CommandSource::hasPermission);
private final CommandHandler<CommandSource> commandHandler = new CommandHandler<>(
new CommandParser<>(CommandSource::hasPermission),
CommandSource::sendMessage,
CommandSource::hasPermission
);
public void register(CommandNode<CommandSource> rootNode) {
public void register(RootCommandNode<CommandSource> rootNode) {
var cm = server.getCommandManager();
var meta = cm.metaBuilder(rootNode.getNames()[0])
.aliases(Arrays.copyOfRange(rootNode.getNames(), 1, rootNode.getNames().length - 1))
.build();
cm.register(meta, new VelocityCommand(commandParser, rootNode));
cm.register(meta, new VelocityCommand(commandHandler, rootNode));
}
}