Interface ImperatConfig<S extends CommandSource>

Type Parameters:
S - The type of the source object used by the configuration, which implements the CommandSource interface.
All Superinterfaces:
BaseThrowableHandler<S>, ResolverRegistrar<S>, ThrowableHandler<S>

public sealed interface ImperatConfig<S extends CommandSource> extends ResolverRegistrar<S>, BaseThrowableHandler<S>
The ImperatConfig interface defines the core configuration and interaction points for a command processing system. It provides methods for registering handlers, resolving dependencies, and managing the execution context. This interface enables integration of custom resolvers, context factories, permission management, and placeholder handling.

Implementations of this interface are responsible for providing these required functionalities and may enforce strict validation and processing rules based on the specified configurations.

  • Method Details

    • commandPrefix

      String commandPrefix()
      Returns:
      The command prefix
    • setCommandPrefix

      void setCommandPrefix(String cmdPrefix)
    • getThrowablePrinter

      @NotNull @NotNull ThrowablePrinter getThrowablePrinter()
      Returns:
      the printer used for unhandled throwables
    • setThrowablePrinter

      void setThrowablePrinter(@NotNull @NotNull ThrowablePrinter printer)
      Sets the printer used for unhandled throwables.
      Parameters:
      printer - the throwable printer to use
    • getArgumentType

      @Nullable @Nullable ArgumentType<S,?> getArgumentType(Type resolvingValueType)
      Fetches ArgumentType for a certain value
      Parameters:
      resolvingValueType - the value that the resolver ends providing it from the context
      Returns:
      the value resolver of a certain valueType
    • hasArgumentType

      default boolean hasArgumentType(Type type)
    • registerAnnotationReplacer

      <A extends Annotation> void registerAnnotationReplacer(Class<A> type, AnnotationReplacer<A> replacer)
      Registers annotation replacer
      Type Parameters:
      A - the type of annotation to replace by the AnnotationReplacer
      Parameters:
      type - the type of annotation to register
      replacer - the replacer for this annotation
    • applyAnnotationReplacers

      @Internal <A extends Annotation> void applyAnnotationReplacers(Imperat<S> imperat)
      Apply annotation replacers.
      Type Parameters:
      A - A type variable used internally
      Parameters:
      imperat - the imperat instance
    • isOptionalParameterSuggestionOverlappingEnabled

      boolean isOptionalParameterSuggestionOverlappingEnabled()
      Determines whether multiple optional parameters can be suggested simultaneously during tab completion at the same command depth level.

      When enabled (true), all available optional parameters will be included in tab completion suggestions, allowing users to see all possible optional arguments they can provide at the current position.

      When disabled (false), only the first optional parameter (typically based on priority or registration order) will be suggested, preventing overwhelming users with too many optional choices and reducing ambiguity in command completion.

      This setting does not affect:

      • Required parameters - they are always suggested
      • RootCommand structure - the actual command tree remains unchanged
      • Parameter validation - all parameters remain functionally available
      Returns:
      true if multiple optional parameters can overlap in suggestions, false if only one optional parameter should be suggested at a time
      See Also:
    • setOptionalParameterSuggestionOverlap

      void setOptionalParameterSuggestionOverlap(boolean enabled)
      Sets whether multiple optional parameters can be suggested simultaneously during tab completion at the same command depth level.

      This is a configuration setting that affects the behavior of tab completion suggestions without modifying the underlying command structure. The command tree and parameter validation remain unchanged regardless of this setting.

      Examples:

      
       // RootCommand structure: /command [count] [extra]
       //                              \[extra]
      
       // When enabled (true):
       /command <TAB> → shows: [count], [extra]
      
       // When disabled (false):
       /command <TAB> → shows: [count] (first optional only)
       
      Parameters:
      enabled - true to allow multiple optional parameter suggestions, false to limit to one optional parameter suggestion
      See Also:
    • handleExecutionMiddleOptionalSkipping

      boolean handleExecutionMiddleOptionalSkipping()

      Whether to handle the skipping of consecutive optional argument during execution For example if you have `/test [a] [b]` where parameter 'a' is of type String and parameter 'b' is of type Integer. if you enter `/test 1` while this option is enabled, it would handle this and assign the parameter 'b' to the value that suits its type. with no respect for the order of optional arguments.

      Else if the option is disabled, then Imperat's OptionalArgumentHandler will respect the order of the optional arguments, and will resolve the arguments in order.

      Returns:
      Whether to handle the skipping of consecutive optional argument DURING EXECUTION.
    • setHandleExecutionConsecutiveOptionalArgumentsSkip

      void setHandleExecutionConsecutiveOptionalArgumentsSkip(boolean toggle)
      Refer to handleExecutionMiddleOptionalSkipping() to know about this option.
      Parameters:
      toggle - whether to toggle the handling of middle optional skipping
    • hasContextResolver

      boolean hasContextResolver(Type type)
      Checks whether the valueType has a registered context-resolver
      Parameters:
      type - the valueType
      Returns:
      whether the valueType has a context-resolver
    • getContextArgumentProvider

      @Nullable <T> @Nullable ContextArgumentProvider<S,T> getContextArgumentProvider(Type resolvingContextType)
      Fetches ContextArgumentProvider for a certain valueType
      Type Parameters:
      T - the valueType of class
      Parameters:
      resolvingContextType - the valueType for this resolver
      Returns:
      the context resolver
    • getContextArgumentProviderFor

      @Nullable <T> @Nullable ContextArgumentProvider<S,T> getContextArgumentProviderFor(@NotNull @NotNull ParameterElement element)
      Fetches the context resolver for ParameterElement of a method
      Type Parameters:
      T - the valueType of value this parameter should be resolved into
      Parameters:
      element - the element
      Returns:
      the ContextArgumentProvider for this element
    • getContextArgumentProvider

      default <T> ContextArgumentProvider<S,T> getContextArgumentProvider(Argument<S> Argument)
      Fetches the ContextArgumentProvider suitable for the Argument
      Type Parameters:
      T - the valueType of value that will be resolved by ArgumentType.parse(CommandContext, Argument, String) OR ArgumentType.parse(ExecutionContext, Cursor) during execution
      Parameters:
      Argument - the parameter of a command's usage
      Returns:
      the context resolver for this parameter's value valueType
    • getContextArgumentProviderFactory

      @Nullable <T> @Nullable ContextArgumentProviderFactory<S,T> getContextArgumentProviderFactory(Type resolvingContextType)
      Parameters:
      resolvingContextType - the valueType the factory is registered to
      Returns:
      returns the factory for creation of ContextArgumentProvider
    • getPermissionChecker

      PermissionChecker<S> getPermissionChecker()
      Returns:
      PermissionChecker for the dispatcher
    • setPermissionResolver

      void setPermissionResolver(PermissionChecker<S> permissionChecker)
      Sets the permission resolver for the platform
      Parameters:
      permissionChecker - the permission resolver to set
    • getContextFactory

      ContextFactory<S> getContextFactory()
      Returns:
      the factory for creation of command related contexts CommandContext
    • setContextFactory

      void setContextFactory(ContextFactory<S> contextFactory)
      sets the context factory ContextFactory for the contexts
      Parameters:
      contextFactory - the context factory to set
    • getPlaceHolder

      Optional<Placeholder> getPlaceHolder(String id)
      The id/format of this placeholder, must be unique and lowercase
      Parameters:
      id - the id for the placeholder
      Returns:
      the placeholder
    • replacePlaceholders

      @NotNull @NotNull String replacePlaceholders(String input)
      Replaces the placeholders of input by their PlaceholderResolver
      Parameters:
      input - the input
      Returns:
      the processed/replaced text input.
    • replacePlaceholders

      @NotNull @NotNull String[] replacePlaceholders(String[] array)
      Replaces the placeholders on each string of the array, modifying the input array content.
      Parameters:
      array - the array to replace its string contents
      Returns:
      The placeholder replaced String array
    • registerDependencyResolver

      void registerDependencyResolver(Type type, DependencySupplier resolver)
      Registers the dependency to the type
      Parameters:
      type - the type for the dependency
      resolver - the resolver
    • resolveDependency

      @Nullable <T> T resolveDependency(Type type)
      Resolves dependency of certain type
      Parameters:
      type - the type
    • hasSourceResolver

      default boolean hasSourceResolver(Type wrap)
    • setErrorHandler

      <T extends Throwable> void setErrorHandler(Class<T> exception, CommandExceptionHandler<T,S> handler)
      Registers a new CommandExceptionHandler for the specified valueType of throwable. This allows customizing the handling of specific throwable types within the application.
      Specified by:
      setErrorHandler in interface ThrowableHandler<S extends CommandSource>
      Type Parameters:
      T - The valueType of the throwable.
      Parameters:
      exception - The class of the throwable to set the resolver for.
      handler - The CommandExceptionHandler to be registered for the specified throwable valueType.
      See Also:
    • getGlobalDefaultPathway

      @NotNull CommandPathway.Builder<S> getGlobalDefaultPathway()
      Returns:
      The global/centralized default usage of EVERY command its empty by default.
    • setGlobalDefaultPathway

      void setGlobalDefaultPathway(@NotNull CommandPathway.Builder<S> globalDefaultUsage)
      Sets the usual default usage if the user doesn't set the default-usage for a Command
      Parameters:
      globalDefaultUsage - the global default usage BUILDER.
    • getHelpCoordinator

      @NotNull @NotNull HelpCoordinator<S> getHelpCoordinator()
      Returns:
      the help coordinator that coordinates how a help is being shown and displayed to the source.
    • setHelpCoordinator

      void setHelpCoordinator(@NotNull @NotNull HelpCoordinator<S> coordinator)
      Sets the coordinator for displaying of a help.
      Parameters:
      coordinator - the new coordinator to set.
    • getInstanceFactory

      InstanceFactory<S> getInstanceFactory()
      The factory for creating instances of types to be dependency injected.
      Returns:
      the instance factory
    • setInstanceFactory

      void setInstanceFactory(InstanceFactory<S> factory)
      Sets the instance factory for creating instances of types to be dependency injected.
      Parameters:
      factory - the instance factory to set
    • getGlobalCommandCoordinator

      CommandCoordinator<S> getGlobalCommandCoordinator()
      Returns:
      the default global command coordinator
    • setGlobalCommandCoordinator

      void setGlobalCommandCoordinator(CommandCoordinator<S> commandCoordinator)
    • setCoroutineScope

      void setCoroutineScope(@NotNull @NotNull Object scope)
    • getCoroutineScope

      @Nullable @Nullable Object getCoroutineScope()
    • hasCoroutineScope

      boolean hasCoroutineScope()
    • setCommandParsingMode

      ImperatConfig<S> setCommandParsingMode(CommandParsingMode mode)
    • getCommandParsingMode

      CommandParsingMode getCommandParsingMode()
    • getEventBus

      EventBus getEventBus()
    • setEventBus

      void setEventBus(EventBus eventBus)