Package me.hackware.api.module
Class Module
java.lang.Object
me.hackware.api.module.Module
- All Implemented Interfaces:
SettingContainer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidActivates a module that was loaded as enabled from config.protected voidaddSettings(Setting<?>... settings) Registers multiple settings at once.protected <S extends Setting<?>>
SaddSettings(S setting) Registers a setting with this module and returns it.static voidbootstrap(Consumer<Module> saveSettings, Runnable saveStates, BooleanSupplier armed) Installed once by the client before any module is constructed.voidTears a module down for unregistration — the inverse ofactivateFromConfig().voiddefaultEnabled(boolean enabled) Declares the compile-time default enabled state (called from a module's constructor).protected voidFailure: redTextIcons.Icon.WARNING, message red too.Returns a short info/meta string for this module, displayed in the HUD module list.getName()Optional module-specific sub-commands invokable as.<module> <verb> [args].getSubCommandSuggestions(String[] args) Tab completions for a sub-command's arguments.booleanhandleSubCommand(String[] args) voidhide()Hides the module again, switching it off first so it never runs unseen.protected voidInformational: aquaTextIcons.Icon.INFO.protected voidSends an informational message with a custom dedup key.booleanbooleanThe compile-time default enabled state declared viadefaultEnabled(boolean).booleanbooleanbooleanisHidden()Whether this module is hidden from the ClickGUI, command tab-completion and HUD pickers.voidloadEnabled(boolean enabled) Applies the enabled state read from config (no toggle callbacks, no save).protected voidprotected voidonEnable()protected Stringprefix(TextIcons.Icon icon, net.minecraft.ChatFormatting iconColor) [icon] [ModuleName]— for subclasses that need their own send (e.g.protected voidprint(TextIcons.Icon icon, net.minecraft.ChatFormatting iconColor, String message) Sendsmessageto the player's chat behind an[icon] [ModuleName]prefix, with the icon tintediconColor.voidPuts the keybind back to its default (unbound, Toggle) and saves binds.yml.voidPuts every setting back to its default (Setting.resetToDefault()).voidPuts the module back the way a fresh install has it: every setting, the keybind and Hide Feedback.voidreveal()Reveals a hidden module so it shows in the ClickGUI and can be toggled.voidPersist this module's settings after a value change (SettingContainer).voidsetEnabled(boolean enabled) voidsetGuiExpanded(boolean expanded) protected voidsetHidden(boolean hidden) Declares the module hidden (called from a module's constructor).voidtoggle()protected voidAdvisory: yellowTextIcons.Icon.WARNING.
-
Constructor Details
-
Module
-
-
Method Details
-
bootstrap
public static void bootstrap(Consumer<Module> saveSettings, Runnable saveStates, BooleanSupplier armed) Installed once by the client before any module is constructed. -
getName
-
getDescription
-
getCategory
-
isEnabled
public boolean isEnabled() -
isAlwaysEnabled
public boolean isAlwaysEnabled() -
getSettings
-
getKeybind
-
getHideFeedback
-
isHidden
public boolean isHidden()Whether this module is hidden from the ClickGUI, command tab-completion and HUD pickers. -
setHidden
protected void setHidden(boolean hidden) Declares the module hidden (called from a module's constructor). -
reveal
public void reveal()Reveals a hidden module so it shows in the ClickGUI and can be toggled. Not persisted here: the client records it (ConfigManager.setRevealed) and reveals it again on load. No-op for a module that was never hidden. -
hide
public void hide()Hides the module again, switching it off first so it never runs unseen. -
isGuiExpanded
public boolean isGuiExpanded() -
setGuiExpanded
public void setGuiExpanded(boolean expanded) -
getExpandedGroupSlugs
-
addSettings
Registers a setting with this module and returns it. Usage:addSetting(new NumberSetting("Range").defaultValue(4.0).min(1.0).max(6.0).step(0.1)) -
addSettings
Registers multiple settings at once. -
saveContainerSettings
public void saveContainerSettings()Persist this module's settings after a value change (SettingContainer).- Specified by:
saveContainerSettingsin interfaceSettingContainer
-
resetSettings
public void resetSettings()Puts every setting back to its default (Setting.resetToDefault()). Each one saves and fires itsonChangedas a ClickGUI edit would. A module whose settings need more than that overrides this. -
resetKeybind
public void resetKeybind()Puts the keybind back to its default (unbound, Toggle) and saves binds.yml. -
resetToDefaults
public void resetToDefaults()Puts the module back the way a fresh install has it: every setting, the keybind and Hide Feedback. Whether it is on is left as it is, so a reset never switches a module off (or on) under the player. -
toggle
public void toggle() -
setEnabled
public void setEnabled(boolean enabled) -
defaultEnabled
public void defaultEnabled(boolean enabled) Declares the compile-time default enabled state (called from a module's constructor). Modules default to off unless they call this withtrue. -
isDefaultEnabled
public boolean isDefaultEnabled()The compile-time default enabled state declared viadefaultEnabled(boolean). -
loadEnabled
public void loadEnabled(boolean enabled) Applies the enabled state read from config (no toggle callbacks, no save). -
activateFromConfig
public void activateFromConfig()Activates a module that was loaded as enabled from config. Registers to the event bus and calls onEnable() without saving config. -
deactivateForUnload
public void deactivateForUnload()Tears a module down for unregistration — the inverse ofactivateFromConfig().Runs
onDisableand drops the event subscription, but does not persist the new state or print toggle feedback. That matters for plugin unload/reload:toggle()writesenabled: falseto states.yml, which would clobber the saved enabled state that a reload is about to restore. -
onEnable
protected void onEnable() -
onDisable
protected void onDisable() -
getSubCommands
Optional module-specific sub-commands invokable as.<module> <verb> [args]. OverridegetSubCommands()to list verbs (for tab completion) andhandleSubCommand(String[])to handle them. Returntruefrom the handler when the verb was recognised, soModuleCommanddoesn't try to resolve it as a setting path. -
handleSubCommand
- See Also:
-
getSubCommandSuggestions
Tab completions for a sub-command's arguments.args[0]is the verb and the last element is the argument being typed.- See Also:
-
getInfoString
Returns a short info/meta string for this module, displayed in the HUD module list. Override in subclasses to provide live info (e.g., CPS, mode, damage). Returnnullto show no info. -
prefix
[icon] [ModuleName]— for subclasses that need their own send (e.g. no dedup). -
print
Sendsmessageto the player's chat behind an[icon] [ModuleName]prefix, with the icon tintediconColor. Replaces any previous message from this module so repeated calls don't spam — one live line per module. -
info
Informational: aquaTextIcons.Icon.INFO. -
warn
Advisory: yellowTextIcons.Icon.WARNING. -
error
Failure: redTextIcons.Icon.WARNING, message red too. -
info
Sends an informational message with a custom dedup key. Useful when a module needs several independent keyed messages.
-