Class ItemEvent

java.lang.Object
org.bukkit.event.Event
io.artificial.enchantments.api.event.EnchantEffectEvent
io.artificial.enchantments.api.event.ItemEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public class ItemEvent extends EnchantEffectEvent implements org.bukkit.event.Cancellable
Event fired when an item-related enchantment effect triggers.

Carries data about the player, item, durability, and action type during item drop, pickup, or durability change events. This event is cancellable.

Since:
0.1.0
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemEvent(@NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull org.bukkit.entity.Player player, @NotNull org.bukkit.inventory.ItemStack item, @NotNull org.bukkit.inventory.EquipmentSlot slot, boolean isDrop, boolean isPickup, int currentDurability, int maxDurability, int damageTaken)
    Creates a new ItemEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the current durability.
    int
    Gets the damage taken.
    static @NotNull org.bukkit.event.HandlerList
    Gets the handler list for this event type.
    @NotNull org.bukkit.event.HandlerList
     
    @NotNull org.bukkit.inventory.ItemStack
    Gets the item.
    int
    Gets the maximum durability.
    @NotNull org.bukkit.entity.Player
    Gets the player associated with the item.
    @NotNull org.bukkit.inventory.EquipmentSlot
    Gets the equipment slot.
    boolean
    Checks if this is an anvil combination.
    boolean
     
    boolean
    Checks if this is a crafting ingredient.
    boolean
    Checks if this is a drop event.
    boolean
    Checks if this is a pickup event.
    void
    reduceDamage(int amount)
    Reduces the damage taken by the specified amount.
    void
    setCancelled(boolean cancelled)
     
    void
    setDamageTaken(int damageTaken)
    Sets the damage taken.
    boolean
    Checks if the item will break from the damage.

    Methods inherited from class io.artificial.enchantments.api.event.EnchantEffectEvent

    checkCancelled, getEnchantment, getLevel, getScaledValue, isCancellable

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, isAsynchronous

    Methods inherited from class java.lang.Object

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

    • ItemEvent

      public ItemEvent(@NotNull @NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.inventory.ItemStack item, @NotNull @NotNull org.bukkit.inventory.EquipmentSlot slot, boolean isDrop, boolean isPickup, int currentDurability, int maxDurability, int damageTaken)
      Creates a new ItemEvent.
      Parameters:
      enchantment - the enchantment that triggered this event
      level - the level of the enchantment
      scaledValue - the scaled value from the enchantment's scaling algorithm
      player - the player associated with the item
      item - the item
      slot - the equipment slot
      isDrop - true if this is a drop event
      isPickup - true if this is a pickup event
      currentDurability - the current durability
      maxDurability - the maximum durability
      damageTaken - the damage taken
  • Method Details

    • getPlayer

      @NotNull public @NotNull org.bukkit.entity.Player getPlayer()
      Gets the player associated with the item.
      Returns:
      the player
    • getItem

      @NotNull public @NotNull org.bukkit.inventory.ItemStack getItem()
      Gets the item.
      Returns:
      the item
    • getSlot

      @NotNull public @NotNull org.bukkit.inventory.EquipmentSlot getSlot()
      Gets the equipment slot.
      Returns:
      the slot
    • isDrop

      public boolean isDrop()
      Checks if this is a drop event.
      Returns:
      true if drop
    • isPickup

      public boolean isPickup()
      Checks if this is a pickup event.
      Returns:
      true if pickup
    • getCurrentDurability

      public int getCurrentDurability()
      Gets the current durability.
      Returns:
      the current durability
    • getMaxDurability

      public int getMaxDurability()
      Gets the maximum durability.
      Returns:
      the maximum durability
    • getDamageTaken

      public int getDamageTaken()
      Gets the damage taken.
      Returns:
      the damage taken
    • setDamageTaken

      public void setDamageTaken(int damageTaken)
      Sets the damage taken.
      Parameters:
      damageTaken - the new damage taken (clamped to non-negative)
    • reduceDamage

      public void reduceDamage(int amount)
      Reduces the damage taken by the specified amount.
      Parameters:
      amount - the amount to reduce
    • willBreak

      public boolean willBreak()
      Checks if the item will break from the damage.
      Returns:
      true if the item will break
    • isCraftingIngredient

      public boolean isCraftingIngredient()
      Checks if this is a crafting ingredient.
      Returns:
      true if crafting ingredient
    • isAnvilCombination

      public boolean isAnvilCombination()
      Checks if this is an anvil combination.
      Returns:
      true if anvil combination
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
    • setCancelled

      public void setCancelled(boolean cancelled)
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Specified by:
      getHandlers in class EnchantEffectEvent
    • getHandlerList

      @NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()
      Gets the handler list for this event type.
      Returns:
      the handler list