Interface CommandTree<S extends Source>
- Type Parameters:
S- the type of source that commands and nodes operate on, must extendSource
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 Summary
Modifier and TypeMethodDescriptionvoidCompute Permissions in APA(AutoPermissionAssign) mode This is a method that shall take some considerable amount of resources whenever an instance ofCommandis created using itsCommand.Builder.@NotNull CommandPathSearch<S>contextMatch(Context<S> context, @NotNull ArgumentInput input) Matches the given input against this command tree and returns a dispatch context.static <S extends Source>
CommandTree<S>create(ImperatConfig<S> imperatConfig, Command<S> command) @Nullable StringgetAutoAssignedPermission(@NotNull CommandParameter<S> commandParameter) This should fetch the command parameter's assigned permission.Set<CommandUsage<S>>getClosestUsages(Context<S> context) Collects the closest usages to a context, this traverses the wholeCommandTreefrom the beginning , visiting every branch/chain possible.static <S extends Source>
CommandTree<S>parsed(ImperatConfig<S> imperatConfig, Command<S> command) voidparseUsage(@NotNull CommandUsage<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 CommandNode<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.intThe size of the unique versioned tree@NotNull CommandNode<S>Gets the unique versioned tree.
-
Method Details
-
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
-
uniqueVersionedTree
Gets the unique versioned tree.- Returns:
- the unique versioned tree.
-
size
int size()The number of nodes cached in thisCommandTree.- 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
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 ofCommandis created using itsCommand.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 againstinput- the argument input to match against- Returns:
- a command dispatch context containing matching results, never null
-
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. -
getClosestUsages
Collects the closest usages to a context, this traverses the wholeCommandTreefrom 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
-
parsed
-