Interface ToolContext
- All Superinterfaces:
EffectContext
Context for tool-related enchantment effects.
Provides access to player, tool, block, drops, and block action data during block break, place, and interact events.
- Since:
- 0.1.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddDrop(@NotNull org.bukkit.inventory.ItemStack item) Adds an item to the drops.@NotNull org.bukkit.block.BlockgetBlock()Gets the block being affected.@Nullable org.bukkit.block.BlockFaceGets the face of the block being hit.@Nullable List<org.bukkit.inventory.ItemStack> getDrops()Gets the list of drops from breaking the block.intGets the experience to drop from breaking the block.@NotNull org.bukkit.LocationGets the location of the affected block.@NotNull org.bukkit.entity.PlayerGets the player using the tool.@NotNull org.bukkit.inventory.ItemStackgetTool()Gets the tool item.booleanisBreak()Checks if the block is being broken.booleanChecks if this is a block interact event.booleanisPlace()Checks if a block is being placed.booleanChecks if this is a pre-break event (before block drops).booleanremoveDrop(@NotNull org.bukkit.inventory.ItemStack item) Removes an item from the drops.voidSets the drops from breaking the block.voidsetExpToDrop(int exp) Sets the experience to drop.booleanChecks if the tool will take damage.booleanChecks if items will be dropped.Methods inherited from interface io.artificial.enchantments.api.context.EffectContext
getEnchantment, getLevel, getScaledValue, isCancellable, isCancelled, tryCancel
-
Method Details
-
getPlayer
@NotNull @NotNull org.bukkit.entity.Player getPlayer()Gets the player using the tool.- Returns:
- the player
-
getTool
@NotNull @NotNull org.bukkit.inventory.ItemStack getTool()Gets the tool item.- Returns:
- the tool
-
getBlock
@NotNull @NotNull org.bukkit.block.Block getBlock()Gets the block being affected.- Returns:
- the block
-
getLocation
@NotNull @NotNull org.bukkit.Location getLocation()Gets the location of the affected block.- Returns:
- the block location
-
getBlockFace
@Nullable @Nullable org.bukkit.block.BlockFace getBlockFace()Gets the face of the block being hit.- Returns:
- the block face, or null
-
isBreak
boolean isBreak()Checks if the block is being broken.- Returns:
- true if breaking
-
isPreBreak
boolean isPreBreak()Checks if this is a pre-break event (before block drops).- Returns:
- true if pre-break
-
isPlace
boolean isPlace()Checks if a block is being placed.- Returns:
- true if placing
-
isInteract
boolean isInteract()Checks if this is a block interact event.- Returns:
- true if interacting
-
getDrops
Gets the list of drops from breaking the block.- Returns:
- the drops, or null
-
setDrops
Sets the drops from breaking the block.- Parameters:
drops- the new drops list
-
addDrop
void addDrop(@NotNull @NotNull org.bukkit.inventory.ItemStack item) Adds an item to the drops.- Parameters:
item- the item to add
-
removeDrop
boolean removeDrop(@NotNull @NotNull org.bukkit.inventory.ItemStack item) Removes an item from the drops.- Parameters:
item- the item to remove- Returns:
- true if removed
-
getExpToDrop
int getExpToDrop()Gets the experience to drop from breaking the block.- Returns:
- the experience amount
-
setExpToDrop
void setExpToDrop(int exp) Sets the experience to drop.- Parameters:
exp- the new experience amount
-
willDropItems
boolean willDropItems()Checks if items will be dropped.- Returns:
- true if dropping items
-
willDamageTool
boolean willDamageTool()Checks if the tool will take damage.- Returns:
- true if tool will be damaged
-