Class AddonModule

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

public abstract class AddonModule extends Object implements Serializable<AddonModule>
Base class for all addon modules

A module is a self-contained piece of functionality that can be enabled or disabled

Each module has a name, description, title (which can be changed), and a keybind

Modules can have settings which are automatically serialized and deserialized
  • Field Details

    • settings

      public final ArrayList<Option<?>> settings
      List of settings for this module
  • Constructor Details

    • AddonModule

      protected AddonModule(String name, String description)
      Creates a new module
      Parameters:
      name - Internal name of this module
      description - Description of what this module does
  • Method Details

    • getName

      public String getName()
      Gets the internal name of this module
      Returns:
      The module's name
    • getTitle

      public String getTitle()
      Gets the display title of this module
      Returns:
      The module's title
    • setTitle

      public void setTitle(String newTitle)
      Sets the display title of this module
      Parameters:
      newTitle - The new title
    • getDescription

      public String getDescription()
      Gets the description of this module
      Returns:
      The module's description
    • getState

      public boolean getState()
      Gets whether this module is enabled
      Returns:
      true if the module is enabled, false otherwise
    • setState

      public boolean setState(boolean newState)
      Sets whether this module is enabled

      This will call onEnable() or onDisable() as appropriate
      Parameters:
      newState - The new state
      Returns:
      true if the state changed, false if it was already in that state
    • onEnable

      protected void onEnable()
      Called when this module is enabled

      Override this to add custom enable behavior
    • onDisable

      protected void onDisable()
      Called when this module is disabled

      Override this to add custom disable behavior
    • getBind

      public Bind getBind()
      Gets the current keybind
      Returns:
      The module's keybind
    • getBindOption

      public BindOption getBindOption()
      Gets the keybind option
      Returns:
      The module's keybind option
    • setBind

      public void setBind(Bind newBind)
      Sets the keybind
      Parameters:
      newBind - The new keybind
    • toJson

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

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