本文整理匯總了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);
}