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.

@FunctionalInterface public interface BlockPlaceCallback
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 Details

    • EVENT

      static final Event<BlockPlaceCallback> EVENT
      The event instance. Use this to register listeners and fire the event.
  • Method Details

    • onBlockPlace

      EventResult onBlockPlace(TalePlayer player, TaleBlock block, Location location)
      Called when a player is about to place a block.
      Parameters:
      player - the player placing the block
      block - the block being placed
      location - the location where the block will be placed
      Returns:
      the event result - EventResult.CANCEL to prevent the block from being placed