/** * 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(); } }
@Override public List<String> getPages() { return bm.getPages(); }
if (bq != null && (bq.getType().equals(Material.WRITABLE_BOOK) || bq.getType().equals(Material.WRITTEN_BOOK))) { BookMeta bm = (BookMeta) bq.getItemMeta(); List<String> pages = bm.getPages(); StringBuilder sb = new StringBuilder(); pages.forEach((s) -> sb.append(s).append(" "));
for (String page: bookMeta.getPages()) { if (page.startsWith("\"") && page.endsWith("\"")) { page = page.substring(1, page.length() - 1);
List<String> pages = bookMeta.getPages(); if (pages.isEmpty()) { player.sendMessage(api.getMessages().get("item.skull_invalid_book"));
static public BookFile getFrom(Inventory inventory, int index, boolean binary, String name) { ItemStack mystack = inventory.getItem(index); if (mystack == null || ! mystack.getType().equals(Material.WRITTEN_BOOK)) { return null; } BookMeta mybook = null; if (mystack.hasItemMeta()) { mybook = (BookMeta) mystack.getItemMeta(); } else { return null; } if ( ! mybook.hasAuthor() || ! mybook.getAuthor().startsWith(prefix)) { return null; } if (name != null && ! mybook.getAuthor().equals(prefix + "." + name)) { return null; } BookFile bookfile = new BookFile(inventory, index, binary); // fix corrupted books in MC 1.8 try { @SuppressWarnings("unused") List<String> test = mybook.getPages(); } catch(NullPointerException e) { inventory.clear(index); bookfile = create(inventory, index, binary, name); } return bookfile; }
return false; if (!book.checkText(bookMeta.getPages())) { return false;