User:JavaRogers/Understanding Brigadier

This page documents my attempts to analyse and understand the Brigadier system for dispatching commands.

a command context has: private final S source; private final String input; private final Command&lt;S> command; private final Map> arguments; private final CommandNode&lt;S> rootNode; private final List> nodes; private final StringRange range; private final CommandContext&lt;S> child; private final RedirectModifier&lt;S> modifier; private final boolean forks; public CommandContext(all those public variables); public CommandContext&lt;S> copyFor(final S source); public CommandContext&lt;S> getChild; public CommandContext&lt;S> getLastChild; public Command&lt;S> getCommand; public S getSource; @SuppressWarnings("unchecked") public  V getArgument(final String name, final Class clazz); @Override public boolean equals(final Object o); @Override public int hashCode; public RedirectModifier&lt;S> getRedirectModifier; public StringRange getRange; public String getInput; public CommandNode&lt;S> getRootNode; public List> getNodes; public boolean hasNodes; public boolean isForked;

I'm thinking this represents a command node (Can be  or   or  &mdash;Commands and arguments, yeah?)

* @param input a command string to parse &amp; execute * @param source a custom "source" object, usually representing the originator of this command * @return a numeric result from a "command" that was performed

See this pastebin for an excerpt from The Brigadier Git/src/main/java/com/mojang/brigadier/CommandDispatcher.java. These are two (okay, four) commands called by several other "parse then execute" commands.