Class BlockCanBuildEvent
java.lang.Object
org.bukkit.event.Event
org.bukkit.event.block.BlockEvent
org.bukkit.event.block.BlockCanBuildEvent
Called when we try to place a block, to see if we can build it here or not.
Note:
- The Block returned by getBlock() is the block we are trying to place on, not the block we are trying to place.
- If you want to figure out what is being placed, use
getMaterial()instead.
-
Nested Class Summary
Nested classes/interfaces inherited from class Event
Event.Result -
Field Summary
FieldsFields inherited from class BlockEvent
block -
Constructor Summary
ConstructorsConstructorDescriptionBlockCanBuildEvent(@NotNull Block block, @NotNull BlockData type, boolean canBuild) Deprecated, for removal: This API element is subject to removal in a future version.BlockCanBuildEvent(@NotNull Block block, @Nullable Player player, @NotNull BlockData type, boolean canBuild) Deprecated, for removal: This API element is subject to removal in a future version.BlockCanBuildEvent(@NotNull Block block, @Nullable Player player, @NotNull BlockData type, boolean canBuild, EquipmentSlot hand) -
Method Summary
Modifier and TypeMethodDescriptionGets the BlockData that we are trying to place.getHand()Gets the hand the player will use to place the blockstatic @NotNull HandlerListGets the Material that we are trying to place.Gets the player who placed the block involved in this event.booleanGets whether the block can be built here.voidsetBuildable(boolean cancel) Sets whether the block can be built here or not.Methods inherited from class BlockEvent
getBlockMethods inherited from class Event
callEvent, getEventName, isAsynchronous
-
Field Details
-
blockData
-
buildable
protected boolean buildable
-
-
Constructor Details
-
BlockCanBuildEvent
@Deprecated(since="1.13.2", forRemoval=true) @Internal public BlockCanBuildEvent(@NotNull @NotNull Block block, @NotNull @NotNull BlockData type, boolean canBuild) Deprecated, for removal: This API element is subject to removal in a future version. -
BlockCanBuildEvent
-
BlockCanBuildEvent
-
-
Method Details
-
getPlayer
-
getMaterial
-
getBlockData
-
getHand
Gets the hand the player will use to place the block- Returns:
- the EquipmentSlot representing the players hand.
-
isBuildable
public boolean isBuildable()Gets whether the block can be built here.By default, returns Minecraft's answer on whether the block can be built here or not.
- Returns:
- boolean whether the block can be built
-
setBuildable
public void setBuildable(boolean cancel) Sets whether the block can be built here or not.- Parameters:
cancel-trueif you want to allow the block to be built here despite Minecraft's default behaviour
-
getHandlers
- Specified by:
getHandlersin classEvent
-
getHandlerList
-