Package com.monkey.mcbot.api
Class MinecraftBotAPI
java.lang.Object
com.monkey.mcbot.api.MinecraftBotAPI
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 Summary
ConstructorsConstructorDescriptionMinecraftBotAPI(org.bukkit.plugin.Plugin plugin, IBotManager botManager, IBotRegistry botRegistry) Creates a new API container. -
Method Summary
Modifier and TypeMethodDescriptionstatic MinecraftBotAPIget()Returns the registered API singleton.Returns the operational bot manager service.Returns the registry service for reading bot snapshots.static MinecraftBotAPIReturns the registered API singleton when available.org.bukkit.plugin.PluginReturns the Bukkit plugin that owns this API instance.static booleanIndicates whether the API singleton is currently available.static voidregister(MinecraftBotAPI api) Registers the global API singleton.static voidUnregisters the global API singleton.
-
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()orgetOrNull().- Parameters:
plugin- owning Bukkit plugin instancebotManager- bot management service implementationbotRegistry- bot registry service implementation
-
-
Method Details
-
register
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()returnsfalseandget()throwsIllegalStateExceptionuntil a new registration occurs. -
get
Returns the registered API singleton.- Returns:
- non-null API instance
- Throws:
IllegalStateException- if the API is not registered yet
-
getOrNull
Returns the registered API singleton when available.- Returns:
- API instance, or
nullif not registered
-
isAvailable
public static boolean isAvailable()Indicates whether the API singleton is currently available.- Returns:
trueifget()can be safely called
-
getPlugin
public org.bukkit.plugin.Plugin getPlugin()Returns the Bukkit plugin that owns this API instance.- Returns:
- owning plugin
-
getBotManager
Returns the operational bot manager service.- Returns:
- bot manager implementation
-
getBotRegistry
Returns the registry service for reading bot snapshots.- Returns:
- bot registry implementation
-