Package dev.jorel.commandapi
Class CommandAPI
java.lang.Object
dev.jorel.commandapi.CommandAPI
Class to register commands with the 1.13 command UI
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDetermines whether command registration is permitted via the CommandAPIForces a command to return a success value of 0static InternalConfigReturns the internal configuration used to manage the CommandAPIstatic LoggerReturns the CommandAPI's loggerstatic List<RegisteredCommand>static booleanisLoaded()Returns whether the CommandAPI is currently loaded.static voidLogs an error from the CommandAPI.static voidLogs a message to the console using Logger.info() if the configuration has verbose logging enabledstatic voidLogs a message from the CommandAPI.static voidlogWarning(String message) Logs a warning from the CommandAPI.static voidUnloads the CommandAPI.static voidonEnable(org.bukkit.plugin.Plugin plugin) Enables the CommandAPI.static voidonLoad(CommandAPIConfig config) Initializes the CommandAPI for loading.static voidregisterCommand(Class<?> commandClass) Registers a command.static voidReloads all of the datapacks that are on the server.static voidunregister(String command) Unregisters a commandstatic voidunregister(String command, boolean force) Unregisters a command, by force (removes all instances of that command)static voidupdateRequirements(org.bukkit.entity.Player player) Updates the requirements required for a given player to execute a command.
-
Method Details
-
isLoaded
public static boolean isLoaded()Returns whether the CommandAPI is currently loaded. This should be true whenonLoad(CommandAPIConfig)is called. If the CommandAPI is loaded, commands are available to register.- Returns:
- whether the CommandAPI has been loaded properly
-
getConfiguration
Returns the internal configuration used to manage the CommandAPI- Returns:
- the internal configuration used to manage the CommandAPI
-
onDisable
public static void onDisable()Unloads the CommandAPI. This should go in your plugin'sJavaPlugin.onDisable()method. -
getLogger
Returns the CommandAPI's logger- Returns:
- the CommandAPI's logger
-
logInfo
Logs a message to the console using Logger.info() if the configuration has verbose logging enabled- Parameters:
message- the message to log to the console
-
logNormal
Logs a message from the CommandAPI. If silent logs are enabled, this message is not logged.- Parameters:
message- the message to log
-
logWarning
Logs a warning from the CommandAPI. If silent logs are enabled, this warning is not logged.- Parameters:
message- the message to log as a warning
-
logError
Logs an error from the CommandAPI. This always gets logged, even if silent logs are enabled.- Parameters:
message- the message to log as an error
-
onLoad
Initializes the CommandAPI for loading. This should be placed at the start of youronLoad()method.- Parameters:
config- the configuration to use for the CommandAPI
-
onEnable
public static void onEnable(org.bukkit.plugin.Plugin plugin) Enables the CommandAPI. This should be placed at the start of youronEnable()method.- Parameters:
plugin- the plugin that this onEnable method is called from
-
updateRequirements
public static void updateRequirements(org.bukkit.entity.Player player) Updates the requirements required for a given player to execute a command.- Parameters:
player- the player whos requirements to update
-
reloadDatapacks
public static void reloadDatapacks()Reloads all of 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. -
fail
Forces a command to return a success value of 0- Parameters:
message- Description of the error message- Returns:
- a
WrapperCommandSyntaxExceptionthat wraps Brigadier'sCommandSyntaxException
-
canRegister
public static boolean canRegister()Determines whether command registration is permitted via the CommandAPI- Returns:
- true if commands can still be registered
-
unregister
Unregisters a command- Parameters:
command- the name of the command to unregister
-
unregister
Unregisters a command, by force (removes all instances of that command)- Parameters:
command- the name of the command to unregisterforce- if true, attempt to unregister all instances of the command across all plugins as well as minecraft, bukkit and spigot
-
registerCommand
Registers a command. Used with the CommandAPI's Annotation API.- Parameters:
commandClass- the class to register
-
getRegisteredCommands
- Returns:
- A list of all
RegisteredCommandsthat have been registered by the CommandAPI so far. The returned list is immutable.
-