Class CommandApi


  • public final class CommandApi
    extends Object
    CommandAPI provides global utilities and configuration options for the CommandAPI framework.

    This class is responsible for:

    • Managing debug and logging configuration
    • Providing centralized command execution logs
    • Measuring command performance
    • Handling and reporting command execution errors

    This class is static-only and must be initialized once during the plugin onEnable() lifecycle.

    Version:
    0.0.9-alpha
    Author:
    jonagamerpro1234
    • Constructor Summary

      Constructors 
      Constructor Description
      CommandApi()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void debug​(@NotNull String message)
      Logs a debug message if debug mode is enabled.
      static void handleError​(@NotNull String command, @NotNull org.bukkit.command.CommandSender sender, @NotNull Throwable throwable)
      Handles and logs an error that occurred during command execution.
      static void init​(@NotNull org.bukkit.plugin.java.JavaPlugin javaPlugin)
      Initializes the CommandAPI.
      static boolean isDebug()
      Checks whether debug mode is enabled.
      static void log​(@NotNull String message)
      Logs an informational message using the plugin logger.
      static void logCommandExecution​(@NotNull String command, @NotNull org.bukkit.command.CommandSender sender, long executionTimeMs)
      Logs information about a command execution.
      static void setDebug​(boolean enabled)
      Enables or disables debug mode.
      static void setLogExecution​(boolean enabled)
      Enables or disables command execution logging.
      static void setLogPerformance​(boolean enabled)
      Enables or disables command performance logging.
    • Constructor Detail

      • CommandApi

        public CommandApi()
    • Method Detail

      • init

        public static void init​(@NotNull
                                @NotNull org.bukkit.plugin.java.JavaPlugin javaPlugin)
        Initializes the CommandAPI.

        This method must be called once in onEnable() before using any CommandAPI features.

        Parameters:
        javaPlugin - the plugin instance
        Since:
        0.0.9-alpha
      • setDebug

        public static void setDebug​(boolean enabled)
        Enables or disables debug mode.

        When enabled, additional debug information and stack traces will be printed to the console.

        Parameters:
        enabled - true to enable debug mode
        Since:
        0.0.9-alpha
      • isDebug

        public static boolean isDebug()
        Checks whether debug mode is enabled.
        Returns:
        true if debug mode is enabled
        Since:
        0.0.9-alpha
      • setLogExecution

        public static void setLogExecution​(boolean enabled)
        Enables or disables command execution logging.
        Parameters:
        enabled - true to enable execution logging
        Since:
        0.0.9-alpha
      • setLogPerformance

        public static void setLogPerformance​(boolean enabled)
        Enables or disables command performance logging.

        This option only has effect if execution logging is enabled.

        Parameters:
        enabled - true to enable performance logging
        Since:
        0.0.9-alpha
      • log

        public static void log​(@NotNull
                               @NotNull String message)
        Logs an informational message using the plugin logger.
        Parameters:
        message - the message to log
        Since:
        0.0.9-alpha
      • debug

        public static void debug​(@NotNull
                                 @NotNull String message)
        Logs a debug message if debug mode is enabled.
        Parameters:
        message - the debug message
        Since:
        0.0.9-alpha
      • logCommandExecution

        public static void logCommandExecution​(@NotNull
                                               @NotNull String command,
                                               @NotNull
                                               @NotNull org.bukkit.command.CommandSender sender,
                                               long executionTimeMs)
        Logs information about a command execution.
        Parameters:
        command - the executed command name
        sender - the command sender
        executionTimeMs - execution time in milliseconds
        Since:
        0.0.9-alpha
      • handleError

        public static void handleError​(@NotNull
                                       @NotNull String command,
                                       @NotNull
                                       @NotNull org.bukkit.command.CommandSender sender,
                                       @NotNull
                                       @NotNull Throwable throwable)
        Handles and logs an error that occurred during command execution.
        Parameters:
        command - the command being executed
        sender - the command sender
        throwable - the thrown exception or error
        Since:
        0.0.9-alpha