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
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result
-
Field Summary
Fields inherited from class org.bukkit.event.player.PlayerEvent
player
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerRightClickEvent
(org.bukkit.event.player.PlayerInteractEvent originalEvent) This constructs a newPlayerRightClickEvent
based on the originalPlayerInteractEvent
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
This method cancels thePlayerRightClickEvent
.Optional
<org.bukkit.block.Block> org.bukkit.block.BlockFace
org.bukkit.inventory.EquipmentSlot
getHand()
This returns the hand that was used in this interaction.static org.bukkit.event.HandlerList
org.bukkit.event.HandlerList
org.bukkit.event.player.PlayerInteractEvent
This returns the originalPlayerInteractEvent
that triggered thisPlayerRightClickEvent
.org.bukkit.inventory.ItemStack
getItem()
This method returns theItemStack
that was held in the hand of thePlayer
.void
setUseBlock
(org.bukkit.event.Event.Result result) void
setUseItem
(org.bukkit.event.Event.Result result) org.bukkit.event.Event.Result
useBlock()
org.bukkit.event.Event.Result
useItem()
Methods inherited from class org.bukkit.event.player.PlayerEvent
getPlayer
Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
PlayerRightClickEvent
public PlayerRightClickEvent(@Nonnull org.bukkit.event.player.PlayerInteractEvent originalEvent) This constructs a newPlayerRightClickEvent
based on the originalPlayerInteractEvent
. TheEvent.Result
of the originalPlayerInteractEvent
will be copied.- Parameters:
originalEvent
- The originalPlayerInteractEvent
-
-
Method Details
-
getInteractEvent
@Nonnull public org.bukkit.event.player.PlayerInteractEvent getInteractEvent()This returns the originalPlayerInteractEvent
that triggered thisPlayerRightClickEvent
.- Returns:
- The original
PlayerInteractEvent
-
getItem
@Nonnull public org.bukkit.inventory.ItemStack getItem()This method returns theItemStack
that was held in the hand of thePlayer
. It will never return null, should there be noItemStack
then it will returnnew ItemStack(Material.AIR)
.- Returns:
- The
ItemStack
that thePlayer
right clicked with
-
getHand
@Nonnull public org.bukkit.inventory.EquipmentSlot getHand()This returns the hand that was used in this interaction. Can either beEquipmentSlot.HAND
orEquipmentSlot.OFF_HAND
.- Returns:
- The hand used in this
Event
-
getClickedBlock
-
getClickedFace
@Nonnull public org.bukkit.block.BlockFace getClickedFace() -
getSlimefunItem
-
getSlimefunBlock
-
cancel
public void cancel()This method cancels thePlayerRightClickEvent
. 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 classorg.bukkit.event.Event
-