Class ZentrixProvider

java.lang.Object
dev.itsharshxd.zentrix.api.ZentrixProvider

public final class ZentrixProvider extends Object
Holds the ZentrixAPI implementation for the core plugin.

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 Details

    • get

      @NotNull public static @NotNull ZentrixAPI 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:
      true if the API is initialized and ready to use
      See Also:
    • register

      @Internal public static void register(@NotNull @NotNull ZentrixAPI api)
      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 null
      IllegalStateException - 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.