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


Java BookMeta.hasTitle方法代碼示例

本文整理匯總了Java中org.bukkit.inventory.meta.BookMeta.hasTitle方法的典型用法代碼示例。如果您正苦於以下問題:Java BookMeta.hasTitle方法的具體用法?Java BookMeta.hasTitle怎麽用?Java BookMeta.hasTitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.inventory.meta.BookMeta的用法示例。


在下文中一共展示了BookMeta.hasTitle方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: serializeBookMeta

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
/**
 * Gets a JSONObject representation of a BookMeta. Book and Quills books will have a pages key, while
 * finished, written, books will also have an author and title key.
 *
 * @param meta The BookMeta to serialize
 * @return A JSON Representation of the give BookMeta
 */
public static JSONObject serializeBookMeta(BookMeta meta) {
    try {
        JSONObject root = new JSONObject();
        if (meta.hasTitle())
            root.put("title", meta.getTitle());
        if (meta.hasAuthor())
            root.put("author", meta.getAuthor());
        if (meta.hasPages()) {
            String[] pages = meta.getPages().toArray(new String[]{});
            root.put("pages", pages);
        }
        return root;
    } catch (JSONException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:ThisIzEthan,項目名稱:NexusInventory,代碼行數:25,代碼來源:BookSerialization.java

示例2: check

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public boolean check(Event e) {
    BookMeta book = (BookMeta) item.getSingle(e).getItemMeta();
    if (book.hasTitle()) {
        if (boo == true) {
            return true;
        } else {
            return false;
        }
    } else {
        if (boo == false) {
            return true;
        } else {
            return false;
        }
    }
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:17,代碼來源:CondHasTitle.java

示例3: matches

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
@Override
public boolean matches(ItemStack item) {
    if(item.hasItemMeta()) {
        ItemMeta meta = item.getItemMeta();
        
        if(meta instanceof BookMeta) {
            BookMeta bookMeta = (BookMeta) meta;
            
            if(bookMeta.hasTitle() == hasTitle() && bookMeta.hasAuthor() == hasAuthor() && bookMeta.hasPages() == hasPages) {
                if(hasPages) {
                    return bookHash(bookMeta.getPages()) == bookHash;
                }
                else {
                    return true;
                }
            }
        }
    }
    
    return false;
}
 
開發者ID:gmlaxfanatic,項目名稱:ItemExchange,代碼行數:22,代碼來源:BookMetadata.java

示例4: giveQuestBook

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public void giveQuestBook(){
    if(getPlayer() == null) return;
    
    Inventory inventory = getPlayer().getInventory();
    if(inventory.contains(Material.WRITTEN_BOOK)){
        for(int i = 0; i < inventory.getContents().length; i++){
            ItemStack item = inventory.getContents()[i];
            if(item != null && item.getType() == Material.WRITTEN_BOOK){
                BookMeta bookMeta = (BookMeta)item.getItemMeta();
                if(bookMeta.hasTitle() && bookMeta.getTitle().equals("Quest Book")) return;
            }
        }
    }
    
    ItemStack book = new ItemStack(Material.WRITTEN_BOOK, 1);
    inventory.addItem(book);
    OpenBookListener.UpdateBook(this);
}
 
開發者ID:Randehh,項目名稱:EpicQuest,代碼行數:19,代碼來源:EpicPlayer.java

示例5: onEditBook

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
@EventHandler
public void onEditBook(PlayerItemHeldEvent event){
    
    //Get player and the action
    Player player = event.getPlayer();
    EpicPlayer epicPlayer = EpicSystem.getEpicPlayer(player.getUniqueId());	
    ItemStack inHand = player.getInventory().getItem(event.getNewSlot());

    if(inHand != null && inHand.getType() == Material.WRITTEN_BOOK){
        
        BookMeta book = (BookMeta)inHand.getItemMeta();
        if(book.hasTitle() && book.getTitle().equalsIgnoreCase("Quest Book")){
            
            //Open zeh quest book!
            inHand.setItemMeta(SetQuestBookPages(epicPlayer, book));
        }
    }
}
 
開發者ID:Randehh,項目名稱:EpicQuest,代碼行數:19,代碼來源:OpenBookListener.java

示例6: onPlayerDeath

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event){
    if(event.getDrops().isEmpty()){
        return;
    }
    ItemStack itemToRemove = null;
    for(ItemStack item : event.getDrops()){
        if(item != null && item.getType() == Material.WRITTEN_BOOK){
            BookMeta bookMeta = (BookMeta)item.getItemMeta();
            if(bookMeta.hasTitle() && bookMeta.getTitle().equals("Quest Book")){
                itemToRemove = item;
            }
        }
    }
    if(itemToRemove != null) event.getDrops().remove(itemToRemove);
}
 
開發者ID:Randehh,項目名稱:EpicQuest,代碼行數:17,代碼來源:DeathListener.java

示例7: getBookTextArray

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public static List<String> getBookTextArray(final ItemStack book, final boolean byline) {
    if (! book.hasItemMeta() || !(book.getItemMeta() instanceof BookMeta))
        return null;

    final BookMeta meta = (BookMeta) book.getItemMeta();
    final List<String> out = new ArrayList<String>(meta.getPages());

    if (byline && meta.hasTitle())
        out.add(0, meta.getTitle() + (meta.hasAuthor() ? " by " + meta.getAuthor() : ""));

    return out;
}
 
開發者ID:stendec,項目名稱:Abyss,代碼行數:13,代碼來源:EntityUtils.java

示例8: onPlayerDropItem

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event){		
    ItemStack droppedItem = event.getItemDrop().getItemStack();
    if(droppedItem.getType() == Material.WRITTEN_BOOK){
        BookMeta book = (BookMeta)droppedItem.getItemMeta();
        if(book.hasTitle() && book.getTitle().equalsIgnoreCase("Quest Book")){
            event.setCancelled(true);
        }
    }
}
 
開發者ID:Randehh,項目名稱:EpicQuest,代碼行數:11,代碼來源:ItemDropListener.java

示例9: addQuestJournal

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public static void addQuestJournal(QuestPlayer qp) {
    if (!qp.getPlayer().isOnline()) {
        return;
    }
    if (!QuestManagerPlugin.questManagerPlugin.getPluginConfiguration()
            .getWorlds().contains(qp.getPlayer().getPlayer().getWorld().getName())) {
        return;
    }
    
    Player play = qp.getPlayer().getPlayer();
    Inventory inv = play.getInventory();
    
    if (inv.firstEmpty() == -1) {
        //no room!
        return;
    }
    
    ItemStack book = null;
    
    for (ItemStack item : inv.all(Material.BOOK_AND_QUILL).values()) {
        if (item.hasItemMeta()) {
            BookMeta meta = (BookMeta) item.getItemMeta();
            if (meta.hasTitle() && meta.getTitle().equals("Journal")
                    && meta.hasAuthor() && meta.getAuthor().equals(play.getName())
                    && item.getEnchantmentLevel(Enchantment.LUCK) == 5) {
                book = item;
                break;
            }
        }
    }
    
    if (book == null) {
    
        book = new ItemStack(Material.BOOK_AND_QUILL);
        BookMeta bookMeta = (BookMeta) book.getItemMeta();
        
        bookMeta.setTitle("Journal");
        bookMeta.setDisplayName("Journal");
        bookMeta.setAuthor(play.getName());
        
        book.setItemMeta(bookMeta);
        
        book.addUnsafeEnchantment(Enchantment.LUCK, 5);
        
        inv.addItem(book);
        
        play.sendMessage(ChatColor.GRAY + "A " + ChatColor.DARK_GREEN 
                + "Quest Journal" + ChatColor.GRAY + " has been added to your inventory."
                 + ChatColor.RESET);
    }
    
    updateQuestJournal(qp, true);
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:54,代碼來源:QuestJournal.java

示例10: BookMetadata

import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public BookMetadata(BookMeta bookMeta) {
    this.title = bookMeta.hasTitle() ? bookMeta.getTitle() : null;
    this.author = bookMeta.hasAuthor() ? bookMeta.getAuthor() : null;
    this.hasPages = bookMeta.hasPages();
    this.bookHash = this.hasPages ? bookHash(bookMeta.getPages()) : 0;
}
 
開發者ID:gmlaxfanatic,項目名稱:ItemExchange,代碼行數:7,代碼來源:BookMetadata.java


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