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 newPlayerRightClickEventbased on the originalPlayerInteractEvent. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()This method cancels thePlayerRightClickEvent.Optional<org.bukkit.block.Block> org.bukkit.block.BlockFaceorg.bukkit.inventory.EquipmentSlotgetHand()This returns the hand that was used in this interaction.static org.bukkit.event.HandlerListorg.bukkit.event.HandlerListorg.bukkit.event.player.PlayerInteractEventThis returns the originalPlayerInteractEventthat triggered thisPlayerRightClickEvent.org.bukkit.inventory.ItemStackgetItem()This method returns theItemStackthat was held in the hand of thePlayer.voidsetUseBlock(org.bukkit.event.Event.Result result) voidsetUseItem(org.bukkit.event.Event.Result result) org.bukkit.event.Event.ResultuseBlock()org.bukkit.event.Event.ResultuseItem()Methods inherited from class org.bukkit.event.player.PlayerEvent
getPlayerMethods 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 newPlayerRightClickEventbased on the originalPlayerInteractEvent. TheEvent.Resultof the originalPlayerInteractEventwill be copied.- Parameters:
originalEvent- The originalPlayerInteractEvent
-
-
Method Details
-
getInteractEvent
@Nonnull public org.bukkit.event.player.PlayerInteractEvent getInteractEvent()This returns the originalPlayerInteractEventthat triggered thisPlayerRightClickEvent.- Returns:
- The original
PlayerInteractEvent
-
getItem
@Nonnull public org.bukkit.inventory.ItemStack getItem()This method returns theItemStackthat was held in the hand of thePlayer. It will never return null, should there be noItemStackthen it will returnnew ItemStack(Material.AIR).- Returns:
- The
ItemStackthat thePlayerright clicked with
-
getHand
@Nonnull public org.bukkit.inventory.EquipmentSlot getHand()This returns the hand that was used in this interaction. Can either beEquipmentSlot.HANDorEquipmentSlot.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:
getHandlersin classorg.bukkit.event.Event
-