Package org.bukkit.event.block
Class BlockDropItemEvent
java.lang.Object
org.bukkit.event.Event
org.bukkit.event.block.BlockEvent
org.bukkit.event.block.BlockDropItemEvent
- All Implemented Interfaces:
Cancellable
Called after a block is broken by a player and potential drops are computed, even if said blocks loot table
does not define any drops at the point the event is constructed.
If the block break is cancelled, this event won't be called.
If isDropItems in
BlockBreakEvent
is set to false, this event won't be
called.
If a block is broken and isDropItems is set to true, this event will be called even if the block does
not drop any items, for example glass broken by hand. In this case, #getItems() will be empty.
This event will also be called if the player breaks a multi block structure,
for example a torch on top of a stone. Both items will be included in the #getItems() list.
The Block is already broken as this event is called, so #getBlock() will be
AIR in most cases. Use #getBlockState() for more Information about the broken
block.-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result
-
Field Summary
Fields inherited from class org.bukkit.event.block.BlockEvent
block
-
Constructor Summary
ConstructorDescriptionBlockDropItemEvent
(@NotNull Block block, @NotNull BlockState blockState, @NotNull Player player, @NotNull List<Item> items) -
Method Summary
Modifier and TypeMethodDescriptionGets the BlockState of the block involved in this event before it was broken.static @NotNull HandlerList
getItems()
Gets list of the Item drops caused by the block break.Gets the Player that is breaking the block involved in this event.boolean
Gets the cancellation state of this event.void
setCancelled
(boolean cancel) Sets the cancellation state of this event.Methods inherited from class org.bukkit.event.block.BlockEvent
getBlock
Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
BlockDropItemEvent
-
-
Method Details
-
getPlayer
Gets the Player that is breaking the block involved in this event.- Returns:
- The Player that is breaking the block involved in this event
-
getBlockState
Gets the BlockState of the block involved in this event before it was broken.- Returns:
- The BlockState of the block involved in this event
-
getItems
Gets list of the Item drops caused by the block break. This list is mutable - removing an item from it will cause it to not drop. Adding to the list is allowed.- Returns:
- The Item the block caused to drop
-
isCancelled
public boolean isCancelled()Description copied from interface:Cancellable
Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins- Specified by:
isCancelled
in interfaceCancellable
- Returns:
- true if this event is cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:Cancellable
Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.- Specified by:
setCancelled
in interfaceCancellable
- Parameters:
cancel
- true if you wish to cancel this event
-
getHandlers
- Specified by:
getHandlers
in classEvent
-
getHandlerList
-