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
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
ConstructorsConstructorDescriptionItemEvent(@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 newItemEvent. -
Method Summary
Modifier and TypeMethodDescriptionintGets the current durability.intGets the damage taken.static @NotNull org.bukkit.event.HandlerListGets the handler list for this event type.@NotNull org.bukkit.event.HandlerList@NotNull org.bukkit.inventory.ItemStackgetItem()Gets the item.intGets the maximum durability.@NotNull org.bukkit.entity.PlayerGets the player associated with the item.@NotNull org.bukkit.inventory.EquipmentSlotgetSlot()Gets the equipment slot.booleanChecks if this is an anvil combination.booleanbooleanChecks if this is a crafting ingredient.booleanisDrop()Checks if this is a drop event.booleanisPickup()Checks if this is a pickup event.voidreduceDamage(int amount) Reduces the damage taken by the specified amount.voidsetCancelled(boolean cancelled) voidsetDamageTaken(int damageTaken) Sets the damage taken.booleanChecks if the item will break from the damage.Methods inherited from class io.artificial.enchantments.api.event.EnchantEffectEvent
checkCancelled, getEnchantment, getLevel, getScaledValue, isCancellableMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
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 newItemEvent.- Parameters:
enchantment- the enchantment that triggered this eventlevel- the level of the enchantmentscaledValue- the scaled value from the enchantment's scaling algorithmplayer- the player associated with the itemitem- the itemslot- the equipment slotisDrop- true if this is a drop eventisPickup- true if this is a pickup eventcurrentDurability- the current durabilitymaxDurability- the maximum durabilitydamageTaken- 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:
isCancelledin interfaceorg.bukkit.event.Cancellable
-
setCancelled
public void setCancelled(boolean cancelled) - Specified by:
setCancelledin interfaceorg.bukkit.event.Cancellable
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()- Specified by:
getHandlersin classEnchantEffectEvent
-
getHandlerList
@NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()Gets the handler list for this event type.- Returns:
- the handler list
-