Class PlayerRightClickEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent

public class PlayerRightClickEvent extends org.bukkit.event.player.PlayerEvent
The PlayerRightClickEvent is our custom version of the PlayerInteractEvent. But it is only triggered on right click. The main and (almost) sole purpose of this Event is to cache the SlimefunItem of the ItemStack and/or Block involved. This allows us (and addons) to efficiently check the used SlimefunItem without the need to do a heavy lookup or item comparison.
Author:
TheBusyBiscuit
  • Constructor Details

    • PlayerRightClickEvent

      public PlayerRightClickEvent(@Nonnull org.bukkit.event.player.PlayerInteractEvent originalEvent)
      This constructs a new PlayerRightClickEvent based on the original PlayerInteractEvent. The Event.Result of the original PlayerInteractEvent will be copied.
      Parameters:
      originalEvent - The original PlayerInteractEvent
  • Method Details

    • getInteractEvent

      @Nonnull public org.bukkit.event.player.PlayerInteractEvent getInteractEvent()
      This returns the original PlayerInteractEvent that triggered this PlayerRightClickEvent.
      Returns:
      The original PlayerInteractEvent
    • getItem

      @Nonnull public org.bukkit.inventory.ItemStack getItem()
      This method returns the ItemStack that was held in the hand of the Player. It will never return null, should there be no ItemStack then it will return new ItemStack(Material.AIR).
      Returns:
      The ItemStack that the Player right clicked with
    • getHand

      @Nonnull public org.bukkit.inventory.EquipmentSlot getHand()
      This returns the hand that was used in this interaction. Can either be EquipmentSlot.HAND or EquipmentSlot.OFF_HAND.
      Returns:
      The hand used in this Event
    • getClickedBlock

      @Nonnull public Optional<org.bukkit.block.Block> getClickedBlock()
    • getClickedFace

      @Nonnull public org.bukkit.block.BlockFace getClickedFace()
    • getSlimefunItem

      @Nonnull public Optional<SlimefunItem> getSlimefunItem()
    • getSlimefunBlock

      @Nonnull public Optional<SlimefunItem> getSlimefunBlock()
    • cancel

      public void cancel()
      This method cancels the PlayerRightClickEvent. This will deny the item and block usage.
    • useItem

      @Nonnull public org.bukkit.event.Event.Result useItem()
    • useBlock

      @Nonnull public org.bukkit.event.Event.Result useBlock()
    • setUseItem

      public void setUseItem(@Nonnull org.bukkit.event.Event.Result result)
    • setUseBlock

      public void setUseBlock(@Nonnull org.bukkit.event.Event.Result result)
    • getHandlerList

      @Nonnull public static org.bukkit.event.HandlerList getHandlerList()
    • getHandlers

      @Nonnull public org.bukkit.event.HandlerList getHandlers()
      Specified by:
      getHandlers in class org.bukkit.event.Event