Class Category

java.lang.Object
me.hackware.api.module.Category
All Implemented Interfaces:
Comparable<Category>

public final class Category extends Object implements Comparable<Category>
A module category — the grouping shown as one panel in the ClickGUI.

Formerly an enum; now an open registry so plugins can contribute their own categories. The built-in categories are declared below as static constants and register themselves in declaration order, so Category.COMBAT and Category.values() behave exactly as they did when this was an enum — including the panel ordering the ClickGUI derives from values().

Plugins register through register(String, String, int) using a namespaced id ("myplugin:utilities") to avoid colliding with the built-ins or with each other. Registration is not thread-safe against concurrent readers by design — register during plugin load, before the ClickGUI builds its panels and before config is applied.

  • Field Details

    • COMBAT

      public static final Category COMBAT
    • MOVEMENT

      public static final Category MOVEMENT
    • PLAYER

      public static final Category PLAYER
    • RENDER

      public static final Category RENDER
    • UTILITY

      public static final Category UTILITY
    • WORLD

      public static final Category WORLD
    • CLIENT

      public static final Category CLIENT
  • Method Details

    • register

      public static Category register(String id, String displayName, int color)
      Registers a new category, visible in the ClickGUI.
      Parameters:
      id - unique key; namespace plugin categories as "pluginid:name"
      displayName - label shown on the panel header
      color - packed RRGGBBAA (note: not ARGB — see getColor())
    • register

      public static Category register(String id, String displayName, int color, boolean hiddenByDefault)
      Registers a new category.
      Parameters:
      hiddenByDefault - when true the category is hidden until isUnlocked() reports otherwise
      Throws:
      IllegalArgumentException - if the id is blank or already registered
    • values

      public static Category[] values()
      All registered categories, in registration order. Built-ins come first in their declaration order, then plugin categories in load order.

      Returns a fresh array each call, mirroring enum values() — safe to iterate while unrelated code registers.

    • registered

      public static List<Category> registered()
      Live unmodifiable view of the registry — avoids the array copy of values().
    • byId

      public static Category byId(String id)
      Looks up a category by its (case-insensitive) id, or null when unregistered.
    • unregister

      public static void unregister(Category category)
      Removes a previously registered category — used to roll back a plugin's categories on unload, so the ClickGUI does not keep an empty panel.

      Built-in categories are refused: removing one would strand the modules that reference it. Registration indices of surviving categories are left alone, so ordering stays stable.

    • getId

      public String getId()
      Unique registry key — "combat", or "myplugin:utilities" for plugins.
    • getDisplayName

      public String getDisplayName()
    • getColor

      public int getColor()
      Returns color in ARGB format for Minecraft rendering. Honors setColorOverride(int).
    • getHexColor

      public String getHexColor()
      Returns the 6-digit RGB hex string (e.g. "FF5555") for use in &#RRGGBB color codes.
    • getDefaultColor

      public int getDefaultColor()
      Default ARGB color (ignores override) — used by the ClickGui module to seed its color picker.
    • setColorOverride

      public void setColorOverride(int argb)
      Apply a runtime ARGB color override (e.g. from the ClickGui module).
    • clearColorOverride

      public void clearColorOverride()
      Remove any runtime color override; revert to the compiled default.
    • index

      public int index()
      Registration index — replaces the old enum ordinal().
    • isHiddenByDefault

      public boolean isHiddenByDefault()
    • isUnlocked

      public boolean isUnlocked()
    • compareTo

      public int compareTo(Category other)
      Orders by registration index, matching the old enum ordinal ordering.
      Specified by:
      compareTo in interface Comparable<Category>
    • toString

      public String toString()
      Overrides:
      toString in class Object