Class UltiToolsAPI
Usage:
public class MyPlugin extends JavaPlugin {
public void onEnable() {
UltiToolsAPI.connect(this);
}
public void onDisable() {
UltiToolsAPI.disconnect(this);
}
}
- Since:
- 6.2.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map<org.bukkit.plugin.java.JavaPlugin, ExternalPluginAdapter> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidconnect(org.bukkit.plugin.java.JavaPlugin plugin) Connect an external Bukkit plugin to UltiTools framework.static voidConnect an external Bukkit plugin to UltiTools framework, declaring entity classes that legitimately live outside the plugin's own JAR (D-19) -- a shared library JAR, or a multi-module build's common artifact.static voiddisconnect(org.bukkit.plugin.java.JavaPlugin plugin) Disconnect an external Bukkit plugin from UltiTools framework.static voidDisconnect all external plugins.(package private) static ExternalPluginAdaptergetAdapter(org.bukkit.plugin.java.JavaPlugin plugin) static <T extends BaseDataEntity<String>>
DataOperator<T> getDataOperator(org.bukkit.plugin.java.JavaPlugin plugin, Class<T> dataEntity) Get a DataOperator for an external plugin's data entity.static EventBusGet the UltiTools EventBus for inter-plugin communication.static booleanisConnected(org.bukkit.plugin.java.JavaPlugin plugin) Check if a plugin is connected.static voidonPluginDisable(org.bukkit.plugin.java.JavaPlugin plugin) Auto-disconnect a plugin when it is disabled.(package private) static voidregisterAdapter(org.bukkit.plugin.java.JavaPlugin plugin, ExternalPluginAdapter adapter) (package private) static voidremoveAdapter(org.bukkit.plugin.java.JavaPlugin plugin) (package private) static voidreset()Reset all state.
-
Field Details
-
adapters
-
-
Constructor Details
-
UltiToolsAPI
private UltiToolsAPI()
-
-
Method Details
-
connect
public static void connect(org.bukkit.plugin.java.JavaPlugin plugin) Connect an external Bukkit plugin to UltiTools framework. Scans the plugin's package for @Service, @CmdExecutor, @EventListener, etc.- Parameters:
plugin- the external JavaPlugin to connect- Throws:
IllegalStateException- if UltiTools is not loaded
-
connect
public static void connect(org.bukkit.plugin.java.JavaPlugin plugin, Class<?>... additionalEntities) Connect an external Bukkit plugin to UltiTools framework, declaring entity classes that legitimately live outside the plugin's own JAR (D-19) -- a shared library JAR, or a multi-module build's common artifact. The plugin's own JAR is always scanned for@Tableclasses automatically;additionalEntitiesis additive to that scan, not a replacement for it. The single-argumentconnect(JavaPlugin)overload is unchanged and delegates here with an empty array.additionalEntitiesis validated, not trusted (02-14). Each class must live onplugin's own classpath -- either its own JAR, or a jar/module not already known to belong to a different, currently-loaded plugin. A class that structurally belongs to a DIFFERENT plugin (its own JAR, or one already recorded as owned by another plugin) is refused with anIllegalStateExceptionwrapping acom.ultikits.ultitools.exceptions.PluginModuleException, and no partial registration is left behind --additionalEntitiescannot be used to obtain a workingDataOperatorfor another plugin's entity, only to declare entities this plugin genuinely owns but does not package.- Parameters:
plugin- the external JavaPlugin to connectadditionalEntities- entity classes owned by this plugin that live outside its own JAR- Throws:
IllegalStateException- if UltiTools is not loaded, or if an entity inadditionalEntitiesdoes not live onplugin's own classpath (02-14)- Since:
- 6.3.0
-
disconnect
public static void disconnect(org.bukkit.plugin.java.JavaPlugin plugin) Disconnect an external Bukkit plugin from UltiTools framework.- Parameters:
plugin- the external JavaPlugin to disconnect
-
getDataOperator
public static <T extends BaseDataEntity<String>> DataOperator<T> getDataOperator(org.bukkit.plugin.java.JavaPlugin plugin, Class<T> dataEntity) Get a DataOperator for an external plugin's data entity. Data is stored in the plugin's own data folder. Refuses outright ifdataEntityis not registered toplugin(D-14) -- checked against the sameDataScopeminted for this plugin atconnect(...)time, via the same refusalDataStore.getOperator(DataScope, Class)builds, so the exception type, error code, and message shape are identical regardless of which entry point a caller reaches.02-13 (CR-03): before this,
scope.owns(...)was checked here inline and this method then delegated to the deprecatedgetOperator(File, Class)overload directly -- soDataStore.getOperator(DataScope, Class), the method D-17/02-07 built specifically as the credential-typed supported path, had zero real callers anywhere in the framework. This now routes through it, so production actually uses the path it was built for.scopeis normally non-null by the time a connected plugin calls this (set byPluginManager.registerExternalright after minting); thenullfallback below only covers an adapter that predates that wiring, where the deprecated overload's owncheckOwnership(...)call still refuses correctly on its own.- Type Parameters:
T- entity type- Parameters:
plugin- the external JavaPlugindataEntity- the data entity class (must have @Table annotation)- Returns:
- data operator
- Throws:
DataAccessException- ifdataEntityis not registered toplugin
-
getEventBus
Get the UltiTools EventBus for inter-plugin communication.- Returns:
- the EventBus instance
-
isConnected
public static boolean isConnected(org.bukkit.plugin.java.JavaPlugin plugin) Check if a plugin is connected.- Parameters:
plugin- the plugin to check- Returns:
- true if connected
-
getAdapter
-
registerAdapter
static void registerAdapter(org.bukkit.plugin.java.JavaPlugin plugin, ExternalPluginAdapter adapter) -
removeAdapter
static void removeAdapter(org.bukkit.plugin.java.JavaPlugin plugin) -
reset
static void reset()Reset all state. For testing only. -
onPluginDisable
public static void onPluginDisable(org.bukkit.plugin.java.JavaPlugin plugin) Auto-disconnect a plugin when it is disabled. Called by the PluginDisableEvent listener in PluginManager.- Parameters:
plugin- the plugin being disabled- Since:
- 6.2.2
-
disconnectAll
public static void disconnectAll()Disconnect all external plugins. Called during UltiTools shutdown.- Since:
- 6.2.2
-