Class BlockBrokenEvent

java.lang.Object
org.bukkit.event.Event
com.github.darksoulq.abyssallib.server.event.custom.block.BlockBrokenEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public class BlockBrokenEvent extends org.bukkit.event.Event implements org.bukkit.event.Cancellable
An event that is called when a custom block is broken by a player. This event is Cancellable, meaning the block break can be prevented by a plugin. It provides control over loot drop logic and access to environmental data like fortune levels.
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Constructor Summary

    Constructors
    Constructor
    Description
    BlockBrokenEvent(@Nullable org.bukkit.entity.Player player, @NotNull CustomBlock block, int fortuneLevel)
    Constructs a new BlockBrokenEvent with player, block, and enchantment data.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if the internal API is currently configured to handle block drops.
    @NotNull CustomBlock
    Retrieves the custom block involved in this break event.
    int
    Retrieves the detected Fortune level applied to the block break calculation.
    static org.bukkit.event.HandlerList
    Provides a static method to retrieve the handler list, required by Bukkit.
    @NotNull org.bukkit.event.HandlerList
    Retrieves the set of handlers listening to this event instance.
    List<org.bukkit.inventory.ItemStack>
    Retrieves the list of custom items to be dropped if base drops are disabled.
    @Nullable org.bukkit.entity.Player
    Retrieves the player responsible for breaking the block.
    boolean
    Checks whether the block break event has been cancelled by a listener.
    void
    setBaseDrops(boolean shouldDrop)
    Sets whether the internal API should proceed with its default loot table logic.
    void
    setCancelled(boolean cancel)
    Sets the cancellation status of the block break.
    void
    setDrops(List<org.bukkit.inventory.ItemStack> drops)
    Defines a specific list of items to drop instead of the default API loot.

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, isAsynchronous

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BlockBrokenEvent

      public BlockBrokenEvent(@Nullable @Nullable org.bukkit.entity.Player player, @NotNull @NotNull CustomBlock block, int fortuneLevel)
      Constructs a new BlockBrokenEvent with player, block, and enchantment data.
      Parameters:
      player - The player breaking the block, or null if broken by other means.
      block - The CustomBlock instance being broken.
      fortuneLevel - The level of the Fortune enchantment detected on the item used.
  • Method Details

    • getBlock

      @NotNull public @NotNull CustomBlock getBlock()
      Retrieves the custom block involved in this break event.
      Returns:
      The non-null CustomBlock involved in the event.
    • getPlayer

      @Nullable public @Nullable org.bukkit.entity.Player getPlayer()
      Retrieves the player responsible for breaking the block.
      Returns:
      The Player instance, or null.
    • setBaseDrops

      public void setBaseDrops(boolean shouldDrop)
      Sets whether the internal API should proceed with its default loot table logic.
      Parameters:
      shouldDrop - True to use default API drops, false to override with custom drops.
    • getBaseDrops

      public boolean getBaseDrops()
      Checks if the internal API is currently configured to handle block drops.
      Returns:
      True if the API handles drops, false otherwise.
    • setDrops

      public void setDrops(List<org.bukkit.inventory.ItemStack> drops)
      Defines a specific list of items to drop instead of the default API loot.
      Parameters:
      drops - The List of ItemStack objects to drop.
    • getNewDrops

      public List<org.bukkit.inventory.ItemStack> getNewDrops()
      Retrieves the list of custom items to be dropped if base drops are disabled.
      Returns:
      A list of ItemStack objects, or null if none are set.
    • getFortuneLevel

      public int getFortuneLevel()
      Retrieves the detected Fortune level applied to the block break calculation.
      Returns:
      The integer level of the Fortune enchantment.
    • isCancelled

      public boolean isCancelled()
      Checks whether the block break event has been cancelled by a listener.
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
      Returns:
      True if cancelled, false otherwise.
    • setCancelled

      public void setCancelled(boolean cancel)
      Sets the cancellation status of the block break.
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
      Parameters:
      cancel - True to prevent the block from breaking, false to allow it.
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Retrieves the set of handlers listening to this event instance.
      Specified by:
      getHandlers in class org.bukkit.event.Event
      Returns:
      The HandlerList for this event.
    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()
      Provides a static method to retrieve the handler list, required by Bukkit.
      Returns:
      The static HandlerList for this event type.