本文整理匯總了Java中org.bukkit.inventory.meta.BookMeta.hasAuthor方法的典型用法代碼示例。如果您正苦於以下問題:Java BookMeta.hasAuthor方法的具體用法?Java BookMeta.hasAuthor怎麽用?Java BookMeta.hasAuthor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.meta.BookMeta
的用法示例。
在下文中一共展示了BookMeta.hasAuthor方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
}
示例2: check
import org.bukkit.inventory.meta.BookMeta; //導入方法依賴的package包/類
public boolean check(Event e) {
BookMeta book = (BookMeta) item.getSingle(e).getItemMeta();
if (book.hasAuthor()) {
if (boo == true) {
return true;
} else {
return false;
}
} else {
if (boo == false) {
return true;
} else {
return false;
}
}
}
示例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;
}
示例4: 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);
}
示例5: 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;
}