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
ConstructorsConstructorDescriptionBlockBrokenEvent(@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 TypeMethodDescriptionbooleanChecks if the internal API is currently configured to handle block drops.@NotNull CustomBlockgetBlock()Retrieves the custom block involved in this break event.intRetrieves the detected Fortune level applied to the block break calculation.static org.bukkit.event.HandlerListProvides a static method to retrieve the handler list, required by Bukkit.@NotNull org.bukkit.event.HandlerListRetrieves 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.PlayerRetrieves the player responsible for breaking the block.booleanChecks whether the block break event has been cancelled by a listener.voidsetBaseDrops(boolean shouldDrop) Sets whether the internal API should proceed with its default loot table logic.voidsetCancelled(boolean cancel) Sets the cancellation status of the block break.voidDefines a specific list of items to drop instead of the default API loot.Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
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- TheCustomBlockinstance being broken.fortuneLevel- The level of the Fortune enchantment detected on the item used.
-
-
Method Details
-
getBlock
Retrieves the custom block involved in this break event.- Returns:
- The non-null
CustomBlockinvolved in the event.
-
getPlayer
@Nullable public @Nullable org.bukkit.entity.Player getPlayer()Retrieves the player responsible for breaking the block.- Returns:
- The
Playerinstance, 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
-
getNewDrops
Retrieves the list of custom items to be dropped if base drops are disabled.- Returns:
- A list of
ItemStackobjects, 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:
isCancelledin interfaceorg.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:
setCancelledin interfaceorg.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:
getHandlersin classorg.bukkit.event.Event- Returns:
- The
HandlerListfor 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
HandlerListfor this event type.
-