public class BlockPlaceEvent extends BlockEvent implements Cancellable
如果方块放置事件被取消,那么这个方块将不能被放置
Event.Result
限定符和类型 | 字段和说明 |
---|---|
protected boolean |
canBuild |
protected boolean |
cancel |
protected EquipmentSlot |
hand |
protected ItemStack |
itemInHand |
protected Block |
placedAgainst |
protected Player |
player |
protected BlockState |
replacedBlockState |
block
构造器和说明 |
---|
BlockPlaceEvent(Block placedBlock,
BlockState replacedBlockState,
Block placedAgainst,
ItemStack itemInHand,
Player thePlayer,
boolean canBuild)
已过时。
|
BlockPlaceEvent(Block placedBlock,
BlockState replacedBlockState,
Block placedAgainst,
ItemStack itemInHand,
Player thePlayer,
boolean canBuild,
EquipmentSlot hand) |
限定符和类型 | 方法和说明 |
---|---|
boolean |
canBuild()
获取这个方块是否可以建造.
|
Block |
getBlockAgainst()
获取这个方块是依附在哪个方块上放置的.
|
Block |
getBlockPlaced()
获得被放置的方块(还未真正被放置).
|
BlockState |
getBlockReplacedState()
获取方块被放置后的方块状态(
BlockState ). |
EquipmentSlot |
getHand()
获取放置这个方块的手.
|
static HandlerList |
getHandlerList() |
HandlerList |
getHandlers() |
ItemStack |
getItemInHand()
获取玩家放置的方块的物品形式(在玩家手上).
|
Player |
getPlayer()
获得是哪个玩家放置的这个方块.
|
boolean |
isCancelled()
获取这个事件是否被取消.一个被取消的事件不会在服务器里被执行,但是仍然会传递事件到其他插件。
|
void |
setBuild(boolean canBuild)
设置这个方块是否可以被放置.
|
void |
setCancelled(boolean cancel)
取消这个事件.
|
getBlock
getEventName, isAsynchronous
protected boolean cancel
protected boolean canBuild
protected Block placedAgainst
protected BlockState replacedBlockState
protected ItemStack itemInHand
protected Player player
protected EquipmentSlot hand
@Deprecated public BlockPlaceEvent(Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild)
public BlockPlaceEvent(Block placedBlock, BlockState replacedBlockState, Block placedAgainst, ItemStack itemInHand, Player thePlayer, boolean canBuild, EquipmentSlot hand)
public boolean isCancelled()
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
isCancelled
在接口中 Cancellable
public void setCancelled(boolean cancel)
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.
setCancelled
在接口中 Cancellable
cancel
- 如果你想取消这个事件,则为truepublic Player getPlayer()
原文:Gets the player who placed the block involved in this event.
public Block getBlockPlaced()
原文:Clarity method for getting the placed block. Not really needed except for reasons of clarity.
public BlockState getBlockReplacedState()
BlockState
). 通常是空气.
例:牌子拿在手里,放在墙上后,这个牌子的方块状态就是墙上的牌子.
原文:Gets the BlockState for the block which was replaced. Material type air mostly.
public Block getBlockAgainst()
原文:Gets the block that this block was placed against
public ItemStack getItemInHand()
原文:Gets the item in the player's hand when they placed the block.
public EquipmentSlot getHand()
原文:Gets the hand which placed the block
public boolean canBuild()
默认情况下,如果玩家还在重生/生成服务器将阻止它们.注意,这跟BLOCK_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.
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
canBuild
- 是否允许玩家放置这个方块public HandlerList getHandlers()
getHandlers
在类中 Event
public static HandlerList getHandlerList()