Class EnchantmentEffectListener

java.lang.Object
io.artificial.enchantments.internal.EnchantmentEffectListener
All Implemented Interfaces:
org.bukkit.event.Listener

public final class EnchantmentEffectListener extends Object implements org.bukkit.event.Listener
Bukkit event listener that bridges gameplay events into the EffectDispatchSpine.

For each supported Bukkit event, this listener extracts the relevant item, queries custom enchantments via ItemEnchantmentService, and dispatches effects through the spine so that typed callbacks and event bus listeners execute.

  • Constructor Summary

    Constructors
    Constructor
    Description
    EnchantmentEffectListener(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull EffectDispatchSpine spine, @NotNull ItemEnchantmentService itemService)
    Creates a new enchantment effect listener.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onBlockBreak(org.bukkit.event.block.BlockBreakEvent event)
    Handles block break events, dispatching enchantment effects for the tool used to break the block.
    void
    onBlockPlace(org.bukkit.event.block.BlockPlaceEvent event)
    Handles block place events, dispatching enchantment effects for the item used to place the block.
    void
    onEntityDamage(org.bukkit.event.entity.EntityDamageEvent event)
    Handles general entity damage events for armor and shield enchantments.
    void
    onEntityDamageByEntity(org.bukkit.event.entity.EntityDamageByEntityEvent event)
    Handles entity damage by entity events, dispatching enchantment effects for weapons held by the attacking player.
    void
    onEntityPickupItem(org.bukkit.event.entity.EntityPickupItemEvent event)
    Handles entity pickup item events, dispatching enchantment effects for the item being picked up.
    void
    onEntityShootBow(org.bukkit.event.entity.EntityShootBowEvent event)
    Handles entity shoot bow events, dispatching enchantment effects for the bow used to shoot the arrow.
    void
    onPlayerDropItem(org.bukkit.event.player.PlayerDropItemEvent event)
    Handles player drop item events, dispatching enchantment effects for the item being dropped.
    void
    onPlayerFish(org.bukkit.event.player.PlayerFishEvent event)
    Handles player fishing events, dispatching enchantment effects for the fishing rod in the main hand.
    void
    onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent event)
    Handles player interact events with blocks, dispatching enchantment effects for the item in the interacting hand.
    void
    onPlayerInteractEntity(org.bukkit.event.player.PlayerInteractEntityEvent event)
    Handles player interact entity events, dispatching enchantment effects for the item in the interacting hand.
    void
    onPlayerItemConsume(org.bukkit.event.player.PlayerItemConsumeEvent event)
    Handles player item consume events, dispatching enchantment effects for the item being consumed.
    void
    onPlayerItemDamage(org.bukkit.event.player.PlayerItemDamageEvent event)
    Handles player item damage events, dispatching enchantment effects for the item taking durability damage.
    void
    onProjectileHit(org.bukkit.event.entity.ProjectileHitEvent event)
    Handles projectile hit events, dispatching enchantment effects for the item used to launch the projectile.
    void
    onProjectileLaunch(org.bukkit.event.entity.ProjectileLaunchEvent event)
    Handles projectile launch events, dispatching enchantment effects for the item used to launch the projectile (e.g., bow, crossbow, snowball).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EnchantmentEffectListener

      public EnchantmentEffectListener(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull EffectDispatchSpine spine, @NotNull @NotNull ItemEnchantmentService itemService)
      Creates a new enchantment effect listener.
      Parameters:
      plugin - the owning plugin for registration context
      spine - the dispatch spine for firing enchantment effects
      itemService - the item enchantment service for querying item enchantments
      Since:
      1.0.0
  • Method Details

    • onEntityDamageByEntity

      public void onEntityDamageByEntity(org.bukkit.event.entity.EntityDamageByEntityEvent event)
      Handles entity damage by entity events, dispatching enchantment effects for weapons held by the attacking player.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.ENTITY_DAMAGE_BY_ENTITY context for enchantments on the main hand weapon.

      Parameters:
      event - the damage event
      Since:
      1.0.0
    • onEntityDamage

      public void onEntityDamage(org.bukkit.event.entity.EntityDamageEvent event)
      Handles general entity damage events for armor and shield enchantments.
      Parameters:
      event - the damage event
      Since:
      1.0.0
    • onBlockBreak

      public void onBlockBreak(org.bukkit.event.block.BlockBreakEvent event)
      Handles block break events, dispatching enchantment effects for the tool used to break the block.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.BLOCK_BREAK context for enchantments on the main hand tool.

      Parameters:
      event - the block break event
      Since:
      1.0.0
    • onBlockPlace

      public void onBlockPlace(org.bukkit.event.block.BlockPlaceEvent event)
      Handles block place events, dispatching enchantment effects for the item used to place the block.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.BLOCK_PLACE context for enchantments on the main hand item.

      Parameters:
      event - the block place event
      Since:
      1.0.0
    • onPlayerInteract

      public void onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent event)
      Handles player interact events with blocks, dispatching enchantment effects for the item in the interacting hand.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.BLOCK_INTERACT context for enchantments on the interacting hand. Only processes left and right click block actions.

      Parameters:
      event - the player interact event
      Since:
      1.0.0
    • onPlayerInteractEntity

      public void onPlayerInteractEntity(org.bukkit.event.player.PlayerInteractEntityEvent event)
      Handles player interact entity events, dispatching enchantment effects for the item in the interacting hand.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.ENTITY_INTERACT context for enchantments on the hand used to interact with the entity.

      Parameters:
      event - the player interact entity event
      Since:
      1.0.0
    • onProjectileLaunch

      public void onProjectileLaunch(org.bukkit.event.entity.ProjectileLaunchEvent event)
      Handles projectile launch events, dispatching enchantment effects for the item used to launch the projectile (e.g., bow, crossbow, snowball).

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.PROJECTILE_LAUNCH context for enchantments on the main or off hand item. Only processes projectiles launched by players.

      Parameters:
      event - the projectile launch event
      Since:
      1.0.0
    • onProjectileHit

      public void onProjectileHit(org.bukkit.event.entity.ProjectileHitEvent event)
      Handles projectile hit events, dispatching enchantment effects for the item used to launch the projectile.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.PROJECTILE_HIT context for enchantments on the main or off hand item. Only processes projectiles shot by players.

      Parameters:
      event - the projectile hit event
      Since:
      1.0.0
    • onPlayerFish

      public void onPlayerFish(org.bukkit.event.player.PlayerFishEvent event)
      Handles player fishing events, dispatching enchantment effects for the fishing rod in the main hand.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.FISHING_ACTION context for enchantments on the fishing rod.

      Parameters:
      event - the player fish event
      Since:
      1.0.0
    • onEntityShootBow

      public void onEntityShootBow(org.bukkit.event.entity.EntityShootBowEvent event)
      Handles entity shoot bow events, dispatching enchantment effects for the bow used to shoot the arrow.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.BOW_SHOOT context for enchantments on the bow. Detects whether the bow was in the main or off hand and dispatches accordingly. Only processes bows shot by players.

      Parameters:
      event - the entity shoot bow event
      Since:
      1.0.0
    • onPlayerItemConsume

      public void onPlayerItemConsume(org.bukkit.event.player.PlayerItemConsumeEvent event)
      Handles player item consume events, dispatching enchantment effects for the item being consumed.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.ITEM_CONSUME context for enchantments on the consumed item.

      Parameters:
      event - the player item consume event
      Since:
      1.0.0
    • onPlayerItemDamage

      public void onPlayerItemDamage(org.bukkit.event.player.PlayerItemDamageEvent event)
      Handles player item damage events, dispatching enchantment effects for the item taking durability damage.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.DURABILITY_DAMAGE context for enchantments on the damaged item.

      Parameters:
      event - the player item damage event
      Since:
      1.0.0
    • onPlayerDropItem

      public void onPlayerDropItem(org.bukkit.event.player.PlayerDropItemEvent event)
      Handles player drop item events, dispatching enchantment effects for the item being dropped.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.ITEM_DROP context for enchantments on the dropped item.

      Parameters:
      event - the player drop item event
      Since:
      1.0.0
    • onEntityPickupItem

      public void onEntityPickupItem(org.bukkit.event.entity.EntityPickupItemEvent event)
      Handles entity pickup item events, dispatching enchantment effects for the item being picked up.

      Creates and dispatches a EffectDispatchSpine.DispatchEventType.ITEM_PICKUP context for enchantments on the picked up item. Only processes pickups by players.

      Parameters:
      event - the entity pickup item event
      Since:
      1.0.0