Class InteractionEvent

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

public class InteractionEvent extends EnchantEffectEvent implements org.bukkit.event.Cancellable
Event fired when an interaction-related enchantment effect triggers.

Carries data about the player, item, block, and entity during player interaction events (left click, right click). This event is cancellable.

Since:
0.1.0
See Also:
  • Nested Class Summary

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

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

    Constructors
    Constructor
    Description
    InteractionEvent(@NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull org.bukkit.entity.Player player, @Nullable org.bukkit.inventory.ItemStack item, @NotNull org.bukkit.inventory.EquipmentSlot hand, @NotNull org.bukkit.Location location, @Nullable org.bukkit.block.Block block, @Nullable org.bukkit.block.BlockFace blockFace, @Nullable org.bukkit.entity.Entity targetEntity, boolean isLeftClick, boolean isRightClick, @Nullable org.bukkit.util.Vector interactionPoint)
    Creates a new InteractionEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable org.bukkit.block.Block
    Gets the block interacted with.
    @Nullable org.bukkit.block.BlockFace
    Gets the block face clicked.
    @NotNull org.bukkit.inventory.EquipmentSlot
    Gets the hand used.
    static @NotNull org.bukkit.event.HandlerList
    Gets the handler list for this event type.
    @NotNull org.bukkit.event.HandlerList
     
    @Nullable org.bukkit.util.Vector
    Gets the precise interaction point.
    @Nullable org.bukkit.inventory.ItemStack
    Gets the item used.
    @NotNull org.bukkit.Location
    Gets the interaction location.
    @NotNull org.bukkit.entity.Player
    Gets the player interacting.
    @Nullable org.bukkit.entity.Entity
    Gets the entity clicked.
    boolean
    Checks if this is a block interaction.
    boolean
     
    boolean
    Checks if this is an entity interaction.
    boolean
    Checks if this is a left click.
    boolean
    Checks if this is a right click.
    boolean
    Checks if the player is sneaking.
    void
    setCancelled(boolean cancelled)
     

    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

    • InteractionEvent

      public InteractionEvent(@NotNull @NotNull EnchantmentDefinition enchantment, int level, double scaledValue, @NotNull @NotNull org.bukkit.entity.Player player, @Nullable @Nullable org.bukkit.inventory.ItemStack item, @NotNull @NotNull org.bukkit.inventory.EquipmentSlot hand, @NotNull @NotNull org.bukkit.Location location, @Nullable @Nullable org.bukkit.block.Block block, @Nullable @Nullable org.bukkit.block.BlockFace blockFace, @Nullable @Nullable org.bukkit.entity.Entity targetEntity, boolean isLeftClick, boolean isRightClick, @Nullable @Nullable org.bukkit.util.Vector interactionPoint)
      Creates a new InteractionEvent.
      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 interacting
      item - the item used, or null
      hand - the hand used
      location - the interaction location
      block - the block interacted with, or null
      blockFace - the block face clicked, or null
      targetEntity - the entity clicked, or null
      isLeftClick - true if left click
      isRightClick - true if right click
      interactionPoint - the precise interaction point, or null
  • Method Details

    • getPlayer

      @NotNull public @NotNull org.bukkit.entity.Player getPlayer()
      Gets the player interacting.
      Returns:
      the player
    • getItem

      @Nullable public @Nullable org.bukkit.inventory.ItemStack getItem()
      Gets the item used.
      Returns:
      the item, or null
    • getHand

      @NotNull public @NotNull org.bukkit.inventory.EquipmentSlot getHand()
      Gets the hand used.
      Returns:
      the hand
    • getLocation

      @NotNull public @NotNull org.bukkit.Location getLocation()
      Gets the interaction location.
      Returns:
      the location
    • getBlock

      @Nullable public @Nullable org.bukkit.block.Block getBlock()
      Gets the block interacted with.
      Returns:
      the block, or null
    • getBlockFace

      @Nullable public @Nullable org.bukkit.block.BlockFace getBlockFace()
      Gets the block face clicked.
      Returns:
      the block face, or null
    • getTargetEntity

      @Nullable public @Nullable org.bukkit.entity.Entity getTargetEntity()
      Gets the entity clicked.
      Returns:
      the target entity, or null
    • isLeftClick

      public boolean isLeftClick()
      Checks if this is a left click.
      Returns:
      true if left click
    • isRightClick

      public boolean isRightClick()
      Checks if this is a right click.
      Returns:
      true if right click
    • isBlockInteraction

      public boolean isBlockInteraction()
      Checks if this is a block interaction.
      Returns:
      true if block was clicked
    • isEntityInteraction

      public boolean isEntityInteraction()
      Checks if this is an entity interaction.
      Returns:
      true if entity was clicked
    • isSneaking

      public boolean isSneaking()
      Checks if the player is sneaking.
      Returns:
      true if sneaking
    • getInteractionPoint

      @Nullable public @Nullable org.bukkit.util.Vector getInteractionPoint()
      Gets the precise interaction point.
      Returns:
      the interaction point, or null
    • 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