AstralItems Overview
AstralItems is the custom-item framework for the AstralRealms network. Server operators define items in YAML — appearance, rarity, version, optional metadata, optional default item data, and one or more behaviour pipelines — and the plugin attaches those behaviours to live Bukkit events without writing a single line of Java.
A pipeline reads like a small program: a head captures a Bukkit event, a chain of links transforms the captured state (drops, XP, durability, the player's inventory, the item's own data bag), and one or more tails apply the side effects (drop on the ground, magnet to inventory, log to console).
What it does
Blueprints describe an item: a
display, ararity, a semverversion, optionalmetadata, optionaldefault-data, and a list ofpipelines.Rarities are top-level objects with their own
idanddisplay. The id becomes the namespace of every blueprint that references them —rarity.id() + ":" + blueprint.idis the item'sKey.Pipelines are declarative event handlers. Heads, chain links, and tails are all looked up by type ID in a central registry — adding a new behaviour means adding a new YAML node, not a new plugin.
Item data is a pluggable typed bag persisted alongside the item — built-in adapters cover XP/level (
scalable), a stored block material (stored-material), and a stored entity (stored-entity). Plugins can register their own adapters viaItemDataRegistry.Item stats (experimental) — a blueprint can declare min/max numeric stats that roll once per item and persist on the stack; see Item Stats. Player application through AstralStats is not yet wired up.
Item instances carry a UUID, a blueprint reference, the version at creation time, and the data bag, all persisted in the ItemStack PDC under
astralrealms:item.Hot upgrade — when the blueprint version bumps, items already in the world rebuild themselves on the next handle (inventory open, chunk load, data load), preserving UUID / damage / unbreakable / enchantments.
Custom anvil —
/items anvilopens a packet-level anvil that firesAnvilResultEventfor every recompute. The plugin's listener uses it to apply enchanted books while honouring the blueprint'savailable-enchantmentswhitelist.CraftEngine integration — items are registered as a CraftEngine stack supplier under the
astralitemsnamespace, so any system that reads a CraftEngine key (recipes, shops, menus) will find AstralItems items.Event hijacking — the plugin re-registers existing listeners through its own dispatcher so it can route events to the correct item's pipeline based on the ItemStack involved.
Requirements
Dependency | Required | Notes |
|---|---|---|
Paper 1.21+ | Yes |
|
AstralCore | Yes | Plugin framework, registries, item wrappers, menus, actions, requirements, placeholders |
AstralSync | Yes |
|
CraftEngine | Yes | Item registry, reload events |
PacketEvents | Yes | Used by |
AstralStats | Yes | Player stat framework — declared for the (experimental) item stats system |
Java 25 | Yes | Compile target — server must run a matching JDK |
Architecture at a glance
Service | Responsibility |
|---|---|
| Loads |
| Loads |
| Type-ID registry for heads / links / tails; wires every blueprint pipeline to the right Bukkit event. |
| Owns one dummy listener per |
| Reads / writes the item PDC; exposes |
| Owns the packet-level custom anvil window; fires |
| Scans inventories for duplicated unique items / over-threshold stackables and alerts via a Discord webhook (production only). See Duplication detection. |
| Static utility that builds an |
| Registers the |
| Loads |
Listener | Trigger |
|---|---|
| Reloads blueprints when CraftEngine reloads. |
| Fires the custom |
| Fires |
| Caps damage at |
| Runs the duplication scan on |
| Blocks vanilla enchanting / smithing / grindstone / loom recipes from operating on custom items. |
| Rebuilds outdated items on |
| Intercepts vanilla anvil right-clicks and reroutes to |
| PacketEvents listener routing anvil window clicks back into |
Item data is persisted directly on the ItemStack via ItemInstanceDataType — see Developer API for the PDC layout and Item Data for the typed data bag.
Duplication detection
On production servers, DuplicationService watches for item duplication and posts a Discord alert — it is a detection / alerting tool and does not remove or block anything. It scans when a player's data loads and when they open an inventory (AstralCore menu inventories are skipped), flagging:
the same unique custom-item UUID appearing in more than one stack, and
configured stackable items whose total quantity crosses a threshold.
It runs only when the server environment is PRODUCTION, and players with the duplication.bypass permission are skipped.
Configure it in duplication.yml:
Key | Type | Description |
|---|---|---|
| String | Discord webhook the alerts post to. |
|
| Per-item quantity thresholds. |
duplication.yml is re-read by /items reload.