Interface ItemContext
- All Superinterfaces:
EffectContext
Context for item-related enchantment effects.
Provides access to player, item, equipment slot, durability, and item action data during durability changes, drops, pickups, and crafting/anvil operations.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionintGets the current durability of the item.intGets the damage being taken by this item.@NotNull org.bukkit.inventory.ItemStackgetItem()Gets the item being processed.@NotNull org.bukkit.LocationGets the location of the item.intGets the maximum durability of the item.@Nullable org.bukkit.entity.PlayerGets the player holding the item.@Nullable org.bukkit.inventory.EquipmentSlotgetSlot()Gets the equipment slot where the item is held.booleanChecks if the item is being combined in an anvil.booleanChecks if the item is being used as a crafting ingredient.booleanisDrop()Checks if this event is an item drop.booleanisPickup()Checks if this event is an item pickup.voidreduceDamage(int reduction) Reduces the damage taken by a specified amount.voidsetDamageTaken(int damage) Sets the damage to be taken by this item.booleanChecks if the item will break from this damage.Methods inherited from interface io.artificial.enchantments.api.context.EffectContext
getEnchantment, getLevel, getScaledValue, isCancellable, isCancelled, tryCancel
-
Method Details
-
getPlayer
@Nullable @Nullable org.bukkit.entity.Player getPlayer()Gets the player holding the item.- Returns:
- the player, or null for environmental item events
-
getItem
@NotNull @NotNull org.bukkit.inventory.ItemStack getItem()Gets the item being processed.- Returns:
- the item
-
getSlot
@Nullable @Nullable org.bukkit.inventory.EquipmentSlot getSlot()Gets the equipment slot where the item is held.- Returns:
- the slot, or null if not applicable
-
getLocation
@NotNull @NotNull org.bukkit.Location getLocation()Gets the location of the item.- Returns:
- the item location
-
getCurrentDurability
int getCurrentDurability()Gets the current durability of the item.- Returns:
- current durability value
-
getMaxDurability
int getMaxDurability()Gets the maximum durability of the item.- Returns:
- maximum durability value
-
getDamageTaken
int getDamageTaken()Gets the damage being taken by this item.- Returns:
- the damage amount
-
setDamageTaken
void setDamageTaken(int damage) Sets the damage to be taken by this item.- Parameters:
damage- the new damage amount
-
reduceDamage
void reduceDamage(int reduction) Reduces the damage taken by a specified amount.- Parameters:
reduction- the amount to reduce
-
willBreak
boolean willBreak()Checks if the item will break from this damage.- Returns:
- true if item will break
-
isDrop
boolean isDrop()Checks if this event is an item drop.- Returns:
- true if dropping
-
isPickup
boolean isPickup()Checks if this event is an item pickup.- Returns:
- true if picking up
-
isCraftingIngredient
boolean isCraftingIngredient()Checks if the item is being used as a crafting ingredient.- Returns:
- true if in crafting
-
isAnvilCombination
boolean isAnvilCombination()Checks if the item is being combined in an anvil.- Returns:
- true if in anvil
-