Skip to content

HeadDatabase Integration

Lord_Lofi edited this page Apr 20, 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 draw randomly from a custom search-based pool — giving every spin a different head.


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. Works for both the box item and individual rewards.

item:
  head-database-id: "3337"
  name: "<gold>✦ Treasure Crate ✦"

Finding IDs: Open /hdb in-game, find the head, hover over it — the numeric ID is in the lore.


Random Head by Custom Category

This is the recommended approach for themed reward pools. Define your own named categories in plugins/LofiBox/head-categories.yml using search terms, then reference them by name in rewards.

head-categories.yml — Basic

categories:

  # Single search term
  starwars:
    search: "star wars"

  # Multiple terms — pool is the union of all matches
  fantasy:
    search:
      - "dragon"
      - "wizard"
      - "elf"
      - "dwarf"

Search terms are matched case-insensitively against each head's name and tags. Multiple terms combine into one pool — a head matching any term is included (no duplicates).


Seasonal Availability Windows

Categories can be restricted to a date range. Outside that window the reward still rolls, but LofiBox falls back to the material field instead of pulling a head.

categories:

  halloween:
    search:
      - "halloween"
      - "pumpkin"
      - "ghost"
    available-from: "10-01"   # October 1
    available-to:   "11-15"   # November 15

  christmas:
    search:
      - "christmas"
      - "santa"
      - "snowman"
    available-from: "12-01"
    available-to:   "01-31"   # Wraps into the new year — supported automatically

Dates use MM-DD format. Year-wrap ranges (e.g. Dec–Jan) are handled automatically.

API exposure: LofiBoxAPI#isBoxAvailableNow(String) and getBoxPrimarySeasonWindow(String) reflect seasonal state so other plugins (e.g. shops) can gate listings. See Developer API.


Double-Reward Chance

A category can award a bonus copy of the head on a configurable percentage of spins, optionally scoped to a date window.

categories:

  pokemon:
    search: "pokemon"
    double-chance: 50           # 50 % chance of a bonus head
    double-from: "02-27"        # Pokémon Day — active for a single day
    double-to:   "02-27"

  monsters:
    search:
      - "monster"
      - "zombie"
      - "skeleton"
    available-from: "10-01"
    available-to:   "11-15"
    double-chance: 5            # 5 % bonus during the halloween window
    double-from: "10-01"
    double-to:   "11-15"

When a double triggers, the player receives a second identical head and a server broadcast fires (configurable in config.yml).

Omit double-from/double-to to make the bonus permanently active.


Server Broadcast & Discord Announce

When a player wins a head-category reward, LofiBox can broadcast the find to the server and post it to an EssentialsXDiscord channel.

# config.yml
head-found-broadcast: true
discord-head-announce: false
discord-channel: "chat"

Broadcast messages are configured in messages.yml under head-found-broadcast and head-double-reward.


Using a Custom Category in a Reward

rewards:
  random_starwars_head:
    weight: 5
    display-name: "<blue>Random Star Wars Head"
    item:
      head-database-category: "starwars"
      material: PLAYER_HEAD    # fallback if HDB unavailable or out of season
      name: "<blue>Mystery Head"
    actions:
      - "[message] <blue>You received a Star Wars head!"

Every spin draws a fresh random head from the pool.


Pool Building

Pools are built once at startup (after HDB's DatabaseLoadEvent fires) by iterating every head in HDB and filtering by your search terms. The cost is paid once; every spin just does a random list pick.

Run /lofibox reload to rebuild pools after editing head-categories.yml.

The startup log will show pool sizes so you can verify your search terms are working:

[HeadCategories] 'starwars' — 47 heads (terms: [star wars])
[HeadCategories] 'fantasy' — 312 heads (terms: [dragon, wizard, elf, dwarf])

All-Heads Pool

Set random: true on a category to draw from every head in HDB with no filtering:

categories:
  random:
    random: true

Random Head by HDB Category (Direct)

You can also reference HDB's built-in category names directly — no head-categories.yml entry needed.

Available values: ANIMALS, MONSTERS, FOOD_DRINKS, HUMANS, HUMANOID, BLOCKS, DECORATION, PLANTS, ALPHABET, MISCELLANEOUS

item:
  head-database-category: "MONSTERS"

Priority Order

When head-database-category is set, LofiBox resolves in this order:

Priority Source Description
1 Custom category (head-categories.yml) Search-term pool — most flexible, supports seasons
2 HDB CategoryEnum Direct built-in HDB category by enum name
3 material fallback Used when HDB is unavailable, out of season, or returns nothing

For the box item itself (head-database-id only):

Priority Key Description
1 head-database-id Specific head by ID
2 item-data Base64 serialized custom item
3 material Standard Bukkit material

Fallback Behaviour

If HeadDatabase is not installed, not yet loaded, a category returns no results, an ID is invalid, or a seasonal window is inactive, LofiBox falls back to the material field. Boxes always load safely on servers without HeadDatabase.

Clone this wiki locally