1.14.4 How to remove the generation from BookMeta?

Discussion in 'Spigot Plugin Development' started by luiskeniosis, Jan 20, 2020.

  1. I'm trying to create a custom book without the "Original" or "Copy of Original" line of text right underneath the author. On the BookMeta API it specifies that if I run setGeneration(null); on the BookMeta, it should remove it, but this isn't working for me.

    Code:
    Code (Text):
    package lucien.HardcoreGames.kits;

    import java.util.ArrayList;
    import java.util.List;

    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.BookMeta;

    import com.connorlinfoot.actionbarapi.ActionBarAPI;

    import lucien.HardcoreGames.game.ChosenKits;
    import lucien.HardcoreGames.game.Tracking;

    public class Analyzer {
        public static void createInfoBook(Player analyzer, List<Player> playerList) {
        //Creates the book item
        ItemStack analyzedBook = new ItemStack(Material.WRITTEN_BOOK, 1);
        //Saves information that the book contains
        BookMeta bookInfo = (BookMeta)analyzedBook.getItemMeta();
        //Sets the author
        bookInfo.setAuthor(ChatColor.YELLOW + "Lucien");
        //Sets the title
        bookInfo.setTitle(ChatColor.BOLD + "" + ChatColor.DARK_PURPLE + "Pre-Game Analysis");
        //Creates a new list to store the book lore
        List<String> lore = new ArrayList<String>();
        //Adds lore to the lore list
        lore.add(ChatColor.translateAlternateColorCodes('&', "&8&l-&7Shows the kit chosen by each opponent."));
        //Sets the lore of the book to the lore list
        bookInfo.setLore(lore);
        //Creates a new list to store the pages of the book
        List<String> pages = new ArrayList<String>();
        for(Player player : playerList) {
            pages.add(ChatColor.translateAlternateColorCodes('&', player.getName() + ": " + ChosenKits.playerKits.get(player.getName())));
        }
        bookInfo.setPages(pages);
        bookInfo.setGeneration((BookMeta.Generation)null);
        analyzedBook.setItemMeta(bookInfo);
        analyzer.getInventory().addItem(analyzedBook);

        }
    }
    I'm on version 1.14.4, any help is appreciated. Thanks in advance :)
     
  2. Use Material.WRITABLE_BOOK not sure if it will fix your issue but i recently had a problem with BookMeta on 1.15.1 and it was caused by using Material.WRITTRN_BOOK