/** * Creates an instance by copying from the given {@link ItemMeta}. If that item is another * {@link BookMeta}, its title, author, pages and generation are copied; otherwise, the new book * is blank. * @param meta the {@link ItemMeta} to copy */ public GlowMetaBook(ItemMeta meta) { super(meta); if (!(meta instanceof BookMeta)) { return; } BookMeta book = (BookMeta) meta; title = book.getTitle(); author = book.getAuthor(); if (book.hasPages()) { pages = new ArrayList<>(book instanceof GlowMetaBook ? ((GlowMetaBook) book).pages : book.getPages()); filterPages(); } if (hasGeneration()) { this.generation = book.getGeneration().ordinal(); } }
handBook.setTitle(book.getTitle()); handBook.setPages(book.getPages()); inHand.setType(Material.WRITTEN_BOOK);
@Override public String getTitle() { return bm.getTitle(); }
private boolean isWanderer(Inventory inv, Scope scope, String suffix, String type) { if (! isWanderer(inv)) return false; ItemStack stack = inv.getItem(0); if (stack != null && stack.getType().equals(Material.WRITTEN_BOOK) && stack.hasItemMeta()) { final BookMeta book = (BookMeta) stack.getItemMeta(); final String booktitle = book.getTitle(); final String dot = "\\."; final StringBuilder match = new StringBuilder(); match.append("^"); final String alphanums = "[a-zA-Z]{1,}"; if (type != null) match.append(type).append(dot); else match.append(alphanums).append(dot); if (scope != null) match.append(scope.name).append(dot); else match.append(alphanums).append(dot); if (suffix != null) match.append(suffix).append(dot); match.append(".*"); if (InventoryFile.isInventoryFile(inv, type) && booktitle.matches(match.toString())) { return true; } } return false; }
private String getType(Inventory inv) { ItemStack stack = inv.getItem(0); String prefix = null; if (stack != null && stack.getType().equals(Material.WRITTEN_BOOK) && stack.hasItemMeta()) { BookMeta book = (BookMeta) stack.getItemMeta(); String booktitle = book.getTitle(); int index = booktitle.indexOf("."); if (index > 0) prefix = booktitle.substring(0, index); } return prefix; }
@Override public String describeItem(ItemStack item) { String displayName = null; if (item.hasItemMeta()) { ItemMeta meta = item.getItemMeta(); displayName = meta.getDisplayName(); if ((displayName == null || displayName.isEmpty()) && meta instanceof BookMeta) { BookMeta book = (BookMeta)meta; displayName = book.getTitle(); } } if (displayName == null || displayName.isEmpty()) { MaterialAndData material = new MaterialAndData(item); displayName = material.getName(); } return displayName; }
title = " title:" + bookMeta.getTitle().replace(" ", "_");
/** * Checks if the item is journal * * @param playerID * ID of the player * @param item * ItemStack to check against being the journal * @return true if the ItemStack is the journal, false otherwise */ public static boolean isJournal(String playerID, ItemStack item) { // if there is no item then it's not a journal if (item == null) { return false; } // get language String playerLang = BetonQuest.getInstance().getPlayerData(playerID).getLanguage(); // check all properties of the item and return the result return (item.getType().equals(Material.WRITTEN_BOOK) && ((BookMeta) item.getItemMeta()).hasTitle() && ((BookMeta) item.getItemMeta()).getTitle().equals(Config.getMessage(playerLang, "journal_title")) && item.getItemMeta().hasLore() && item.getItemMeta().getLore().contains(Config.getMessage(playerLang, "journal_lore"))); }
return meta.getDisplayName(); } else if (meta instanceof BookMeta && ((BookMeta) meta).hasTitle()) { return ((BookMeta) meta).getTitle(); } else if (meta instanceof SkullMeta) { if (((SkullMeta) meta).hasOwner()) {
pages.setString(Integer.toString(i), book.getPage(i)); key.setString("book.title", book.getTitle()); key.setString("book.author", book.getAuthor()); serialiseEnchantments(key.getRelative("book.enchantments"), book.getEnchants());
BookMeta meta = (BookMeta) item.getItemMeta(); if (meta.hasTitle()) { name = meta.getTitle();
if (!book.checkTitle(bookMeta.getTitle())) { return false;