Class ZentrixAddon

java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
dev.itsharshxd.zentrix.api.addon.ZentrixAddon
All Implemented Interfaces:
io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner, net.kyori.adventure.key.Namespaced, org.bukkit.command.CommandExecutor, org.bukkit.command.TabCompleter, org.bukkit.command.TabExecutor, org.bukkit.plugin.Plugin

public abstract class ZentrixAddon extends org.bukkit.plugin.java.JavaPlugin
Base class for Zentrix addons.

Extend this class from an addon's main class. It checks API availability, verifies the required version, and registers the addon during startup.

Example


 public class MyAddon extends ZentrixAddon {

     @Override
     protected void onAddonEnable() {
         // Initialize the addon
         getLogger().info("MyAddon enabled!");

         // Access the API
         ZentrixAPI api = ZentrixAPI.get();
         api.getGameService().getActiveGames();
     }

     @Override
     protected void onAddonDisable() {
         // Clean up addon state
         getLogger().info("MyAddon disabled!");
     }

     @Override
     protected String getRequiredAPIVersion() {
         return "1.0.0"; // Minimum required API version
     }
 }
 

API access

Use ZentrixAPI.get() to access the API from anywhere in the addon.

plugin.yml configuration

Your addon's plugin.yml should declare Zentrix as a dependency:

 name: MyAddon
 version: 1.0.0
 main: com.example.myaddon.MyAddon
 depend: [Zentrix]
 api-version: '1.21'
 
Since:
1.0.0
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull String
    Returns the addon's unique identifier.
    protected final @NotNull ZentrixAPI
    Returns the ZentrixAPI instance.
    protected @NotNull String
    Returns the minimum required ZentrixAPI version.
    protected final boolean
    Returns whether the ZentrixAPI is currently available.
    final boolean
    Returns whether this addon is registered with Zentrix.
    protected void
    Called while the addon is being disabled.
    protected abstract void
    Called after the addon passes the startup checks.
    final void
    Final implementation of onDisable().
    final void
    Final implementation of onEnable().

    Methods inherited from class org.bukkit.plugin.java.JavaPlugin

    getClassLoader, getCommand, getConfig, getDataFolder, getDefaultBiomeProvider, getDefaultWorldGenerator, getDescription, getFile, getLifecycleManager, getLogger, getPlugin, getPluginLoader, getPluginMeta, getProvidingPlugin, getResource, getServer, getTextResource, init, init, isEnabled, isNaggable, onCommand, onLoad, onTabComplete, registerCommand, registerCommand, registerCommand, registerCommand, reloadConfig, saveConfig, saveDefaultConfig, saveResource, setEnabled, setNaggable, toString

    Methods inherited from class org.bukkit.plugin.PluginBase

    equals, getName, hashCode, namespace

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.bukkit.plugin.Plugin

    getComponentLogger, getDataPath, getLog4JLogger, getSLF4JLogger
  • Constructor Details

    • ZentrixAddon

      public ZentrixAddon()
  • Method Details

    • onEnable

      public final void onEnable()
      Final implementation of onEnable().

      It checks API availability and version compatibility, registers the addon, and then calls onAddonEnable() for addon-specific initialization.

      Specified by:
      onEnable in interface org.bukkit.plugin.Plugin
      Overrides:
      onEnable in class org.bukkit.plugin.java.JavaPlugin
    • onDisable

      public final void onDisable()
      Final implementation of onDisable().

      It calls onAddonDisable() and then unregisters the addon.

      Specified by:
      onDisable in interface org.bukkit.plugin.Plugin
      Overrides:
      onDisable in class org.bukkit.plugin.java.JavaPlugin
    • onAddonEnable

      protected abstract void onAddonEnable()
      Called after the addon passes the startup checks.

      Override this method to initialize the addon. The API is available and the addon has already been registered with Zentrix.

      Use ZentrixAPI.get() to access the API here.

    • onAddonDisable

      protected void onAddonDisable()
      Called while the addon is being disabled.

      Override this method to clean up addon state. It runs before the addon is unregistered from Zentrix.

      The default implementation is empty.

    • getAddonId

      @NotNull public @NotNull String getAddonId()
      Returns the addon's unique identifier.

      The default is the plugin name in lowercase. Override this method to use a different identifier.

      Returns:
      The addon ID (never null)
    • getRequiredAPIVersion

      @NotNull protected @NotNull String getRequiredAPIVersion()
      Returns the minimum required ZentrixAPI version.

      Override this method to specify the minimum API version the addon needs. The default is "1.0.0".

      Version format follows semantic versioning: MAJOR.MINOR.PATCH Compatibility is determined by the major version number.

      Returns:
      The minimum required API version (e.g., "1.0.0")
    • getAPI

      @NotNull protected final @NotNull ZentrixAPI getAPI()
      Returns the ZentrixAPI instance.

      Use ZentrixAPI.get() instead. This method remains for backwards compatibility.

      Returns:
      The ZentrixAPI instance (never null)
      Throws:
      IllegalStateException - if called before the addon is enabled or if Zentrix is not available
      See Also:
    • isAPIAvailable

      protected final boolean isAPIAvailable()
      Returns whether the ZentrixAPI is currently available.

      Use ZentrixAPI.isAvailable() when checking availability outside the enable phase.

      Returns:
      true if the API is available
      See Also:
    • isZentrixEnabled

      public final boolean isZentrixEnabled()
      Returns whether this addon is registered with Zentrix.
      Returns:
      true if the addon is registered and enabled