Class ToolEvent

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

public class ToolEvent extends EnchantEffectEvent implements org.bukkit.event.Cancellable
Event fired when a tool-related enchantment effect triggers.

Carries data about the player, tool, block, and drops during block break, block place, or block interact events. This event is cancellable.

Since:
0.1.0
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Represents the type of tool interaction.

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

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

    Constructors
    Constructor
    Description
    ToolEvent(@NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull org.bukkit.entity.Player player, @NotNull org.bukkit.inventory.ItemStack tool, @NotNull org.bukkit.block.Block block, @Nullable org.bukkit.block.BlockFace face, @NotNull ToolEvent.ToolType type, @Nullable List<org.bukkit.inventory.ItemStack> drops, int expToDrop)
    Creates a new ToolEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull org.bukkit.block.Block
    Gets the block being affected.
    @Nullable List<org.bukkit.inventory.ItemStack>
    Gets the drops from the block.
    int
    Gets the experience to drop.
    @Nullable org.bukkit.block.BlockFace
    Gets the block face being interacted with.
    static @NotNull org.bukkit.event.HandlerList
    Gets the handler list for this event type.
    @NotNull org.bukkit.event.HandlerList
     
    @NotNull org.bukkit.entity.Player
    Gets the player using the tool.
    @NotNull org.bukkit.inventory.ItemStack
    Gets the tool item.
    Gets the tool interaction type.
    boolean
     
    void
    setCancelled(boolean cancelled)
     
    void
    setDrops(@Nullable List<org.bukkit.inventory.ItemStack> drops)
    Sets the drops from the block.
    void
    setExpToDrop(int exp)
    Sets the experience to drop.

    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

    • ToolEvent

      public ToolEvent(@NotNull @NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.inventory.ItemStack tool, @NotNull @NotNull org.bukkit.block.Block block, @Nullable @Nullable org.bukkit.block.BlockFace face, @NotNull @NotNull ToolEvent.ToolType type, @Nullable @Nullable List<org.bukkit.inventory.ItemStack> drops, int expToDrop)
      Creates a new ToolEvent.
      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 using the tool
      tool - the tool item
      block - the block being affected
      face - the block face being interacted with, or null
      type - the tool interaction type
      drops - the drops from the block, or null
      expToDrop - the experience to drop
  • Method Details

    • getPlayer

      @NotNull public @NotNull org.bukkit.entity.Player getPlayer()
      Gets the player using the tool.
      Returns:
      the player
    • getTool

      @NotNull public @NotNull org.bukkit.inventory.ItemStack getTool()
      Gets the tool item.
      Returns:
      the tool
    • getBlock

      @NotNull public @NotNull org.bukkit.block.Block getBlock()
      Gets the block being affected.
      Returns:
      the block
    • getFace

      @Nullable public @Nullable org.bukkit.block.BlockFace getFace()
      Gets the block face being interacted with.
      Returns:
      the block face, or null
    • getToolType

      @NotNull public @NotNull ToolEvent.ToolType getToolType()
      Gets the tool interaction type.
      Returns:
      the tool type
    • getDrops

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

      public void setDrops(@Nullable @Nullable List<org.bukkit.inventory.ItemStack> drops)
      Sets the drops from the block.
      Parameters:
      drops - the new drops, or null
    • getExpToDrop

      public int getExpToDrop()
      Gets the experience to drop.
      Returns:
      the experience value
    • setExpToDrop

      public void setExpToDrop(int exp)
      Sets the experience to drop.
      Parameters:
      exp - the new experience value (clamped to non-negative)
    • 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