Class CommandAPI

java.lang.Object
dev.jorel.commandapi.CommandAPI

public final class CommandAPI extends Object
Class to register commands with the 1.13 command UI
  • Method Details

    • isLoaded

      public static boolean isLoaded()
      Returns whether the CommandAPI is currently loaded. This should be true when onLoad(CommandAPIConfig) is called. If the CommandAPI is loaded, commands are available to register.
      Returns:
      whether the CommandAPI has been loaded properly
    • getConfiguration

      public static InternalConfig 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's JavaPlugin.onDisable() method.
    • getLogger

      public static Logger getLogger()
      Returns the CommandAPI's logger
      Returns:
      the CommandAPI's logger
    • logInfo

      public static void logInfo(String message)
      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

      public static void logNormal(String message)
      Logs a message from the CommandAPI. If silent logs are enabled, this message is not logged.
      Parameters:
      message - the message to log
    • logWarning

      public static void logWarning(String message)
      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

      public static void logError(String message)
      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

      public static void onLoad(CommandAPIConfig config)
      Initializes the CommandAPI for loading. This should be placed at the start of your onLoad() 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 your onEnable() 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

      public static WrapperCommandSyntaxException fail(String message)
      Forces a command to return a success value of 0
      Parameters:
      message - Description of the error message
      Returns:
      a WrapperCommandSyntaxException that wraps Brigadier's CommandSyntaxException
    • canRegister

      public static boolean canRegister()
      Determines whether command registration is permitted via the CommandAPI
      Returns:
      true if commands can still be registered
    • unregister

      public static void unregister(String command)
      Unregisters a command
      Parameters:
      command - the name of the command to unregister
    • unregister

      public static void unregister(String command, boolean force)
      Unregisters a command, by force (removes all instances of that command)
      Parameters:
      command - the name of the command to unregister
      force - if true, attempt to unregister all instances of the command across all plugins as well as minecraft, bukkit and spigot
    • registerCommand

      public static void registerCommand(Class<?> commandClass)
      Registers a command. Used with the CommandAPI's Annotation API.
      Parameters:
      commandClass - the class to register
    • getRegisteredCommands

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