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
-
Field Summary
Fields Modifier and Type Field Description protected booleancanBuildprotected booleancancelprotected ItemStackitemInHandprotected BlockplacedAgainstprotected Playerplayerprotected BlockStatereplacedBlockState -
Constructor Summary
Constructors Constructor Description BlockPlaceEvent(Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild) -
Method Summary
Modifier and Type Method Description booleancanBuild()Gets the value whether the player would be allowed to build here.BlockgetBlockAgainst()Gets the block that this block was placed againstBlockgetBlockPlaced()Clarity method for getting the placed block.BlockStategetBlockReplacedState()Gets the BlockState for the block which was replaced.static HandlerListgetHandlerList()HandlerListgetHandlers()ItemStackgetItemInHand()Gets the item in the player's hand when they placed the block.PlayergetPlayer()Gets the player who placed the block involved in this event.booleanisCancelled()Gets the cancellation state of this event.voidsetBuild(boolean canBuild)Sets the canBuild state of this event.voidsetCancelled(boolean cancel)Sets the cancellation state of this event.
-
Field Details
-
cancel
protected boolean cancel -
canBuild
protected boolean canBuild -
placedAgainst
-
replacedBlockState
-
itemInHand
-
player
-
-
Constructor Details
-
BlockPlaceEvent
public BlockPlaceEvent(Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild)
-
-
Method Details
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableGets 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:
isCancelledin interfaceCancellable- Returns:
- true if this event is cancelled
-
setCancelled
public void setCancelled(boolean cancel)Description copied from interface:CancellableSets 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:
setCancelledin interfaceCancellable- Parameters:
cancel- true if you wish to cancel this event
-
getPlayer
Gets the player who placed the block involved in this event.- Returns:
- The Player who placed the block involved in this event
-
getBlockPlaced
Clarity method for getting the placed block. Not really needed except for reasons of clarity.- Returns:
- The Block that was placed
-
getBlockReplacedState
Gets the BlockState for the block which was replaced. Material type air mostly.- Returns:
- The BlockState for the block which was replaced.
-
getBlockAgainst
Gets the block that this block was placed against- Returns:
- Block the block that the new block was placed against
-
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
-
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
- Specified by:
getHandlersin classEvent
-
getHandlerList
-