Class Module

java.lang.Object
me.hackware.api.module.Module
All Implemented Interfaces:
SettingContainer

public abstract class Module extends Object implements SettingContainer
  • Constructor Details

  • 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

      public String getName()
    • getDescription

      public String getDescription()
    • getCategory

      public Category getCategory()
    • isEnabled

      public boolean isEnabled()
    • isAlwaysEnabled

      public boolean isAlwaysEnabled()
    • getSettings

      public List<Setting<?>> getSettings()
    • getKeybind

      public KeybindSetting getKeybind()
    • getHideFeedback

      public BooleanSetting getHideFeedback()
    • isGuiExpanded

      public boolean isGuiExpanded()
    • setGuiExpanded

      public void setGuiExpanded(boolean expanded)
    • getExpandedGroupSlugs

      public Set<String> getExpandedGroupSlugs()
    • addSettings

      protected <S extends Setting<?>> S addSettings(S setting)
      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

      protected void addSettings(Setting<?>... settings)
      Registers multiple settings at once.
    • saveContainerSettings

      public void saveContainerSettings()
      Persist this module's settings after a value change (SettingContainer).
      Specified by:
      saveContainerSettings in interface SettingContainer
    • 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 with true.
    • isDefaultEnabled

      public boolean isDefaultEnabled()
      The compile-time default enabled state declared via defaultEnabled(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 of activateFromConfig().

      Runs onDisable and drops the event subscription, but does not persist the new state or print toggle feedback. That matters for plugin unload/reload: toggle() writes enabled: false to 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

      public List<String> getSubCommands()
      Optional module-specific sub-commands invokable as .<module> <verb> [args]. Override getSubCommands() to list verbs (for tab completion) and handleSubCommand(String[]) to handle them. Return true from the handler when the verb was recognised, so ModuleCommand doesn't try to resolve it as a setting path.
    • handleSubCommand

      public boolean handleSubCommand(String[] args)
      See Also:
    • getInfoString

      public String 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). Return null to show no info.
    • prefix

      protected String prefix(TextIcons.Icon icon, net.minecraft.ChatFormatting iconColor)
      [icon] [ModuleName] — for subclasses that need their own send (e.g. no dedup).
    • print

      protected void print(TextIcons.Icon icon, net.minecraft.ChatFormatting iconColor, String message)
      Sends message to the player's chat behind an [icon] [ModuleName] prefix, with the icon tinted iconColor. Replaces any previous message from this module so repeated calls don't spam — one live line per module.
    • info

      protected void info(String message)
      Informational: aqua TextIcons.Icon.INFO.
    • warn

      protected void warn(String message)
      Advisory: yellow TextIcons.Icon.WARNING.
    • error

      protected void error(String message)
      Failure: red TextIcons.Icon.WARNING, message red too.
    • info

      protected void info(String key, String message)
      Sends an informational message with a custom dedup key. Useful when a module needs several independent keyed messages.