Hook System

Hook System

Learn about zItems' hook system that integrates with third-party plugins to provide extended functionality.


Overview

Hooks are optional plugin integrations that add features when specific plugins are installed. They enable zItems to:

  • Detect custom blocks from ItemsAdder, Nexo, Oraxen

  • Boost job rewards in Jobs Reborn and ZJobs

  • Respect region protection from WorldGuard and SuperiorSkyBlock2

  • Integrate with shops for Auto-Sell effects

Hooks are automatically enabled when their corresponding plugin is detected at startup.


How Hooks Work

Auto-Detection

At startup, zItems scans for @AutoHook annotations:

@AutoHook("Jobs")
public class JobsHook implements Hook {
    @Override
    public void onEnable() {
        // Register extractors, handlers, providers
    }
}

If the plugin name ("Jobs") is found using Bukkit.getPluginManager().getPlugin("Jobs"), the hook is enabled.

Hook Lifecycle


Available Hooks

Custom Block Providers

Detect and drop custom blocks from third-party plugins.

ItemsAdder

Plugin: ItemsAdder Hook: IAHook.java Purpose: Custom blocks, items, textures

What it provides:

  • Detects ItemsAdder custom blocks using CustomBlock.byAlreadyPlaced()

  • Detects ItemsAdder furniture using CustomFurniture.byAlreadySpawned()

  • Returns correct ItemStack for custom drops

Integration:

Effects that use it:

  • Hammer

  • Vein Mining

Nexo

Plugin: Nexo Hook: NexoHook.java Purpose: Custom blocks and items

What it provides:

  • Detects Nexo custom blocks using NexoBlocks.customBlockMechanic()

  • Returns correct ItemStack for custom drops

Effects that use it:

  • Hammer

  • Vein Mining

Oraxen

Plugin: Oraxen Hook: OraxenHook.java Purpose: Custom items and blocks

What it provides:

  • Detects Oraxen custom blocks using OraxenBlocks.isOraxenBlock()

  • Returns correct ItemStack using OraxenBlocks.getOraxenBlock()

Effects that use it:

  • Hammer

  • Vein Mining


Job System Integrations

Boost job experience and money rewards.

Jobs Reborn

Plugin: Jobs Reborn Hook: JobsHook.java Purpose: Job system with leveling

What it provides:

Extractors:

  • JobExpGainEventExtractor - Extracts ItemStack from JobsExpGainEvent

  • JobMoneyGainEventExtractor - Extracts ItemStack from JobsPrePaymentEvent

Handlers:

  • JobsExperienceMultiplier - Multiplies job XP gained

  • JobsMoneyMultiplier - Multiplies job money gained

Example effect:

How it works:

ZJobs

Plugin: ZJobs (GroupeZ) Hook: ZJobsHook.java Purpose: GroupeZ custom job system

What it provides:

Extractors:

  • ZJobExpGainEventExtractor - Extracts ItemStack from ZJobs XP events

  • ZJobMoneyGainEventExtractor - Extracts ItemStack from ZJobs money events

Handlers:

  • ZJobsExperienceMultiplier - Multiplies ZJobs XP

  • ZJobsMoneyMultiplier - Multiplies ZJobs money

Example effect:


Protection Plugins

Respect region protection and island permissions.

WorldGuard

Plugin: WorldGuard Hook: WorldGuardHook.java Purpose: Region protection

What it provides:

  • Location access checking for protected regions

  • Prevents Hammer/Vein Mining in protected areas

Implementation:

Location Access Check:

How effects use it:

SuperiorSkyBlock2

Plugin: SuperiorSkyBlock2 Hook: SuperiorSkyBlockHook.java Purpose: Skyblock plugin with island protection

What it provides:

  • Island permission checking

  • Prevents non-members from using effects on islands

Implementation:


Shop Integrations

Provide item pricing for Auto-Sell effect.

EconomyShopGUI

Plugin: EconomyShopGUI Hook: EconomyShopGUIHook.java Purpose: Shop plugin

