Events
AstralItems fires four custom Bukkit events that other plugins (and AstralItems' own heads) can listen to.
HandEquipEvent
Fully qualified name: com.astralrealms.items.event.HandEquipEvent (extends PlayerEvent).
Fired by HandListener whenever the main hand's ItemStack changes in a way the plugin cares about:
Trigger | Source |
|
|
|---|---|---|---|
Main-hand slot updated |
| Previous main-hand item | New main-hand item |
Interaction with item frame / armour stand |
| Current main-hand item | Empty |
Player quits |
| Current main-hand item | Empty |
The event is not cancellable — it is a notification. Both oldItem and newItem are defensively cloned on construction.
Fields
Field | Type | Description |
|---|---|---|
|
| Inherited from |
|
| The item leaving the slot (cloned). |
|
| The item entering the slot (cloned). |
Example listener
ArmorEquipEvent
Fully qualified name: com.astralrealms.items.event.armor.ArmorEquipEvent (extends PlayerEvent).
Fired by ArmorListener off Paper's PlayerArmorChangeEvent whenever a non-empty item enters an armour slot. Not cancellable — it is a notification. Drives the equip-armor pipeline head.
Fields
Field | Type | Description |
|---|---|---|
|
| Inherited from |
|
| The item that was equipped ( |
|
| The armour slot it entered ( |
ArmorUnEquipEvent
Fully qualified name: com.astralrealms.items.event.armor.ArmorUnEquipEvent (extends PlayerEvent).
The counterpart to ArmorEquipEvent: fired by ArmorListener when a non-empty item leaves an armour slot. Not cancellable. Drives the unequip-armor pipeline head.
Fields
Field | Type | Description |
|---|---|---|
|
| Inherited from |
|
| The item that was removed ( |
|
| The armour slot it left ( |
AnvilResultEvent
Fully qualified name: com.astralrealms.items.event.AnvilResultEvent (extends PlayerEvent, implements Cancellable).
Fired by AnvilService every time the player's custom anvil result needs to be recomputed: when an input slot changes, when the rename text changes, or when a click happens. Listeners can override the result item, override the level cost, or cancel the whole combine.
The default vanilla algorithm (VanillaAnvilLogic) runs before the event fires, so listeners see a populated result and cost and can either tweak or fully replace them.
Fields
Field | Type | Description |
|---|---|---|
|
| The anvil user. |
|
| The full session — exposes both input slots, the output slot, the cursor stack, and the rename text. |
|
| Slot 0. Cloned snapshot — mutating it has no effect. |
|
| Slot 1. Cloned snapshot — mutating it has no effect. |
|
| Slot 2. Replace it with |
|
| Level cost the player will pay on take. Set to |
Example listener
The plugin's own AnvilListener listens at HIGH priority to apply enchanted-book combines that respect metadata.available-enchantments, and at LOW priority to refuse over-levelled non-custom results. See Anvil for the full recompute pipeline.
Reacting to a Bukkit event from inside a pipeline
The equip-hand head subscribes to HandEquipEvent for you — wiring a HandEquipPipelineHead in a blueprint is enough to run a pipeline whenever the item is equipped:
For every other Bukkit event the plugin already hooks (block break, entity damage, fishing, drag-and-drop, …), use the corresponding head from Pipeline Heads — there is no need to write your own Bukkit listener.