Package dev.polv.taleapi.event.block
Interface BlockPlaceCallback
- 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 place a block.
This event is cancellable. If cancelled, the block will not be placed.
Example Usage
BlockPlaceCallback.EVENT.register((player, block, location) -> {
System.out.println(player.getDisplayName() + " placed " + block.getId());
return EventResult.PASS;
});
// Prevent placing blocks in a protected area
BlockPlaceCallback.EVENT.register(EventPriority.HIGH, (player, block, location) -> {
if (isProtectedArea(location)) {
player.sendMessage("You cannot build here!");
return EventResult.CANCEL;
}
return EventResult.PASS;
});
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiononBlockPlace(TalePlayer player, TaleBlock block, Location location) Called when a player is about to place a block.
-
Field Details
-
EVENT
The event instance. Use this to register listeners and fire the event.
-
-
Method Details
-
onBlockPlace
Called when a player is about to place a block.- Parameters:
player- the player placing the blockblock- the block being placedlocation- the location where the block will be placed- Returns:
- the event result -
EventResult.CANCELto prevent the block from being placed
-