Interface CommandTree<S extends CommandSource>
- Type Parameters:
S- the type of source that commands and nodes operate on, must extendCommandSource
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 Summary
Modifier and TypeMethodDescriptionstatic <S extends CommandSource>
CommandTree<S>create(ImperatConfig<S> imperatConfig, Command<S> command) @NotNull TreeExecutionResult<S>execute(ExecutionContext<S> context, @NotNull ArgumentInput input) Directly traverses the tree and executes the matching pathway in one step.default voidparseSubCommand(@NotNull Command<S> subCommand, String attachmentNode) voidparseSubTree(@NotNull CommandTree<S> subTree, String attachmentNode) voidparseUsage(@NotNull CommandPathway<S> usage) Parses the given command usage and updates the command tree accordingly.Queries the help system to retrieve a set of help entries that match the specified criteria.root()Gets the root command of this command tree.@NotNull LiteralCommandNode<S>rootNode()Gets the root node of this command tree.intsize()The number of nodes cached in thisCommandTree.tabComplete(@NotNull SuggestionContext<S> context) Generates tab-completion suggestions based on the current command context.
-
Method Details
-
create
static <S extends CommandSource> CommandTree<S> create(ImperatConfig<S> imperatConfig, Command<S> command) -
root
Gets the root command of this command tree.- Returns:
- the root command, never null
-
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 thisCommandTree.- Returns:
- the number of nodes representing the size of this N-ary tree
-
parseUsage
Parses the given command usage and updates the command tree accordingly.- Parameters:
usage- the command usage to parse, must not be null
-
parseSubTree
-
parseSubCommand
-
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 againstinput- 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
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
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.
-