Class MinecraftBotAPI

java.lang.Object
com.monkey.mcbot.api.MinecraftBotAPI

public final class MinecraftBotAPI extends Object
Main public entry point for the MinecraftBot API.

This object exposes the two core API services: IBotManager for operations and IBotRegistry for read-only snapshots. The instance is registered by the core plugin during startup and can be retrieved by external plugins after MinecraftBotReadyEvent is fired.

Typical usage in another plugin:


 MinecraftBotAPI api = MinecraftBotAPI.getOrNull();
 if (api != null) {
     IBotManager manager = api.getBotManager();
     // spawn / update / remove operations
 }
 
  • Constructor Details

    • MinecraftBotAPI

      public MinecraftBotAPI(org.bukkit.plugin.Plugin plugin, IBotManager botManager, IBotRegistry botRegistry)
      Creates a new API container.

      This constructor is intended for the core plugin integration layer. External plugins should not instantiate this class directly; they should access the registered singleton through get() or getOrNull().

      Parameters:
      plugin - owning Bukkit plugin instance
      botManager - bot management service implementation
      botRegistry - bot registry service implementation
  • Method Details

    • register

      public static void register(MinecraftBotAPI api)
      Registers the global API singleton.

      Calling this method replaces any previous instance.

      Parameters:
      api - fully initialized API instance
    • unregister

      public static void unregister()
      Unregisters the global API singleton.

      After this call, isAvailable() returns false and get() throws IllegalStateException until a new registration occurs.

    • get

      public static MinecraftBotAPI get()
      Returns the registered API singleton.
      Returns:
      non-null API instance
      Throws:
      IllegalStateException - if the API is not registered yet
    • getOrNull

      public static MinecraftBotAPI getOrNull()
      Returns the registered API singleton when available.
      Returns:
      API instance, or null if not registered
    • isAvailable

      public static boolean isAvailable()
      Indicates whether the API singleton is currently available.
      Returns:
      true if get() can be safely called
    • getPlugin

      public org.bukkit.plugin.Plugin getPlugin()
      Returns the Bukkit plugin that owns this API instance.
      Returns:
      owning plugin
    • getBotManager

      public IBotManager getBotManager()
      Returns the operational bot manager service.
      Returns:
      bot manager implementation
    • getBotRegistry

      public IBotRegistry getBotRegistry()
      Returns the registry service for reading bot snapshots.
      Returns:
      bot registry implementation