Class BlockDropItemEvent

  • All Implemented Interfaces:
    Cancellable

    public class BlockDropItemEvent
    extends BlockEvent
    implements Cancellable
    Called if a block broken by a player drops an item. 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. 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 have an event call. 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.
    • Constructor Detail

      • BlockDropItemEvent

        public BlockDropItemEvent​(@NotNull
                                  Block block,
                                  @NotNull
                                  BlockState blockState,
                                  @NotNull
                                  Player player,
                                  @NotNull
                                  List<Item> items)
    • Method Detail

      • getPlayer

        @NotNull
        public Player 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

        @NotNull
        public BlockState 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

        @NotNull
        public List<Item> 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. It is not legal however to add new items to the list.
        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 interface Cancellable
        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 interface Cancellable
        Parameters:
        cancel - true if you wish to cancel this event
      • getHandlerList

        @NotNull
        public static HandlerList getHandlerList()