本文整理汇总了Java中org.bukkit.block.Sign.getBlock方法的典型用法代码示例。如果您正苦于以下问题:Java Sign.getBlock方法的具体用法?Java Sign.getBlock怎么用?Java Sign.getBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.Sign
的用法示例。
在下文中一共展示了Sign.getBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chestBlock
import org.bukkit.block.Sign; //导入方法依赖的package包/类
/**
* Find a valid container block for a given sign, if it exists.
* @param sign sign to check
* @return container for the sign if available, null otherwise.
*/
public static Block chestBlock(Sign sign) {
// is sign attached to a valid vault container?
Block signBlock = sign.getBlock();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)signBlock.getState().getData();
BlockFace attached = signData.getAttachedFace();
// allow either the block sign is attached to or the block below the sign as chest block. Prefer attached block.
Block blockAttached = signBlock.getRelative(attached);
Block blockBelow = signBlock.getRelative(BlockFace.DOWN);
if (validContainer(blockAttached.getType()))
return blockAttached;
if (validContainer(blockBelow.getType()))
return blockBelow;
return null; // no valid container
}
示例2: validatedCommit
import org.bukkit.block.Sign; //导入方法依赖的package包/类
default void validatedCommit(Player player, Sign sign) {
// Simulates blanking the sign to check if editing this sign is allowed
SignChangeEvent event = new SignChangeEvent(sign.getBlock(), player, new String[]{"", "", "", ""});
getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
player.sendMessage(CHAT_PREFIX + "§cSign edit forbidden by policy or other plugin");
return;
}
commit(player, sign);
}