Class AbstractCommandManager<B,S>

java.lang.Object
io.github.mqzn.commands.base.manager.AbstractCommandManager<B,S>
Type Parameters:
B - The bootstrap for the lib to work on
S - The command sender type
All Implemented Interfaces:
CommandManager<B,S>

public abstract class AbstractCommandManager<B,S> extends Object implements CommandManager<B,S>
The class responsible for handling, registering, and coordinating the execution of the available commands
See Also:
  • Field Details

    • logger

      protected final Logger logger
    • bootstrap

      protected final B bootstrap
    • argumentNumberSuggestionProcessor

      @NotNull protected final @NotNull ArgumentNumberSuggestionProcessor argumentNumberSuggestionProcessor
    • wrapper

      @NotNull protected final @NotNull SenderWrapper<S> wrapper
    • captionRegistry

      @NotNull protected final @NotNull CaptionRegistry<S> captionRegistry
    • senderProviderRegistry

      @NotNull protected final @NotNull SenderProviderRegistry<S> senderProviderRegistry
  • Constructor Details

  • Method Details

    • getBootstrap

      @NotNull public B getBootstrap()
      Description copied from interface: CommandManager
      The bootstrap for the platform on which the manager is being used on
      Specified by:
      getBootstrap in interface CommandManager<B,S>
      Returns:
      the bootstrap instance
    • typeRegistry

      @NotNull public @NotNull ArgumentTypeRegistry typeRegistry()
      Description copied from interface: CommandManager
      The argument types registry which contains all types of arguments that will be handled during execution
      Specified by:
      typeRegistry in interface CommandManager<B,S>
      Returns:
      the argument type registry
    • suggestionProviderRegistry

      @NotNull public @NotNull SuggestionProviderRegistry suggestionProviderRegistry()
      Description copied from interface: CommandManager
      The suggestion provider registry
      Specified by:
      suggestionProviderRegistry in interface CommandManager<B,S>
      Returns:
      the provider registry for suggestions per argument
      See Also:
    • exceptionHandler

      @NotNull public @NotNull CommandExceptionHandler<S> exceptionHandler()
      Description copied from interface: CommandManager
      The exception handler which handles exceptions during execution stage.
      Specified by:
      exceptionHandler in interface CommandManager<B,S>
      Returns:
      the exception handler
    • helpProvider

      @Nullable public @Nullable CommandHelpProvider helpProvider()
      Description copied from interface: CommandManager
      Fetches the command help provider during command execution of '/cmd help'
      Specified by:
      helpProvider in interface CommandManager<B,S>
      Returns:
      the sender provider registry
      See Also:
    • setHelpProvider

      public void setHelpProvider(@Nullable @Nullable CommandHelpProvider helpProvider)
      Description copied from interface: CommandManager
      Sets the help menu provider for all commands registered
      Specified by:
      setHelpProvider in interface CommandManager<B,S>
      Parameters:
      helpProvider - the new help provider
    • executeCommand

      public final <C> void executeCommand(@NotNull @NotNull Command<S> command, @NotNull S sender, @NotNull @NotNull String[] args)
      Description copied from interface: CommandManager
      Executes a command asynchronously OR synchronously using the execution coordinator CommandExecutionCoordinator<S>
      Specified by:
      executeCommand in interface CommandManager<B,S>
      Type Parameters:
      C - the type of the custom sender
      Parameters:
      command - the command to execute
      sender - the command sender
      args - the arguments used
    • findSyntax

      public io.github.mqzn.commands.base.syntax.CommandTree.TraversingResult<S> findSyntax(@NotNull @NotNull Command<S> command, @NotNull @NotNull DelegateCommandContext<S> commandContext)
      Description copied from interface: CommandManager
      Finds the most suitable syntax for the context that is being executed
      Specified by:
      findSyntax in interface CommandManager<B,S>
      Parameters:
      command - the command being executed
      commandContext - the delegate command context (context containing only raws)
      Returns:
      the traversing result of the search
    • getSenderWrapper

      @NotNull public @NotNull SenderWrapper<S> getSenderWrapper()
      Description copied from interface: CommandManager
      The wrapper for sending messages across different platforms
      Specified by:
      getSenderWrapper in interface CommandManager<B,S>
      Returns:
      the sender wrapper
    • registerCommand

      public <C extends Command<S>> void registerCommand(C command)
      Description copied from interface: CommandManager
      Registers a command in the platform
      Specified by:
      registerCommand in interface CommandManager<B,S>
      Type Parameters:
      C - the type of the command class
      Parameters:
      command - the command instance
    • unregisterCommand

      public void unregisterCommand(String name)
      Description copied from interface: CommandManager
      Unregisters the command
      Specified by:
      unregisterCommand in interface CommandManager<B,S>
      Parameters:
      name - the command to unregister
    • getCommand

      @Nullable public @Nullable Command<S> getCommand(String name)
      Description copied from interface: CommandManager
      Gets a command which is already registered
      Specified by:
      getCommand in interface CommandManager<B,S>
      Parameters:
      name - the command's name to fetch
      Returns:
      the registered command that goes by a specific name returns null if no command with that name was registered !
    • getCommands

      @NotNull public @NotNull Collection<Command<S>> getCommands()
      Description copied from interface: CommandManager
      All registered commands
      Specified by:
      getCommands in interface CommandManager<B,S>
      Returns:
      all registered commands
    • flagRegistry

      @NotNull public @NotNull FlagRegistry flagRegistry()
      Description copied from interface: CommandManager
      The registry that holds all the flags that will be handled during command execution
      Specified by:
      flagRegistry in interface CommandManager<B,S>
      Returns:
      the flags registry
      See Also:
    • captionRegistry

      @NotNull public @NotNull CaptionRegistry<S> captionRegistry()
      Description copied from interface: CommandManager
      The registry that holds all the captions that will be used during command execution
      Specified by:
      captionRegistry in interface CommandManager<B,S>
      Returns:
      the ca registry
      See Also:
    • senderProviderRegistry

      @NotNull public @NotNull SenderProviderRegistry<S> senderProviderRegistry()
      Description copied from interface: CommandManager
      The registry that holds all custom sender providers that will be used during command execution
      Specified by:
      senderProviderRegistry in interface CommandManager<B,S>
      Returns:
      the sender provider registry
      See Also:
    • suggest

      @NotNull public @NotNull List<String> suggest(Command<S> command, S sender, String[] args)
      Description copied from interface: CommandManager
      Suggests the suggestions in correspond to the args being used while tab completing and to the command arguments of course !
      Specified by:
      suggest in interface CommandManager<B,S>
      Parameters:
      command - the command being used while tab completing
      sender - the sender
      args - the args
      Returns:
      the suggestions
    • findAmbiguity

      @NotNull public @NotNull List<CommandSyntax<S>> findAmbiguity(@NotNull @NotNull Command<S> command)
      Description copied from interface: CommandManager
      Finds syntaxes that are ambigious
      Specified by:
      findAmbiguity in interface CommandManager<B,S>
      Parameters:
      command - the syntaxes provider to check upon for ambiguity
      Returns:
      the ambigious syntaxes
    • numericArgumentSuggestionProcessor

      @NotNull public @NotNull ArgumentNumberSuggestionProcessor numericArgumentSuggestionProcessor()
      Description copied from interface: CommandManager
      Numeric argument suggestion processor
      Specified by:
      numericArgumentSuggestionProcessor in interface CommandManager<B,S>
      Returns:
      the processor of numeric args suggestions
    • log

      public void log(String msg, Object... args)
      Specified by:
      log in interface CommandManager<B,S>