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

public class CommandManager<S> extends Object
Base command manager responsible for registering argument resolvers and handling errors.
  • Constructor Details

    • CommandManager

      public CommandManager(ErrorHandler<S> errorHandler)
      Constructs a CommandManager with the specified error handler.
      Parameters:
      errorHandler - the error handler
  • Method Details

    • formatMessage

      public String formatMessage(String key, String defaultValue, Object... args)
      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 use
      args - the arguments to format the template with
      Returns:
      the formatted message
    • registerResolver

      public <T> void registerResolver(Class<T> type, ArgumentResolver<S,T> resolver)
      Registers a custom argument resolver for a specific type.
      Type Parameters:
      T - the type of parameter
      Parameters:
      type - the target class type
      resolver - the resolver instance
    • registerProvider

      public void registerProvider(ArgumentResolverProvider<S> provider)
      Registers an argument resolver provider for dynamic type resolution.
      Parameters:
      provider - the resolver provider
    • getResolver

      public <T> ArgumentResolver<S,T> getResolver(Class<T> type)
      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

      public ErrorHandler<S> getErrorHandler()
      Gets the error handler.
      Returns:
      the error handler
    • setErrorHandler

      public void setErrorHandler(ErrorHandler<S> errorHandler)
      Sets the error handler.
      Parameters:
      errorHandler - the error handler to set
    • registerExposer

      public void registerExposer(Object commandInstance, CommandInfoExposer exposer)
      Registers a CommandInfoExposer for a command instance.
      Parameters:
      commandInstance - the command instance
      exposer - the exposer
    • getCommandInfo

      public List<CommandInfo> getCommandInfo(Object commandInstance)
      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