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.private static IllegalStateExceptionconnectionFailure(org.bukkit.plugin.java.JavaPlugin plugin, String reason, Exception cause) static voiddisconnect(org.bukkit.plugin.java.JavaPlugin plugin) Disconnect an external Bukkit plugin from UltiTools framework.private static voiddisconnect(org.bukkit.plugin.java.JavaPlugin plugin, boolean propagateFailure) static voidDisconnect all external plugins, rethrowing the first failure after all attempts finish.(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) static ReloadReportreload(org.bukkit.plugin.java.JavaPlugin plugin) Reloads a connected external plugin's typed configuration, timing bindings and message overrides, as/ul reload <name>does.static voidreloadMessages(org.bukkit.plugin.java.JavaPlugin plugin) Re-reads the message catalogues bundled in a connected external plugin's JAR and the overrides in itsmessages/data directory.(package private) static voidremoveAdapter(org.bukkit.plugin.java.JavaPlugin plugin) private static ExternalPluginAdapterrequireConnectedAdapter(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
-
connectionFailure
private static IllegalStateException connectionFailure(org.bukkit.plugin.java.JavaPlugin plugin, String reason, Exception cause) -
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
-
disconnect
private static void disconnect(org.bukkit.plugin.java.JavaPlugin plugin, boolean propagateFailure) -
reloadMessages
public static void reloadMessages(org.bukkit.plugin.java.JavaPlugin plugin) Re-reads the message catalogues bundled in a connected external plugin's JAR and the overrides in itsmessages/data directory. A malformed override file is ignored with a warning in the server console, so the bundled messages remain available as fallback. Does nothing if the plugin did not ship a message catalogue. A full/ul reloadalso refreshes these overrides for connected plugins.May be called from any thread; file I/O is synchronous under the text engine lock. Call only after
connect(JavaPlugin)returns successfully, not from a bean initializer or other code running during registration.- Parameters:
plugin- the connected external JavaPlugin- Throws:
IllegalStateException- if the plugin is not connected to UltiTools, including while it is still being registered byconnect- Since:
- 7.0.0
-
reload
Reloads a connected external plugin's typed configuration, timing bindings and message overrides, as/ul reload <name>does. UnlikereloadMessages(JavaPlugin), this operation runs only on the server thread. Other threads receive a partial report explaining the refusal, without reloading anything.- Parameters:
plugin- the connected external JavaPlugin- Returns:
- the reload report, empty when every step completed
- Throws:
IllegalStateException- if the plugin is not connected, including during registrationConfigurationException- if a configuration fails to reload- Since:
- 7.2.0
-
requireConnectedAdapter
private static ExternalPluginAdapter requireConnectedAdapter(org.bukkit.plugin.java.JavaPlugin plugin) -
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 non-null by the time a connected plugin calls this (set byPluginManager.registerExternalright after minting). An adapter without a scope (its registration was refused) is refused withENTITY_NOT_OWNED, as the deprecatedDataStore.getOperator(File, Class)overload it fell back to before 6.4.0 refused an unregistered data folder.- 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. Teardown failures already reported by the manager are not rethrown.- Parameters:
plugin- the plugin being disabled- Since:
- 6.2.2
-
disconnectAll
public static void disconnectAll()Disconnect all external plugins, rethrowing the first failure after all attempts finish.- Since:
- 6.2.2
-