Ability System¶
The Ability System allows custom accessories to grant potion effects and attribute modifiers when equipped.
Overview¶
Abilities are defined per-item and consist of:
- Trigger — When the ability activates
- Effect Type — What kind of effect to apply
- Effect Name — The specific effect or attribute
- Amplifier — Effect strength (0–9)
- Duration — How long the effect lasts (in ticks)
Triggers¶
| Trigger | Behavior |
|---|---|
EQUIP |
Fires once when the item is placed into a slot |
DE_EQUIP |
Fires once when the item is removed from a slot |
WHILE_EQUIPPED |
Fires repeatedly while the item remains in a slot |
Effect Types¶
Potion Effects (POTION_EFFECT)¶
Applies a Bukkit PotionEffect to the player. The effect is applied with:
- The specified amplifier (0 = Level I)
- The specified duration in ticks
ambient: true— Ambient particlesparticles: false— Hides particles (less visual noise)
For WHILE_EQUIPPED, the effect is re-applied periodically to maintain the buff.
Player Modifiers (PLAYER_MODIFIER)¶
Modifies a player's attribute (e.g., max health, attack damage) using Bukkit's AttributeModifier system.
- Applied on equip, removed on de-equip
- The amplifier value is used as the modifier amount
- Uses
AttributeModifier.Operation.ADD_NUMBERby default
Ability Listener¶
The AbilityListener handles ability application:
- Listens for
AccessoryEquipEventevents - On
EQUIP: AppliesEQUIPand startsWHILE_EQUIPPEDabilities - On
UNEQUIP: AppliesDE_EQUIPand stopsWHILE_EQUIPPEDabilities - On
SWAP: Removes old abilities, applies new ones
Data Format¶
Abilities are stored in item YAML files:
abilities:
speed_boost:
trigger: WHILE_EQUIPPED
effect-type: POTION_EFFECT
effect-name: SPEED
amplifier: 1
duration: 200
strength_on_equip:
trigger: EQUIP
effect-type: POTION_EFFECT
effect-name: INCREASE_DAMAGE
amplifier: 0
duration: 600
Validation¶
An ability is considered valid when:
triggeris not nulleffectTypeis not nulleffectNameis not null and not emptyamplifieris between 0 and 9
Invalid abilities are silently skipped during loading.
Multiple Abilities¶
Items can have multiple abilities with different triggers. For example, a ring could:
- Grant Speed I while equipped
- Apply Regeneration II for 10 seconds on equip
- Remove a weakness debuff on de-equip