当前位置: 首页>>代码示例>>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;未经允许,请勿转载。