Interface CommandTree<S extends Source>

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

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

    • root

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

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

      @NotNull @NotNull CommandNode<S> uniqueVersionedTree()
      Gets the unique versioned tree.
      Returns:
      the unique versioned tree.
    • size

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

      int uniqueSize()
      The size of the unique versioned tree
      Returns:
      The size of the unique versioned tree.
      See Also:
    • parseUsage

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

      void computePermissions()
      Compute Permissions in APA(AutoPermissionAssign) mode This is a method that shall take some considerable amount of resources whenever an instance of Command is created using its Command.Builder.
    • getAutoAssignedPermission

      @Nullable @Nullable String getAutoAssignedPermission(@NotNull @NotNull CommandParameter<S> commandParameter)
      This should fetch the command parameter's assigned permission. Use this method when necessary only.
      Parameters:
      commandParameter - the parameter
      Returns:
      the permission that was auto assigned for it.
      Throws:
      IllegalStateException - when the APA(AutoPermissionAssign) mode is NOT enabled.
    • contextMatch

      @NotNull @NotNull CommandPathSearch<S> contextMatch(Context<S> context, @NotNull @NotNull ArgumentInput input)
      Matches the given input against this command tree and returns a dispatch context.
      Parameters:
      context - The context to match against
      input - the argument input to match against
      Returns:
      a command dispatch context containing matching results, never null
    • 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:
    • getClosestUsages

      Set<CommandUsage<S>> getClosestUsages(Context<S> context)
      Collects the closest usages to a context, this traverses the whole CommandTree from the beginning , visiting every branch/chain possible. This will lead to collecting the closest usages in-order by how close they are to your input.
      Parameters:
      context - the context containing the details of an input.
      Returns:
      A set of the closest usages to a Context
    • create

      static <S extends Source> CommandTree<S> create(ImperatConfig<S> imperatConfig, Command<S> command)
    • parsed

      static <S extends Source> CommandTree<S> parsed(ImperatConfig<S> imperatConfig, Command<S> command)