Interface ImperatConfig<S extends Source>

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

public sealed interface ImperatConfig<S extends Source> extends ProcessorRegistrar<S>, 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)
    • getParameterType

      @Nullable @Nullable ParameterType<S,?> getParameterType(Type resolvingValueType)
      Fetches ParameterType 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
    • hasParameterType

      default boolean hasParameterType(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
    • setPermissionLoader

      @Experimental void setPermissionLoader(PermissionLoader<S> assigner)
      Sets the permission assigner for every parameter
      Parameters:
      assigner - the assigner.
    • getPermissionLoader

      @Experimental @NotNull @NotNull PermissionLoader<S> getPermissionLoader()
      Returns:
      The permission loader for CommandParameter on every command.
    • setNodePermissionAssigner

      @Experimental void setNodePermissionAssigner(NodePermissionAssigner<S> assigner)
      Sets the permission assigner for CommandParameter on every command.
      Parameters:
      assigner - the assigner.
    • getPermissionAssigner

      @Experimental @NotNull @NotNull NodePermissionAssigner<S> getPermissionAssigner()
      The permission assigner for every CommandParameter
      Returns:
      the NodePermissionAssigner which is responsible for assigning permissions loaded by PermissionLoader per CommandParameter.
    • isAutoPermissionAssignMode

      @Experimental boolean isAutoPermissionAssignMode()
      Is the automatic permission assigning mode enabled? If so, the CommandTree will be using PermissionLoader to deduce the permission per CommandParameter and the NodePermissionAssigner to assign the deduced permission to a ParameterNode which is a crucial part of CommandTree
      Returns:
      Whether the automatic permission assign mode is enabled or not.
    • setAutoPermissionAssignMode

      @Experimental void setAutoPermissionAssignMode(boolean toggle)
      Toggles the auto permission assign mode.
      Parameters:
      toggle - whether to enable/disable the auto permission assign(APS) mode.
    • 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
      • Command 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:

      
       // Command 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 ParameterValueAssigner 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
    • getContextResolver

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

      @Nullable <T> @Nullable ContextResolver<S,T> getMethodParamContextResolver(@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 ContextResolver for this element
    • getContextResolver

      default <T> ContextResolver<S,T> getContextResolver(CommandParameter<S> commandParameter)
      Fetches the ContextResolver suitable for the CommandParameter
      Type Parameters:
      T - the valueType of value that will be resolved by ParameterType.resolve(ExecutionContext, CommandInputStream, String)
      Parameters:
      commandParameter - the parameter of a command's usage
      Returns:
      the context resolver for this parameter's value valueType
    • getContextResolverFactory

      @Nullable <T> @Nullable ContextResolverFactory<S,T> getContextResolverFactory(Type resolvingContextType)
      Parameters:
      resolvingContextType - the valueType the factory is registered to
      Returns:
      returns the factory for creation of ContextResolver
    • 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 Context
    • getPlaceHolder

      Optional<Placeholder<S>> 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
    • setContextFactory

      void setContextFactory(ContextFactory<S> contextFactory)
      sets the context factory ContextFactory for the contexts
      Parameters:
      contextFactory - the context factory to set
    • 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
    • getUsageVerifier

      UsageVerifier<S> getUsageVerifier()
      Returns:
      the usage verifier
    • setUsageVerifier

      void setUsageVerifier(UsageVerifier<S> usageVerifier)
      Sets the usage verifier to a new instance
      Parameters:
      usageVerifier - the usage verifier to set
    • hasSourceResolver

      default boolean hasSourceResolver(Type wrap)
    • setThrowableResolver

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

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

      void setGlobalDefaultUsage(@NotNull CommandUsage.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.
    • getDefaultAttachmentMode

      @NotNull @NotNull AttachmentMode getDefaultAttachmentMode()
      Returns:
      the default attachment mode AttachmentMode
    • setDefaultAttachmentMode

      void setDefaultAttachmentMode(AttachmentMode attachmentMode)
      Sets the default AttachmentMode
      Parameters:
      attachmentMode - the attachment mode.
    • 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