Package net.orbyfied.j8.command
Class Node
java.lang.Object
net.orbyfied.j8.command.Node
Represents a command node in the
command tree. Has components that
determine what it is and can do.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe aliases of this node.The children (subnodes/subcommands) of this node.The children (subnodes/subcommands) of this node mapped by name.protected final ArrayList<NodeComponent>The components stored in a linear list.protected final HashMap<Class<?>,NodeComponent> The components mapped by class.NOTE: Only subcommands will be stored here, no parameters as they have nothing to be mapped to.protected final StringThe primary name of this node.protected final NodeThe immediate parent of this node.protected NodeThe root node of this tree. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAliases(String... aliases) argument(ArgumentType<?> type) argument(ArgumentType<?> type, ArgumentOptions options) <T extends NodeComponent>
T<T extends NodeComponent>
Nodeexecutable(Consumer<Executable> consumer) executes(CommandNodeExecutor executor) executes(CommandNodeExecutor executor, CommandNodeExecutor walked) flag(String name, Character ch, ArgumentType<?> type, boolean isSwitch) flag(String name, ArgumentType<?> type) getChildByName(String name) getChildByPath(String... path) <T extends NodeComponent>
TgetComponent(Class<T> klass) <T> TgetComponentOf(Class<T> klass) Map<Class<?>,NodeComponent> getName()getOrCreateChild(String name, Function<Node, Node> constructor) booleanhasComponentOf(Class<?> klass) <T extends NodeComponent>
TmakeComponent(Function<Node, T> constructor) <T extends NodeComponent>
NodemakeComponent(Function<Node, T> constructor, Consumer<T> consumer) node()parent()permission(String perm) voidprintTreeFancy(PrintStream stream) propertied(String desc, String label, String usage) removeAlias(String... aliases) removeChild(Node node) removeComponent(Class<?> klass) removeComponent(NodeComponent component) root()setExecutor(Consumer<Context> executor) thenArgument(String name, ArgumentType<?> type) thenArgument(String name, ArgumentType<?> type, BiConsumer<Node, Argument> consumer) thenArgument(String name, ArgumentType<?> type, Consumer<Node> consumer) thenArgument(String name, ArgumentType<?> type, ArgumentOptions options) thenArgument(String name, ArgumentType<?> type, ArgumentOptions options, BiConsumer<Node, Argument> consumer) thenArgument(String name, ArgumentType<?> type, ArgumentOptions options, Consumer<Node> consumer) thenExecute(String name, Consumer<Context> executor) thenExecute(String name, CommandNodeExecutor executor) thenExecute(String name, CommandNodeExecutor executor, BiConsumer<Node, Executable> consumer) thenExecute(String name, CommandNodeExecutor executor, Consumer<Node> consumer) thenExecute(String name, CommandNodeExecutor executor, CommandNodeExecutor walked) thenExecute(String name, CommandNodeExecutor executor, CommandNodeExecutor walked, BiConsumer<Node, Executable> consumer) booleanWalks this node in a dispatch chain, this node will handle it's own behaviour and then move on to the next or terminate the chain.withAliases(String... aliases) <T extends NodeComponent>
TwithComponent(T component) <T extends NodeComponent>
NodewithComponent(T component, Consumer<T> consumer)
-
Field Details
-
components
The components stored in a linear list. -
componentsByClass
The components mapped by class. Includes all parent classes of a component which are not annotated withNonComponent -
children
The children (subnodes/subcommands) of this node. -
childrenByName
The children (subnodes/subcommands) of this node mapped by name. -
fastMappedChildren
NOTE: Only subcommands will be stored here, no parameters as they have nothing to be mapped to. -
name
The primary name of this node. -
aliases
The aliases of this node. -
parent
The immediate parent of this node. -
root
The root node of this tree.
-
-
Constructor Details
-
Node
Constructor.
-
-
Method Details
-
walk
Walks this node in a dispatch chain, this node will handle it's own behaviour and then move on to the next or terminate the chain.- Parameters:
context- The command context.last- The last node in the chain.fReader- The string reader.- Returns:
- If the chain has ended and should be back tracked further to the last executable.
-
findNext
-
node
-
getChildren
-
getFastMappedChildren
-
getComponents
-
getComponentsByClass
-
parent
-
getName
-
getAliases
-
root
-
withAliases
-
addAliases
-
removeAlias
-
makeComponent
-
makeComponent
public <T extends NodeComponent> Node makeComponent(Function<Node, T> constructor, Consumer<T> consumer) -
component
-
component
public <T extends NodeComponent> Node component(Class<T> tClass, Function<Node, T> constructor, BiConsumer<Node, T> consumer) -
withComponent
-
withComponent
-
removeComponent
-
removeComponent
-
getComponentOf
-
getComponent
-
hasComponentOf
-
addChild
-
addChild
-
removeChild
-
getChildByName
-
getChildByPath
-
getChild
-
getOrCreateChild
-
propertied
-
executable
-
executable
-
executes
-
setExecutor
-
executes
-
executes
-
argument
-
argument
-
permission
-
flag
-
flag
-
flag
-
thenArgument
-
thenArgument
-
thenArgument
-
thenArgument
-
thenArgument
public Node thenArgument(String name, ArgumentType<?> type, ArgumentOptions options, Consumer<Node> consumer) -
thenArgument
public Node thenArgument(String name, ArgumentType<?> type, ArgumentOptions options, BiConsumer<Node, Argument> consumer) -
thenExecute
-
thenExecute
-
thenExecute
-
thenExecute
-
thenExecute
public Node thenExecute(String name, CommandNodeExecutor executor, BiConsumer<Node, Executable> consumer) -
thenExecute
-
thenExecute
public Node thenExecute(String name, CommandNodeExecutor executor, CommandNodeExecutor walked, BiConsumer<Node, Executable> consumer) -
printTreeFancy
-