Interface CommandTree<S extends CommandSource>

Type Parameters:
S - the type of source that commands and nodes operate on, must extend CommandSource

public interface CommandTree<S extends CommandSource>
Represents a tree structure for commands, providing methods for parsing, matching, and tab-completion functionality within a command framework.
  • Method Details

    • create

      static <S extends CommandSource> CommandTree<S> create(ImperatConfig<S> imperatConfig, Command<S> command)
    • root

      @NotNull @NotNull Command<S> root()
      Gets the root command of this command tree.
      Returns:
      the root command, never null
    • rootNode

      @NotNull @NotNull LiteralCommandNode<S> rootNode()
      Gets the root node of this command tree.
      Returns:
      the root command node, never null
    • size

      int size()
      The number of nodes cached in this CommandTree.
      Returns:
      the number of nodes representing the size of this N-ary tree
    • parseUsage

      void parseUsage(@NotNull @NotNull CommandPathway<S> usage)
      Parses the given command usage and updates the command tree accordingly.
      Parameters:
      usage - the command usage to parse, must not be null
    • parseSubTree

      void parseSubTree(@NotNull @NotNull CommandTree<S> subTree, String attachmentNode)
    • parseSubCommand

      default void parseSubCommand(@NotNull @NotNull Command<S> subCommand, String attachmentNode)
    • execute

      @NotNull @NotNull TreeExecutionResult<S> execute(ExecutionContext<S> context, @NotNull @NotNull ArgumentInput input) throws CommandException
      Directly traverses the tree and executes the matching pathway in one step. This combines the old contextMatch + executeUsage into a single unified operation.
      Parameters:
      context - the context to execute against
      input - the argument input to traverse the tree with
      Returns:
      the result of the tree execution containing status and resolved context
      Throws:
      CommandException - if an error occurs during argument resolution or execution
    • tabComplete

      @NotNull @NotNull List<String> tabComplete(@NotNull @NotNull SuggestionContext<S> context)
      Generates tab-completion suggestions based on the current command context.
      Parameters:
      context - the suggestion context
      Returns:
      a list of tab-completion suggestions, never null
    • queryHelp

      HelpEntryList<S> queryHelp(@NotNull @NotNull HelpQuery<S> query)
      Queries the help system to retrieve a set of help entries that match the specified criteria.

      This method searches through available help entries and returns those that satisfy the conditions defined in the provided HelpQuery. The query can include filters such as search terms, categories, permissions, or other criteria depending on the implementation.

      Parameters:
      query - the help query containing search criteria and filters; must not be null
      Returns:
      a set of HelpEntry objects that match the query criteria; returns an empty set if no matches are found; never returns null
      Since:
      2.0.0
      See Also: