Class ZentrixProvider
Addons should use ZentrixAPI.get() instead. This class is used by the
core plugin and by ZentrixAddon during addon startup and shutdown.
Usage
// Get the API instance
ZentrixAPI api = ZentrixAPI.get();
api.getGameService().getActiveGames();
Direct use
register(ZentrixAPI) and unregister() are core bootstrap functionality and
are not supported for addons: there is no supported case for registering or replacing the API
manually, and doing so does not change how Zentrix behaves. Addons retrieve the API, check
PlatformService.getLifecycleState(), and customize
Zentrix through the services' own registrations, events and hooks.
Lifecycle
The API becomes available while Zentrix starts, before it has finished loading arenas and
saved custom games. ZentrixReadyEvent
fires once it has; ZentrixShutdownEvent
fires just before the API is unregistered on shutdown, after which isAvailable() is
false.
- Since:
- 1.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ZentrixAPIget()Returns the ZentrixAPI instance.static booleanReturns whether the ZentrixAPI is available.static voidregister(@NotNull ZentrixAPI api) Registers the API implementation used by the core plugin.static voidRemoves the API implementation.
-
Method Details
-
get
Returns the ZentrixAPI instance.Addons should call
ZentrixAPI.get()instead.- Returns:
- The API instance
- Throws:
IllegalStateException- if the API has not been initialized yet- See Also:
-
isAvailable
public static boolean isAvailable()Returns whether the ZentrixAPI is available.Addons should call
ZentrixAPI.isAvailable()instead.- Returns:
trueif the API is initialized and ready to use- See Also:
-
register
Registers the API implementation used by the core plugin.Internal method. Addons must not call this.
The core plugin calls this during startup. Calling it from an addon is unsupported: it has no useful effect and may cause problems.
- Parameters:
api- The API implementation to register- Throws:
IllegalArgumentException- if api is nullIllegalStateException- if API is already registered
-
unregister
@Internal public static void unregister()Removes the API implementation.Internal method. Addons must not call this.
The core plugin calls this during shutdown. Calling it from an addon is unsupported: it would cut every other addon off from the API while Zentrix keeps running.
-