Package me.hackware.api.plugin
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 Summary
Modifier and TypeMethodDescriptionorg.slf4j.Loggerlogger()Logger tagged with this plugin's name.metadata()Descriptor parsed from this plugin'shackware.plugin.json/.yml.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.registerCategory(String id, String displayName, int color, boolean hiddenByDefault) AsregisterCategory(String, String, int), with an explicit hidden-by-default flag.voidRegisters a ClickGUI tab.voidregisterCommand(Command command) Registers a chat command.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.voidregisterModule(Module module) Registers a module.voidregisterScriptProvider(Object provider) Registers a scripting provider — an object whose@Propertymethods become template variables and functions, resolved under its@Namespace.
-
Method Details
-
metadata
PluginMetadata metadata()Descriptor parsed from this plugin'shackware.plugin.json/.yml. -
logger
org.slf4j.Logger logger()Logger tagged with this plugin's name. -
registerModule
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
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 plugindisplayName- label shown on the ClickGUI panel headercolor- packed RRGGBBAA, matchingCategory.register(java.lang.String, java.lang.String, int)
-
registerCategory
AsregisterCategory(String, String, int), with an explicit hidden-by-default flag. -
registerCommand
Registers a chat command. -
registerClickGuiTab
Registers a ClickGUI tab. Use a namespacedClickGuiTab.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
TYPEinitializer, 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
Registers a scripting provider — an object whose@Propertymethods become template variables and functions, resolved under its@Namespace.
-