This commit is contained in:
kento2 2026-06-29 18:49:42 +02:00
parent 254af80fde
commit 72f7625b19
53 changed files with 679 additions and 756 deletions

View file

@ -0,0 +1,27 @@
package de.kentoj.kencommandapi;
import de.kentoj.kencommandapi.api.CommandNode;
import de.kentoj.kencommandapi.internal.parser.CommandParser;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.permissions.Permissible;
import java.lang.reflect.Field;
public class CommandAPI {
private final CommandParser<CommandSender> commandParser = new CommandParser<>(Permissible::hasPermission);
public void register(CommandNode<CommandSender> rootNode) {
SimpleCommandMap commandMap;
try {
Field field = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
field.setAccessible(true);
commandMap = (SimpleCommandMap) field.get(Bukkit.getPluginManager());
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new IllegalStateException("failed registering command ", e);
}
commandMap.register(rootNode.getNames()[0], new BukkitKenCommand(commandParser, rootNode));
}
}