SmartCommandsManager

This is a guide to learn how to use the SmartCommandsManager class.

What is SmartCommandsManager ?

SmartCommandsManager is a class which allows you to manage your commands. Indeed, it provides many features like checking if a command is loaded, getting a SmartCommand or reloading its contents.

You can get it by using the getSmartCommandsManager() method from the SmartCommandsAPI class.

SmartCommandsAPI api = new SmartCommandsAPI.ApiBuilder().build(this);

SmartCommandsManager scManager = api.getSmartCommandsManager();

Check if a command is loaded

This class allows you to check if a command is correcly loaded by using the isLoaded(String name) method which takes as parameter the name of the command you want to check.

A command is considered as loaded if it meets two criteria:

  1. The command is stored in the commands.json file without syntax errors.

  2. Its contents has been loaded without errors (only if it has a contents file).

boolean isLoaded = scManager.isLoaded("item");

Get a SmartCommand by name

You can use the getSmartCommand(String name) method to get the SmartCommand instance associated to a command.

SmartCommand is a class used to store command data. You can read this guide to get more information about it.

SmartCommand itemCommand = scManager.getSmartCommand("item");

Reload command contents

This class also allows you to reload the contents of one or more command. To reload the contents of only one command, you can use the reloadCommandContents(String name) method which takes as parameter the name of the command you want to reload.

scManager.reloadCommandContents("item");

If you want to reload the contents of all the commands registered by the plugin, just use the reloadCommandContents() method.

scManager.reloadCommandContents();

Last updated