Package dev.polv.taleapi.event.block
Interface BlockBreakCallback
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Called when a player attempts to break a block.
This event is cancellable. If cancelled, the block will not be broken.
Example Usage
BlockBreakCallback.EVENT.register((player, block, location) -> {
System.out.println(player.getDisplayName() + " broke " + block.getId());
return EventResult.PASS;
});
// Prevent breaking blocks in a protected area
BlockBreakCallback.EVENT.register(EventPriority.HIGH, (player, block, location) -> {
if (isProtectedArea(location)) {
player.sendMessage("This area is protected!");
return EventResult.CANCEL;
}
return EventResult.PASS;
});
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiononBlockBreak(TalePlayer player, TaleBlock block, Location location) Called when a player is about to break a block.
-
Field Details
-
EVENT
The event instance. Use this to register listeners and fire the event.
-
-
Method Details
-
onBlockBreak
Called when a player is about to break a block.- Parameters:
player- the player breaking the blockblock- the block being brokenlocation- the location of the block- Returns:
- the event result -
EventResult.CANCELto prevent the block from being broken
-