/** * 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 String getAuthor() { return bm.getAuthor(); }
private static boolean isBookFile(String name, BookMeta mybook) { return mybook.getAuthor().equals(prefix + "." + name); }
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; }
BookMeta bookMeta = (BookMeta) meta; if (bookMeta.hasAuthor()) { author = " author:" + bookMeta.getAuthor().replace(" ", "_");
key.setString("book.author", book.getAuthor()); serialiseEnchantments(key.getRelative("book.enchantments"), book.getEnchants()); } else {
return false; if (!book.checkAuthor(bookMeta.getAuthor())) { return false;