Class CommandManager<S>
java.lang.Object
io.github.projectunified.craftcommand.CommandManager<S>
- Type Parameters:
S- the type of command sender
- Direct Known Subclasses:
BukkitCommandManager,PaperCommandManager,StandaloneCommandManager
Base command manager responsible for registering argument resolvers and handling errors.
-
Constructor Summary
ConstructorsConstructorDescriptionCommandManager(ErrorHandler<S> errorHandler) Constructs a CommandManager with the specified error handler. -
Method Summary
Modifier and TypeMethodDescriptionformatMessage(String key, String defaultValue, Object... args) Formats a message template for a key with the given arguments.getCommandInfo(Object commandInstance) Gets the list of command information for the given command instance.Gets the error handler.<T> ArgumentResolver<S, T> getResolver(Class<T> type) Gets the registered argument resolver for the given class type.voidregisterExposer(Object commandInstance, CommandInfoExposer exposer) Registers a CommandInfoExposer for a command instance.voidregisterProvider(ArgumentResolverProvider<S> provider) Registers an argument resolver provider for dynamic type resolution.<T> voidregisterResolver(Class<T> type, ArgumentResolver<S, T> resolver) Registers a custom argument resolver for a specific type.voidsetErrorHandler(ErrorHandler<S> errorHandler) Sets the error handler.
-
Constructor Details
-
CommandManager
Constructs a CommandManager with the specified error handler.- Parameters:
errorHandler- the error handler
-
-
Method Details
-
formatMessage
Formats a message template for a key with the given arguments. Subclasses can override this method to translate/customize messages based on the key.- Parameters:
key- the message key (e.g. "missing-argument", "validation.min")defaultValue- the default template to useargs- the arguments to format the template with- Returns:
- the formatted message
-
registerResolver
Registers a custom argument resolver for a specific type.- Type Parameters:
T- the type of parameter- Parameters:
type- the target class typeresolver- the resolver instance
-
registerProvider
Registers an argument resolver provider for dynamic type resolution.- Parameters:
provider- the resolver provider
-
getResolver
Gets the registered argument resolver for the given class type. Supports exact match, class hierarchy (superclass/interface) match, dynamic providers, and a sender fallback.- Type Parameters:
T- the parameter type- Parameters:
type- the class type- Returns:
- the resolver
-
getErrorHandler
Gets the error handler.- Returns:
- the error handler
-
setErrorHandler
Sets the error handler.- Parameters:
errorHandler- the error handler to set
-
registerExposer
Registers a CommandInfoExposer for a command instance.- Parameters:
commandInstance- the command instanceexposer- the exposer
-
getCommandInfo
Gets the list of command information for the given command instance.- Parameters:
commandInstance- the command instance- Returns:
- the list of command information, or an empty list if not registered
-