Package dev.boze.api.addon
Class AddonModule
java.lang.Object
dev.boze.api.addon.AddonModule
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AddonModule
(String name, String description) Creates a new module -
Method Summary
Modifier and TypeMethodDescriptionfromJson
(com.google.gson.JsonObject object) getBind()
Gets the current keybindGets the keybind optionGets the description of this modulegetName()
Gets the internal name of this moduleboolean
getState()
Gets whether this module is enabledgetTitle()
Gets the display title of this moduleprotected void
Called when this module is disabledprotected void
onEnable()
Called when this module is enabledvoid
Sets the keybindboolean
setState
(boolean newState) Sets whether this module is enabledvoid
Sets the display title of this modulecom.google.gson.JsonObject
toJson()
-
Field Details
-
settings
List of settings for this module
-
-
Constructor Details
-
AddonModule
Creates a new module- Parameters:
name
- Internal name of this moduledescription
- Description of what this module does
-
-
Method Details
-
getName
Gets the internal name of this module- Returns:
- The module's name
-
getTitle
Gets the display title of this module- Returns:
- The module's title
-
setTitle
Sets the display title of this module- Parameters:
newTitle
- The new title
-
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
Gets the current keybind- Returns:
- The module's keybind
-
getBindOption
Gets the keybind option- Returns:
- The module's keybind option
-
setBind
Sets the keybind- Parameters:
newBind
- The new keybind
-
toJson
public com.google.gson.JsonObject toJson()- Specified by:
toJson
in interfaceSerializable<AddonModule>
- Returns:
- The object as a JsonObject
-
fromJson
- Specified by:
fromJson
in interfaceSerializable<AddonModule>
- Parameters:
object
- The JsonObject to deserialize- Returns:
- The deserialized object
-