Class PlayerUseSpecialItemEvent
java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
de.marcely.bedwars.api.event.player.PlayerUseSpecialItemEvent
- All Implemented Interfaces:
ArenaEvent,Cancellable
Gets called when a player is using a special item while he's in a game
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result -
Field Summary
Fields inherited from class org.bukkit.event.player.PlayerEvent
player -
Constructor Summary
ConstructorsConstructorDescriptionPlayerUseSpecialItemEvent(Player player, SpecialItem specialItem, Arena arena, ItemStack item, boolean isOffHand, @Nullable Block clickedBlock, @Nullable BlockFace clickedBlockFace, boolean takeItem) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSessionListener(Consumer<SpecialItemUseSession> callback) Adds a listener that gets called once the session has been initiated.getArena()Returns the arena in which the player has used the item.@Nullable BlockReturns the block on which the player clicked.@Nullable BlockFaceReturns the block face on which the player clicked.static HandlerListintReturns the inventory slot in which the item is located.getItem()Returns the item with which the player interacted.Returns the listeners that will be called once the session has been initiated.Returns the special item that the player has used.booleanReturns whether the plugin will accept the handling of the natural behaviour of whatever would actually happen.booleanReturns whether the player used the item in his off-hand.booleanReturns whether the item will be taken from the players inventory.voidsetNaturalInteractionCancelled(boolean newState) Set whether the plugin should accept the handling of the natural behaviour of whatever would actually happen.voidsetTakingItem(boolean takeItem) Set whether the item should be taken away from the player.Methods inherited from class org.bukkit.event.player.PlayerEvent
getPlayerMethods inherited from class org.bukkit.event.Event
getEventName, isAsynchronousMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bukkit.event.Cancellable
isCancelled, setCancelled
-
Constructor Details
-
PlayerUseSpecialItemEvent
-
-
Method Details
-
getSpecialItem
Returns the special item that the player has used.- Returns:
- The special item that has been used
-
getArena
Returns the arena in which the player has used the item.- Specified by:
getArenain interfaceArenaEvent- Returns:
- The arena involved in this
-
getItem
Returns the item with which the player interacted.- Returns:
- The item that the player right-clicked
-
isOffHand
public boolean isOffHand()Returns whether the player used the item in his off-hand.This method always returns false on 1.8.8, as off-hand got added with 1.9.
- Returns:
- If the player used the item in his off-hand
-
getClickedBlock
Returns the block on which the player clicked.Can be
nullwhen the player used the item while looking to the sky or at an hologram.- Returns:
- The block that has been clicked
-
getClickedBlockFace
Returns the block face on which the player clicked.Can be
nullwhen the player used the item while looking to the sky or at an hologram.- Returns:
- The block face on which he clicked
-
isTakingItem
public boolean isTakingItem()Returns whether the item will be taken from the players inventory.- Returns:
- If the item will be taken away
-
setTakingItem
public void setTakingItem(boolean takeItem) Set whether the item should be taken away from the player.- Parameters:
takeItem- If the item shall be taken away
-
isNaturalInteractionCancelled
public boolean isNaturalInteractionCancelled()Returns whether the plugin will accept the handling of the natural behaviour of whatever would actually happen.For instance, when holding a block, the player would (possibly) place the block. By default, the plugin returns
trueunless it has been changed usingsetNaturalInteractionCancelled(boolean).- Returns:
- If the natural behaviour of the interaction will be processed
-
setNaturalInteractionCancelled
public void setNaturalInteractionCancelled(boolean newState) Set whether the plugin should accept the handling of the natural behaviour of whatever would actually happen.For instance, when holding a block, the player would (possibly) place the block. By default, the plugin has set it to
true.- Parameters:
newState- If the natural behaviour of the interaction shall be processed
-
getInventorySlot
public int getInventorySlot()Returns the inventory slot in which the item is located.- Returns:
- The inventory slot of the item
-
addSessionListener
Adds a listener that gets called once the session has been initiated.The initiation occurs immediately after processing this event-loop. It might not occur at all if this event is cancelled or an error occurs during initiation.
- Parameters:
callback- The callback that gets called once the session has been initiated
-
getSessionListeners
Returns the listeners that will be called once the session has been initiated.- Returns:
- The listeners that will be called once the session has been initiated
- See Also:
-
getHandlers
- Specified by:
getHandlersin classEvent
-
getHandlerList
-