CommandAPI 9.5.2
An API for the command UI introduced in Minecraft 1.13
dev.jorel.commandapi.CommandAPI Class Reference

Class to register commands with the 1.13 command UI. More...

Static Public Member Functions

static boolean isLoaded ()
 Returns whether the CommandAPI is currently loaded. More...
 
static void stopCommandRegistration ()
 Flag that commands should no longer be registered. More...
 
static boolean canRegister ()
 Determines whether command registration is permitted via the CommandAPI. More...
 
static InternalConfig getConfiguration ()
 Returns the internal configuration used to manage the CommandAPI. More...
 
static void setLogger (CommandAPILogger logger)
 
static CommandAPILogger getLogger ()
 
static void onLoad (CommandAPIConfig<?> config)
 Initializes the CommandAPI for loading. More...
 
static void onEnable ()
 Enables the CommandAPI. More...
 
static void onDisable ()
 Unloads the CommandAPI.
 
static void logInfo (String message)
 Logs a message to the console using Logger.info() if the configuration has verbose logging enabled. More...
 
static void logNormal (String message)
 Logs a message from the CommandAPI. More...
 
static void logWarning (String message)
 Logs a warning from the CommandAPI. More...
 
static void logError (String message)
 Logs an error from the CommandAPI. More...
 
static void reloadDatapacks ()
 Reloads all the datapacks that are on the server. More...
 
static< CommandSender, Player extends CommandSender > void updateRequirements (Player player)
 Updates the requirements required for a given player to execute a command. More...
 
static WrapperCommandSyntaxException failWithString (String message)
 Forces a command to return a success value of 0. More...
 
static WrapperCommandSyntaxException failWithMessage (Message message)
 Forces a command to return a success value of 0. More...
 
static void unregister (String command)
 Unregisters a command. More...
 
static void unregister (String command, boolean unregisterNamespaces)
 Unregisters a command. More...
 
static void registerCommand (Class<?> commandClass)
 Registers a command. More...
 
static List< RegisteredCommand > getRegisteredCommands ()
 

Detailed Description

Class to register commands with the 1.13 command UI.

Member Function Documentation

◆ canRegister()

static boolean dev.jorel.commandapi.CommandAPI.canRegister ( )
static

Determines whether command registration is permitted via the CommandAPI.

Returns
true if commands can still be registered

◆ failWithMessage()

static WrapperCommandSyntaxException dev.jorel.commandapi.CommandAPI.failWithMessage ( Message  message)
static

Forces a command to return a success value of 0.

Parameters
messageDescription of the error message, formatted as a brigadier message
Returns
a WrapperCommandSyntaxException that wraps Brigadier's CommandSyntaxException

◆ failWithString()

static WrapperCommandSyntaxException dev.jorel.commandapi.CommandAPI.failWithString ( String  message)
static

Forces a command to return a success value of 0.

Parameters
messageDescription of the error message
Returns
a WrapperCommandSyntaxException that wraps Brigadier's CommandSyntaxException

◆ getConfiguration()

static InternalConfig dev.jorel.commandapi.CommandAPI.getConfiguration ( )
static

Returns the internal configuration used to manage the CommandAPI.

Returns
the internal configuration used to manage the CommandAPI

◆ getLogger()

static CommandAPILogger dev.jorel.commandapi.CommandAPI.getLogger ( )
static
Returns
the CommandAPI's logger

◆ getRegisteredCommands()

static List< RegisteredCommand > dev.jorel.commandapi.CommandAPI.getRegisteredCommands ( )
static
Returns
A list of all RegisteredCommands that have been registered by the CommandAPI so far. The returned list is immutable.

◆ isLoaded()

static boolean dev.jorel.commandapi.CommandAPI.isLoaded ( )
static

Returns whether the CommandAPI is currently loaded.

This should be true when CommandAPI#onLoad(CommandAPIConfig) is called. If the CommandAPI is loaded, commands are available to register.

Returns
whether the CommandAPI has been loaded properly

◆ logError()

static void dev.jorel.commandapi.CommandAPI.logError ( String  message)
static

Logs an error from the CommandAPI.

This always gets logged, even if silent logs are enabled.

Parameters
messagethe message to log as an error

◆ logInfo()

static void dev.jorel.commandapi.CommandAPI.logInfo ( String  message)
static

Logs a message to the console using Logger.info() if the configuration has verbose logging enabled.

Parameters
messagethe message to log to the console

◆ logNormal()

static void dev.jorel.commandapi.CommandAPI.logNormal ( String  message)
static

Logs a message from the CommandAPI.

If silent logs are enabled, this message is not logged.

Parameters
messagethe message to log

◆ logWarning()

static void dev.jorel.commandapi.CommandAPI.logWarning ( String  message)
static

Logs a warning from the CommandAPI.

If silent logs are enabled, this warning is not logged.

Parameters
messagethe message to log as a warning

◆ onEnable()

static void dev.jorel.commandapi.CommandAPI.onEnable ( )
static

Enables the CommandAPI.

This should be placed at the start of your onEnable() method.

◆ onLoad()

static void dev.jorel.commandapi.CommandAPI.onLoad ( CommandAPIConfig<?>  config)
static

Initializes the CommandAPI for loading.

This should be placed at the start of your onLoad() method.

Parameters
configthe configuration to use for the CommandAPI. This should be a CommandAPIConfig subclass corresponding to the active platform.

◆ registerCommand()

static void dev.jorel.commandapi.CommandAPI.registerCommand ( Class<?>  commandClass)
static

Registers a command.

Used with the CommandAPI's Annotation API.

Parameters
commandClassthe class to register

◆ reloadDatapacks()

static void dev.jorel.commandapi.CommandAPI.reloadDatapacks ( )
static

Reloads all the datapacks that are on the server.

This should be used if you change a datapack and want to reload a server. Execute this method after running /minecraft:reload, NOT before.

◆ stopCommandRegistration()

static void dev.jorel.commandapi.CommandAPI.stopCommandRegistration ( )
static

Flag that commands should no longer be registered.

After running this, CommandAPI#canRegister() will return false.

◆ unregister() [1/2]

static void dev.jorel.commandapi.CommandAPI.unregister ( String  command)
static

Unregisters a command.

Parameters
commandthe name of the command to unregister

◆ unregister() [2/2]

static void dev.jorel.commandapi.CommandAPI.unregister ( String  command,
boolean  unregisterNamespaces 
)
static

Unregisters a command.

Parameters
commandthe name of the command to unregister
unregisterNamespaceswhether the unregistration system should attempt to remove versions of the command that start with a namespace. E.g. minecraft:command, bukkit:command, or plugin:command. If true, these namespaced versions of a command are also unregistered.

◆ updateRequirements()

static< CommandSender, Player extends CommandSender > void dev.jorel.commandapi.CommandAPI.updateRequirements ( Player  player)
static

Updates the requirements required for a given player to execute a command.

Parameters
playerthe player whose requirements should be updated