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
CommandTree
s. Every type of node should extend this class.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds the given string as aLabelNode
to the children of this node and returns it.addChild
(CommandNode node) Adds the givenCommandNode
to the children of this class and returns it.Returns a list of the child nodes that this node contain.Returns aCommandExecutive
to run when the console executes this node.Returns the description of this nodeReturns aCommandExecutive
to run when this node is executed by someone.Returns the parent of this node.Returns the permission that thisCommandNode
requires 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 thisCommandNode
and 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 aCommandExecutive
to run when this node is executed by someone.- Returns:
- Executive of this node.
-
getConsoleExecutive
Returns aCommandExecutive
to 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:
CommandNode
itself.
-
addChild
Adds the givenCommandNode
to the children of this class and returns it.- Parameters:
node
- New child node to add to this node.- Returns:
CommandNode
itself.
-
addChild
Adds the given string as aLabelNode
to the children of this node and returns it.- Parameters:
label
- New label node to add to this one.- Returns:
CommandNode
itself.
-
getPermission
Returns the permission that thisCommandNode
requires to run the executive of this node.- Returns:
- Permission of this node.
-
setPermission
Changes the permission of thisCommandNode
and returns it.- Parameters:
permission
- Permission that thisCommandNode
will require to run its executive.- Returns:
CommandNode
itself.
-
suggest
Provides a list that can be added to the final list of tab completion.- Parameters:
sender
- Sender that needs a tab completion. Probably aPlayer
since console doesn't need a tab completion.args
- List of the other arguments given by the sender.- Returns:
- A list for tab completion.
-