Class AddonModule

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

public abstract class AddonModule extends Object implements Serializable<AddonModule>, BaseModule
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

    • options

      public final ArrayList<Option<?>> options
      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
      Specified by:
      getName in interface BaseModule
      Returns:
      The module's name
    • getTitle

      public String getTitle()
      Gets the display title of this module
      Specified by:
      getTitle in interface BaseModule
      Returns:
      The module's title
    • setTitle

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

      public String getDescription()
      Gets the description of this module
      Specified by:
      getDescription in interface BaseModule
      Returns:
      The module's description
    • setDescription

      public void setDescription(String description)
      Modify the description of the module

      This resets when you re-launch

      Supports newline escape sequence
      Specified by:
      setDescription in interface BaseModule
      Parameters:
      description - Description to set
    • getState

      public boolean getState()
      Gets whether this module is enabled
      Specified by:
      getState in interface BaseModule
      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
      Specified by:
      setState in interface BaseModule
      Parameters:
      newState - The new state
      Returns:
      true if the state changed, false if it was already in that state
    • onEnable

      public void onEnable()
      Called when this module is enabled

      Override this to add custom enable behavior
      Specified by:
      onEnable in interface BaseModule
    • onDisable

      public void onDisable()
      Called when this module is disabled

      Override this to add custom disable behavior
      Specified by:
      onDisable in interface BaseModule
    • getBind

      public Bind getBind()
      Gets the current keybind
      Specified by:
      getBind in interface BaseModule
      Returns:
      The module's keybind
    • setBind

      public void setBind(Bind newBind)
      Sets the keybind
      Specified by:
      setBind in interface BaseModule
      Parameters:
      newBind - The new keybind
    • getArrayListInfo

      public String getArrayListInfo()
      Method called by ArrayList to get info
      Specified by:
      getArrayListInfo in interface BaseModule
      Returns:
      Info to show in ArrayList brackets
    • isVisible

      public boolean isVisible()
      Gets whether this module is visible in the ArrayList
      Specified by:
      isVisible in interface BaseModule
      Returns:
      true if the module is visible in ArrayList, false otherwise
    • setVisible

      public void setVisible(boolean visible)
      Sets whether this module is visible in the ArrayList
      Specified by:
      setVisible in interface BaseModule
      Parameters:
      visible - true to make the module visible in ArrayList, false to hide it
    • shouldNotify

      public boolean shouldNotify()
      Gets whether notifications should be shown when this module is toggled
      Specified by:
      shouldNotify in interface BaseModule
      Returns:
      true if notifications should be shown, false otherwise
    • setNotify

      public void setNotify(boolean notify)
      Sets whether notifications should be shown when this module is toggled
      Specified by:
      setNotify in interface BaseModule
      Parameters:
      notify - true to show notifications, false to hide them
    • isOnlyWhileHolding

      public boolean isOnlyWhileHolding()
      Gets whether this module should only be active while the bind key is held
      Specified by:
      isOnlyWhileHolding in interface BaseModule
      Returns:
      true if the module only activates while holding the key, false for toggle behavior
    • setOnlyWhileHolding

      public void setOnlyWhileHolding(boolean onlyWhileHolding)
      Sets whether this module should only be active while the bind key is held
      Specified by:
      setOnlyWhileHolding in interface BaseModule
      Parameters:
      onlyWhileHolding - true for hold-to-activate, false for toggle behavior
    • getOptions

      public List<Option<?>> getOptions()
      Gets a list of this module's options
      Specified by:
      getOptions in interface BaseModule
      Returns:
      the list of this module's options
    • getBindOption

      public BindOption getBindOption()
      Gets the keybind option
      Returns:
      The module's bind option
    • 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