當前位置: 首頁>>代碼示例>>Java>>正文


Java Sign.getBlock方法代碼示例

本文整理匯總了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
}
 
開發者ID:sakunc,項目名稱:Gringotts-,代碼行數:22,代碼來源:Util.java

示例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);
}
 
開發者ID:Deltik,項目名稱:SignEdit,代碼行數:11,代碼來源:SignEditCommit.java


注:本文中的org.bukkit.block.Sign.getBlock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。