Interface ToolContext

All Superinterfaces:
EffectContext

public interface ToolContext extends 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 Type
    Method
    Description
    void
    addDrop(@NotNull org.bukkit.inventory.ItemStack item)
    Adds an item to the drops.
    @NotNull org.bukkit.block.Block
    Gets the block being affected.
    @Nullable org.bukkit.block.BlockFace
    Gets the face of the block being hit.
    @Nullable List<org.bukkit.inventory.ItemStack>
    Gets the list of drops from breaking the block.
    int
    Gets the experience to drop from breaking the block.
    @NotNull org.bukkit.Location
    Gets the location of the affected block.
    @NotNull org.bukkit.entity.Player
    Gets the player using the tool.
    @NotNull org.bukkit.inventory.ItemStack
    Gets the tool item.
    boolean
    Checks if the block is being broken.
    boolean
    Checks if this is a block interact event.
    boolean
    Checks if a block is being placed.
    boolean
    Checks if this is a pre-break event (before block drops).
    boolean
    removeDrop(@NotNull org.bukkit.inventory.ItemStack item)
    Removes an item from the drops.
    void
    setDrops(@Nullable List<org.bukkit.inventory.ItemStack> drops)
    Sets the drops from breaking the block.
    void
    setExpToDrop(int exp)
    Sets the experience to drop.
    boolean
    Checks if the tool will take damage.
    boolean
    Checks 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

      @Nullable @Nullable List<org.bukkit.inventory.ItemStack> getDrops()
      Gets the list of drops from breaking the block.
      Returns:
      the drops, or null
    • setDrops

      void setDrops(@Nullable @Nullable List<org.bukkit.inventory.ItemStack> drops)
      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