Interface PluginContext


public interface PluginContext
The registration surface handed to a Plugin on enable.

Registering through this context rather than calling the underlying registries directly lets the loader attribute every contribution back to the owning plugin, so it can be rolled back when the plugin is unloaded or disabled after an error.

All register* methods must be called from Plugin.onEnable(PluginContext); the context is not valid afterwards.

  • Method Details

    • metadata

      PluginMetadata metadata()
      Descriptor parsed from this plugin's hackware.plugin.json/.yml.
    • logger

      org.slf4j.Logger logger()
      Logger tagged with this plugin's name.
    • registerModule

      void registerModule(Module module)
      Registers a module. Behaves exactly like a built-in module: it appears in its category panel, gets a chat command, and its settings and keybind are persisted.
    • registerCategory

      Category registerCategory(String id, String displayName, int color)
      Registers a category, automatically namespaced to this plugin ("<pluginId>:<id>") so it cannot collide with the built-ins or another plugin.
      Parameters:
      id - category key, unique within this plugin
      displayName - label shown on the ClickGUI panel header
      color - packed RRGGBBAA, matching Category.register(java.lang.String, java.lang.String, int)
    • registerCategory

      Category registerCategory(String id, String displayName, int color, boolean hiddenByDefault)
      As registerCategory(String, String, int), with an explicit hidden-by-default flag.
    • registerCommand

      void registerCommand(Command command)
      Registers a chat command.
    • registerClickGuiTab

      void registerClickGuiTab(ClickGuiTab tab)
      Registers a ClickGUI tab. Use a namespaced ClickGuiTab.id() such as "myplugin:tools"; registering under an existing id replaces that surface.
    • registerHudElement

      HudElementType registerHudElement(String typeName, String idPrefix, String menuLabel, boolean persist, Class<? extends HUDElement> elementClass, HudElementFactory factory, Set<String> typeAliases, Set<String> idPrefixAliases)
      Registers a HUD element type.

      Built-in elements self-register from a static TYPE initializer, which only runs when the class is loaded. Plugin elements must be registered explicitly through this method instead — the loader does not scan plugin jars for element classes.

    • registerScriptProvider

      void registerScriptProvider(Object provider)
      Registers a scripting provider — an object whose @Property methods become template variables and functions, resolved under its @Namespace.