Package dev.oumaimaa.kawaiiapi.command
Class CommandManager
java.lang.Object
dev.oumaimaa.kawaiiapi.command.CommandManager
Advanced command management system for Paper plugins.
Provides reflection-based command registration with subcommand support,
tab completion, and permission handling.
Features:
- Automatic subcommand registration
- Smart tab completion
- Command caching for performance
- Error recovery and logging
- Thread-safe command storage
- Version:
- 1.0
- Author:
- KawaiiDevelopment
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder class for creating commands with a fluent API. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateCoreCommand(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull String commandName, @NotNull String commandDescription, @NotNull String commandUsage, @Nullable CommandList commandList, @NotNull Class<? extends SubCommand>... subcommands) Creates and registers a core command without aliases.static voidcreateCoreCommand(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull String commandName, @NotNull String commandDescription, @NotNull String commandUsage, @Nullable CommandList commandList, @NotNull List<String> aliases, @NotNull Class<? extends SubCommand>... subcommands) Creates and registers a core command with subcommands using modern Paper command system.static @Nullable dev.oumaimaa.kawaiiapi.command.CoreCommandgetCommand(@NotNull String commandName) Retrieves a registered core command by name.Gets all currently registered command names.static booleanisCommandRegistered(@NotNull String commandName) Checks if a command is currently registered.static booleanunregisterCommand(@NotNull String commandName) Unregisters a previously registered command.
-
Method Details
-
createCoreCommand
@SafeVarargs public static void createCoreCommand(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull @NotNull String commandName, @NotNull @NotNull String commandDescription, @NotNull @NotNull String commandUsage, @Nullable @Nullable CommandList commandList, @NotNull @NotNull List<String> aliases, @NotNull @NotNull Class<? extends SubCommand>... subcommands) Creates and registers a core command with subcommands using modern Paper command system. This method uses reflection to access the server's CommandMap for registration.- Parameters:
plugin- The plugin instance that owns this commandcommandName- The name of the command to registercommandDescription- Description of the command's functionalitycommandUsage- Usage syntax for the command (e.g., "/command") commandList- Optional custom display handler for command listingaliases- List of command aliases (can be empty)subcommands- Class references to SubCommand implementations- Throws:
IllegalStateException- if command registration fails
-
createCoreCommand
@SafeVarargs public static void createCoreCommand(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull @NotNull String commandName, @NotNull @NotNull String commandDescription, @NotNull @NotNull String commandUsage, @Nullable @Nullable CommandList commandList, @NotNull @NotNull Class<? extends SubCommand>... subcommands) Creates and registers a core command without aliases. Convenience method that calls the full registration method with an empty alias list.- Parameters:
plugin- The plugin instance that owns this commandcommandName- The name of the command to registercommandDescription- Description of the commandcommandUsage- Usage syntax for the commandcommandList- Optional custom display handlersubcommands- Class references to SubCommand implementations
-
unregisterCommand
Unregisters a previously registered command. Useful for plugin reloading or dynamic command management.- Parameters:
commandName- The name of the command to unregister- Returns:
- true if the command was found and unregistered
-
getCommand
@Nullable public static @Nullable dev.oumaimaa.kawaiiapi.command.CoreCommand getCommand(@NotNull @NotNull String commandName) Retrieves a registered core command by name.- Parameters:
commandName- The command name to look up- Returns:
- The CoreCommand instance, or null if not found
-
isCommandRegistered
Checks if a command is currently registered.- Parameters:
commandName- The command name to check- Returns:
- true if the command is registered
-
getRegisteredCommands
-