Package org.bukkit.event.block

# Class BlockPlaceEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.block.BlockEvent
org.bukkit.event.block.BlockPlaceEvent

All Implemented Interfaces:
  `Cancellable`

Direct Known Subclasses:
  `BlockMultiPlaceEvent`

public class BlockPlaceEvent extends BlockEvent implements Cancellable
Called when a block is placed by a player.

If a Block Place event is cancelled, the block will not be placed.

## Nested Class Summary

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

`Event.Result`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected boolean`
`canBuild`
`protected boolean`
`cancel`
`protected EquipmentSlot`
`hand`
`protected ItemStack`
`itemInHand`
`protected Block`
`placedAgainst`
`protected Player`
`player`
`protected BlockState`
`replacedBlockState`

### Fields inherited from class org.bukkit.event.block.BlockEvent

`block`

## Constructor Summary

Constructors
Constructor
Description
`BlockPlaceEvent(@NotNull Block placedBlock, @NotNull BlockState replacedBlockState, @NotNull Block placedAgainst, @NotNull ItemStack itemInHand, @NotNull Player thePlayer, boolean canBuild)`
Deprecated.
`BlockPlaceEvent(@NotNull Block placedBlock, @NotNull BlockState replacedBlockState, @NotNull Block placedAgainst, @NotNull ItemStack itemInHand, @NotNull Player thePlayer, boolean canBuild, @NotNull EquipmentSlot hand)`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`canBuild()`
Gets the value whether the player would be allowed to build here.
`@NotNull Block`
`getBlockAgainst()`
Gets the block that this block was placed against
`@NotNull Block`
`getBlockPlaced()`
Clarity method for getting the placed block.
`@NotNull BlockState`
`getBlockReplacedState()`
Gets the BlockState for the block which was replaced.
`@NotNull EquipmentSlot`
`getHand()`
Gets the hand which placed the block
`static @NotNull HandlerList`
`getHandlerList()`
`@NotNull HandlerList`
`getHandlers()`
`@NotNull ItemStack`
`getItemInHand()`
Gets the item in the player's hand when they placed the block.
`@NotNull Player`
`getPlayer()`
Gets the player who placed the block involved in this event.
`boolean`
`isCancelled()`
Gets the cancellation state of this event.
`void`
`setBuild(boolean canBuild)`
Sets the canBuild state of this event.
`void`
`setCancelled(boolean cancel)`
Sets the cancellation state of this event.

### Methods inherited from class org.bukkit.event.block.BlockEvent

`getBlock`

### Methods inherited from class org.bukkit.event.Event

`callEvent, getEventName, isAsynchronous`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### cancel

protected boolean cancel

### canBuild

protected boolean canBuild

### placedAgainst

protected Block placedAgainst

### replacedBlockState

protected BlockState replacedBlockState

### itemInHand

protected ItemStack itemInHand

### player

protected Player player

### hand

protected EquipmentSlot hand

## Constructor Details

### BlockPlaceEvent

@Deprecated public BlockPlaceEvent(@NotNull @NotNull Block placedBlock, @NotNull @NotNull BlockState replacedBlockState, @NotNull @NotNull Block placedAgainst, @NotNull @NotNull ItemStack itemInHand, @NotNull @NotNull Player thePlayer, boolean canBuild)
Deprecated.

### BlockPlaceEvent

public BlockPlaceEvent(@NotNull @NotNull Block placedBlock, @NotNull @NotNull BlockState replacedBlockState, @NotNull @NotNull Block placedAgainst, @NotNull @NotNull ItemStack itemInHand, @NotNull @NotNull Player thePlayer, boolean canBuild, @NotNull @NotNull EquipmentSlot hand)

## Method Details

### isCancelled

public boolean isCancelled()
Description copied from interface: `Cancellable`
Gets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins

Specified by:
  `isCancelled` in interface `Cancellable`
Returns:
  true if this event is cancelled

### setCancelled

public void setCancelled(boolean cancel)
Description copied from interface: `Cancellable`
Sets the cancellation state of this event. A cancelled event will not be executed in the server, but will still pass to other plugins.

Specified by:
  `setCancelled` in interface `Cancellable`
Parameters:
  `cancel` - true if you wish to cancel this event

### getPlayer

@NotNull public @NotNull Player getPlayer()
Gets the player who placed the block involved in this event.

Returns:
  The Player who placed the block involved in this event

### getBlockPlaced

@NotNull public @NotNull Block getBlockPlaced()
Clarity method for getting the placed block. Not really needed except for reasons of clarity.

Returns:
  The Block that was placed

### getBlockReplacedState

@NotNull public @NotNull BlockState getBlockReplacedState()
Gets the BlockState for the block which was replaced. Material type air mostly.

Returns:
  The BlockState for the block which was replaced.

### getBlockAgainst

@NotNull public @NotNull Block getBlockAgainst()
Gets the block that this block was placed against

Returns:
  Block the block that the new block was placed against

### getItemInHand

@NotNull public @NotNull ItemStack getItemInHand()
Gets the item in the player's hand when they placed the block.

Returns:
  The ItemStack for the item in the player's hand when they placed the block

### getHand

@NotNull public @NotNull EquipmentSlot getHand()
Gets the hand which placed the block

Returns:
  Main or off-hand, depending on which hand was used to place the block

### canBuild

public boolean canBuild()
Gets the value whether the player would be allowed to build here. Defaults to spawn if the server was going to stop them (such as, the player is in Spawn). Note that this is an entirely different check than BLOCK_CANBUILD, as this refers to a player, not universe-physics rule like cactus on dirt.

Returns:
  boolean whether the server would allow a player to build here

### setBuild

public void setBuild(boolean canBuild)
Sets the canBuild state of this event. Set to true if you want the player to be able to build.

Parameters:
  `canBuild` - true if you want the player to be able to build

### getHandlers

@NotNull public @NotNull HandlerList getHandlers()

Specified by:
  `getHandlers` in class `Event`

### getHandlerList

@NotNull public static @NotNull HandlerList getHandlerList()