Skip to content

HeadDatabase Integration

Lord_Lofi edited this page Apr 18, 2026 · 4 revisions

HeadDatabase Integration

LofiBox has built-in support for HeadDatabase. You can use HDB heads as box items, as specific reward items, or as randomly picked heads from a category — giving every spin a different head from the pool.


Setup

No configuration is required. If HeadDatabase is installed, LofiBox detects it at startup and waits for the DatabaseLoadEvent before enabling the hook. Heads requested before the database loads fall back to the configured material.


Specific Head by ID

Add head-database-id to any item: section. This works for both the box item itself and for individual rewards.

Box Item Example

name: "<gold>Treasure Crate"

item:
  head-database-id: "3337"
  name: "<gold>✦ Treasure Crate ✦"
  lore:
    - ""
    - "<gray>Right-click to open!"

Reward Item Example

rewards:
  skull_reward:
    weight: 10
    display-name: "<yellow>Trophy Head"
    item:
      head-database-id: "9876"
      name: "<yellow>Trophy Head"
      lore:
        - "<gray>A rare decorative head"
    actions:
      - "[message] <yellow>You received a rare head!"

Finding Head IDs

  1. Open the HeadDatabase GUI in-game with /hdb.
  2. Find the head you want.
  3. Hover over it — the numeric ID is shown in the item lore.
  4. Use that number as head-database-id.

Random Head by Category

Use head-database-category instead of head-database-id to make LofiBox pick a random head from that category every time the reward is drawn. Each spin and each give produces a different head from the pool.

rewards:
  random_animal_head:
    weight: 8
    display-name: "<green>Random Animal Head"
    item:
      head-database-category: "Animals"
      material: PLAYER_HEAD      # fallback if HDB is unavailable
      name: "<green>Mystery Animal Head"
      lore:
        - "<gray>A random animal head!"
    actions:
      - "[message] <green>You received a random animal head!"

The category name must match exactly as it appears inside HeadDatabase (e.g. Animals, Food, Minecraft, Humanoid). You can browse category names inside the /hdb GUI.

How It Works

  • On every spin strip render and every reward delivery, getRandomHeadByCategory() queries HeadDatabase for all heads in that category and picks one at random.
  • This means two players opening the same crate may receive completely different animal heads.
  • If the category returns no results (typo, HDB not ready), the reward falls back to the material field.

Priority Order

When building an item, LofiBox checks in this order:

Priority Key Description
1 head-database-category Random head from HDB category (rewards only)
2 head-database-id Specific head by HDB ID
3 item-data Base64 serialized custom item
4 material Standard Bukkit material (default: CHEST)

Fallback Behaviour

If HeadDatabase is not installed, not yet loaded, or a category/ID returns nothing, LofiBox falls back gracefully to the material field. Boxes always load safely on servers without HeadDatabase.

Clone this wiki locally