CommandManager
com.jsmacrosce.jsmacros.client.api.classes.inventory.CommandManager
Provides access to the client's command tree, command builders, and command autocomplete.
Obtain the shared instance with Chat.getCommandManager().
js
// list the commands in the current client command tree
for (const name of Chat.getCommandManager().getValidCommands()) {
Chat.log(name);
}
// register one of our own
const command = Chat.getCommandManager().createCommandBuilder("hello");
command.literalArg("world")
.executes(JavaWrapper.methodToJava(function (ctx) {
Chat.log("hello world");
return true;
}));
command.register();Constructors
new CommandManager
new CommandManager()#Methods
createCommandBuilder
Creates a builder for a client command; it is not registered until CommandBuilder.register() is called.
Parameters:
name: command name, without a leading slash
Returns: a builder initialized for that command
getArgumentAutocompleteOptions
getArgumentAutocompleteOptions(String commandPart, MethodWrapper<List<String>, Object, Object, ?> callback): voidSince1.8.2#Requests autocomplete suggestions and passes their text values to the callback when the asynchronous request completes. Requires a player to be present.
Parameters:
commandPart: partial command text to completecallback: receives the list of suggested completion text when the request completes
getValidCommands
reRegisterCommand
Re-registers a command node previously removed with unregisterCommand(String).
Parameters:
node: helper returned by unregisterCommand(String)
unregisterCommand
Removes a named command from the client command dispatchers.
Parameters:
command: name of the command to remove
Returns: a helper for the removed command node, for use with reRegisterCommand(CommandNodeHelper)