Interface IScriptHookHandler


  • public interface IScriptHookHandler
    Handler for registering and retrieving script hooks. Addon mods can register custom hooks that will appear in the script editor GUIs.

    Available contexts:

    • "npc" - NPC script editor
    • "player" - Player scripts editor
    • "block" - Scripted block editor
    • "item" - Scripted item editor
    • "linked_item" - Linked item editor
    • "forge" - Forge scripts editor
    • "global_npc" - Global NPC scripts editor
    • "recipe" - Recipe scripts editor
    • "effect" - Custom effect scripts editor

    Hook Registration

    Use registerHookDefinition(String, IHookDefinition) to register hooks:
    
     hooks.registerHookDefinition("player",
         HookDefinition.of("onDBCTransform", IDBCEvent.TransformEvent.class));
     
    • Method Detail

      • registerHookDefinition

        void registerHookDefinition​(String context,
                                    IHookDefinition definition)
        Register a hook with full metadata including event type and imports.
        Parameters:
        context - The context identifier (e.g., "npc", "player", "block")
        definition - The hook definition containing all metadata
      • getHookDefinition

        IHookDefinition getHookDefinition​(String context,
                                          String hookName)
        Get the hook definition for a specific hook.
        Parameters:
        context - The context identifier
        hookName - The hook function name
        Returns:
        The hook definition, or null if not found
      • getAllHookDefinitions

        List<IHookDefinition> getAllHookDefinitions​(String context)
        Get all hook definitions for a context.
        Parameters:
        context - The context identifier
        Returns:
        List of all hook definitions (may be empty, never null)
      • getAllHooks

        List<String> getAllHooks​(String context)
        Get all hook names for a context.
        Parameters:
        context - The context identifier
        Returns:
        List of all hook function names
      • hasHook

        boolean hasHook​(String context,
                        String hookName)
        Check if a hook is registered in a specific context.
        Parameters:
        context - The context to check
        hookName - The function name to look for
        Returns:
        true if the hook is registered
      • getHookRevision

        int getHookRevision()
        Get the current hook revision number. This increments each time a hook is registered, allowing caches to invalidate.
        Returns:
        The current revision number
      • getContexts

        String[] getContexts()
        Get all available context identifiers.
        Returns:
        Array of context strings