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
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 ClassesModifier and TypeClassDescriptionstatic enumRepresents the type of tool interaction.Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionToolEvent(@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 newToolEvent. -
Method Summary
Modifier and TypeMethodDescription@NotNull org.bukkit.block.BlockgetBlock()Gets the block being affected.@Nullable List<org.bukkit.inventory.ItemStack> getDrops()Gets the drops from the block.intGets the experience to drop.@Nullable org.bukkit.block.BlockFacegetFace()Gets the block face being interacted with.static @NotNull org.bukkit.event.HandlerListGets the handler list for this event type.@NotNull org.bukkit.event.HandlerList@NotNull org.bukkit.entity.PlayerGets the player using the tool.@NotNull org.bukkit.inventory.ItemStackgetTool()Gets the tool item.@NotNull ToolEvent.ToolTypeGets the tool interaction type.booleanvoidsetCancelled(boolean cancelled) voidSets the drops from the block.voidsetExpToDrop(int exp) Sets the experience to drop.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
-
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 newToolEvent.- Parameters:
enchantment- the enchantment that triggered this eventlevel- the level of the enchantmentscaledValue- the scaled value from the enchantment's scaling algorithmplayer- the player using the tooltool- the tool itemblock- the block being affectedface- the block face being interacted with, or nulltype- the tool interaction typedrops- the drops from the block, or nullexpToDrop- 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
Gets the tool interaction type.- Returns:
- the tool type
-
getDrops
Gets the drops from the block.- Returns:
- the drops, or null
-
setDrops
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:
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
-