Class Addon

java.lang.Object
dev.boze.api.addon.Addon
All Implemented Interfaces:
Serializable<Addon>

public abstract class Addon extends Object implements Serializable<Addon>
Base class for all Boze addons
An addon is a self-contained extension that can add new functionality to Boze
Each addon has a unique identifier, name, description, and version
Addons can contain multiple modules and commands, which are managed through the addon's dispatcher
  • Field Details

    • id

      public final String id
      Unique identifier for this addon
    • name

      public final String name
      Display name of this addon
    • description

      public final String description
      Description of what this addon does
    • version

      public final String version
      Version string of this addon
    • modules

      public final ArrayList<AddonModule> modules
      List of modules provided by this addon
    • extensions

      public final ArrayList<ClientModuleExtension> extensions
      List of client module extensions provided by this addon
    • dispatcher

      public final AddonDispatcher dispatcher
      Command dispatcher for this addon
  • Constructor Details

    • Addon

      public Addon(String id, String name, String description, String version)
      Creates a new addon with a default dispatcher
      Parameters:
      id - Unique identifier for this addon
      name - Display name of this addon
      description - Description of what this addon does
      version - Version string of this addon
    • Addon

      public Addon(String id, String name, String description, String version, AddonDispatcher dispatcher)
      Creates a new addon with a custom dispatcher
      Parameters:
      id - Unique identifier for this addon
      name - Display name of this addon
      description - Description of what this addon does
      version - Version string of this addon
      dispatcher - Custom command dispatcher for this addon
  • Method Details

    • createCategory

      protected void createCategory(String name)
      Creates a custom GUI category for this addon's modules.
      An addon may create at most one category; the first call wins and later calls are ignored. When set, all of this addon's modules appear under this category in the GUI as their own element instead of the shared "Addons" category. Call this from initialize().
      Parameters:
      name - Display name of the category
    • getCategory

      public String getCategory()
      Gets this addon's custom category name.
      Returns:
      The category name, or null if this addon uses the shared "Addons" category
    • initialize

      public abstract boolean initialize()
      Initializes this addon
      Register your modules, extensions, and commands here
      Returns:
      true if initialization was successful, false otherwise
    • load

      public void load()
      Loads the addon config
      This is called when the client config is loaded.
    • postInitialize

      public void postInitialize()
      Called after load() once all addons have been created.
      Addons may override this to perform post-load initialization that relies on config data.
    • shutdown

      public void shutdown()
      Shuts down this addon
      This is called when the addon is unloaded. The default implementation saves the addon's configuration to disk.
    • getDir

      public File getDir()
      Gets the addon's directory
      Creates the directory if it doesn't exist
      Returns:
      The addon's directory
    • toJson

      public com.google.gson.JsonObject toJson()
      Specified by:
      toJson in interface Serializable<Addon>
      Returns:
      The object as a JsonObject
    • fromJson

      public Addon fromJson(com.google.gson.JsonObject object)
      Specified by:
      fromJson in interface Serializable<Addon>
      Parameters:
      object - The JsonObject to deserialize
      Returns:
      The deserialized object