Package me.efekos.simpler.commands.node
Class CommandNode
java.lang.Object
me.efekos.simpler.commands.node.CommandNode
- Direct Known Subclasses:
ArgumentNode,LabelNode
Main class for nodes of
CommandTrees. Every type of node should extend this class.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the given string as aLabelNodeto the children of this node and returns it.addChild(CommandNode node) Adds the givenCommandNodeto the children of this class and returns it.Returns a list of the child nodes that this node contain.Returns aCommandExecutiveto run when the console executes this node.Returns the description of this nodeReturns aCommandExecutiveto run when this node is executed by someone.Returns the parent of this node.Returns the permission that thisCommandNoderequires to run the executive of this node.setConsoleExecutive(CommandExecutive consoleExecutive) Changes the console-special executive of this node.setDescription(String description) Changes the description of this node.setExecutive(CommandExecutive executive) Changes the executive of this node.setParent(CommandNode parent) Changes the parent of this node.setPermission(String permission) Changes the permission of thisCommandNodeand returns it.Provides a list that can be added to the final list of tab completion.
-
Constructor Details
-
CommandNode
Creates a newCommandNode.- Parameters:
children- Any amount of child nodes if you would like to add now. You can still add child nodes usingaddChild(CommandNode)later.
-
-
Method Details
-
getDescription
Returns the description of this node- Returns:
- Description of this node
-
setDescription
Changes the description of this node. You don't really have to set a description if this node won't have aCommandExecutive.- Parameters:
description- Description of this node.- Returns:
- Itself.
-
getChildren
Returns a list of the child nodes that this node contain.- Returns:
- Children of this node.
-
getExecutive
Returns aCommandExecutiveto run when this node is executed by someone.- Returns:
- Executive of this node.
-
getConsoleExecutive
Returns aCommandExecutiveto run when the console executes this node.- Returns:
- Console-special executive of this node.
-
setConsoleExecutive
Changes the console-special executive of this node.- Parameters:
consoleExecutive- New executive to use- Returns:
- CommandNode itself.
-
setExecutive
Changes the executive of this node.- Parameters:
executive- New executive to use.- Returns:
- CommandNode itself.
-
getParent
Returns the parent of this node.- Returns:
- Parent of this node.
-
setParent
Changes the parent of this node. Please note that parents are only used for display purposes, and does not affect the command tree in any way. It is not recommended to change the parent of any node.- Parameters:
parent- New parent of this node.- Returns:
CommandNodeitself.
-
addChild
Adds the givenCommandNodeto the children of this class and returns it.- Parameters:
node- New child node to add to this node.- Returns:
CommandNodeitself.
-
addChild
Adds the given string as aLabelNodeto the children of this node and returns it.- Parameters:
label- New label node to add to this one.- Returns:
CommandNodeitself.
-
getPermission
Returns the permission that thisCommandNoderequires to run the executive of this node.- Returns:
- Permission of this node.
-
setPermission
Changes the permission of thisCommandNodeand returns it.- Parameters:
permission- Permission that thisCommandNodewill require to run its executive.- Returns:
CommandNodeitself.
-
suggest
Provides a list that can be added to the final list of tab completion.- Parameters:
sender- Sender that needs a tab completion. Probably aPlayersince console doesn't need a tab completion.args- List of the other arguments given by the sender.- Returns:
- A list for tab completion.
-