What it provides:

  • Shop pricing via EconomyShopGUIProvider

  • Auto-sell functionality

Implementation:

Effect that uses it:

  • Auto Sell

ShopGUIPlus

Plugin: ShopGUIPlus Hook: ShopGUIPlusHook.java Purpose: Shop plugin

What it provides:

  • Shop pricing via ShopGUIPlusProvider

  • Auto-sell functionality

ZShop

Plugin: ZShop (GroupeZ) Hook: ZShopHook.java Purpose: GroupeZ custom shop system

What it provides:

  • Shop pricing via ZShopProvider

  • Auto-sell functionality with GroupeZ-specific pricing


Hook Components

Extractors

Purpose: Extract ItemStack from plugin-specific events

Interface: ItemSourceExtractor<E extends Event>

Example:

Registration:

Handlers

Purpose: Custom effect handlers for plugin-specific features

Example: Jobs XP Boost

Implementation:

Registration:

Providers

Purpose: Provide plugin-specific services (shops, custom blocks, protection)

Interface Example: CustomBlockProvider

Registration:


Creating Custom Hooks

Step 1: Create Hook Module

Create a new directory in hooks/:

Step 2: Implement Hook Interface

Step 3: Create Extractor (Optional)

Step 4: Create Handler (Optional)

Step 5: Add to Build

Edit settings.gradle.kts (auto-detected if directory exists):

Step 6: Add Dependency

Create hooks/MyPlugin/build.gradle.kts:

Step 7: Test

  1. Build: ./gradlew build

  2. Install zItems + MyPlugin

  3. Check logs for:


Hook Registry System

All hooks use the centralized registry pattern:

CustomBlockProviderRegistry

LocationAccessRegistry

ShopProviderRegistry


Checking Enabled Hooks

In Console

At startup, zItems logs detected hooks:

In Code


Soft Dependencies

All hooks are defined as soft dependencies in plugin.yml:

Soft dependencies are optional - zItems loads even if they're not present.


Troubleshooting

Hook not detected

Symptoms:

  • Plugin is installed but hook doesn't enable

  • Console shows no "Detected [Plugin]" message

Checklist:

  1. Is the plugin name correct in @AutoHook("PluginName")?

  2. Is the plugin loaded before zItems? (Check load order)

  3. Is the hook class in the correct package? (fr.traqueur.items.hooks.*)

Debug:

Look for: [zItems] [DEBUG] Scanning for @AutoHook annotations...

Custom blocks not dropping

Symptoms:

  • ItemsAdder/Oraxen blocks drop vanilla items

Checklist:

  1. Is the hook enabled? (Check console logs)

  2. Is the custom block plugin loaded?

  3. Are you using Hammer or Vein Mining effects?

Test: Break the custom block manually (without zItems). Does it drop correctly? If no, the issue is with the custom block plugin, not zItems.

Auto-Sell not working

Symptoms:

  • Items aren't sold automatically

  • No money received

Checklist:

  1. Is a shop plugin installed? (EconomyShopGUI, ShopGUIPlus, ZShop)

  2. Is the shop plugin detected? (Check console logs)

  3. Does the item have a price in the shop?

Test:

Look for: [zItems] Detected EconomyShopGUI - enabling shop integration


Best Practices

  1. Use @AutoHook annotation - Automatic detection and loading

  2. Register all components in onEnable() - Centralized registration

  3. Use Registry pattern - Type-safe component access

  4. Provide meaningful provider names - e.g., "itemsadder", "worldguard"

  5. Handle Optional.empty() gracefully - Providers may not handle all cases

  6. Test with and without plugin - Ensure graceful degradation

  7. Document required dependencies - In hook's JavaDoc


  • Dependencies - Required and optional plugins

  • Effect Handlers Reference - How effects use hooks

  • Block Tracking - zItems custom block tracking


Need help? Join our Discord or check GitHub Issues!

Last updated