Skip to content

CommandManager ​

com.jsmacrosce.jsmacros.client.api.classes.inventory.CommandManager

Since1.7.0

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 ​

createCommandBuilder(String name): CommandBuilderSince1.7.0#
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 complete
  • callback: receives the list of suggested completion text when the request completes

getValidCommands ​

getValidCommands(): List<String>Since1.7.0#
Returns: names of the root command tree's direct children; empty when no connection is available

reRegisterCommand ​

reRegisterCommand(CommandNodeHelper node): voidSince1.7.0#
Re-registers a command node previously removed with unregisterCommand(String).

Parameters:

unregisterCommand ​

unregisterCommand(String command): CommandNodeHelperSince1.7.0#
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)