Problem with written book! (Invalid Book tag)

Discussion in 'Plugin Development' started by envic, Jan 19, 2017.

Thread Status:
Not open for further replies.
  1. Offline


    In Short, i faced NPE in line 46:
    import java.util.ArrayList;
    import java.util.List;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.player.PlayerDropItemEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.BookMeta;
    public class rullBookOnJoin {
        private static rullBookOnJoin instance;
        public rullBookOnJoin(){
            instance = this;
        public static rullBookOnJoin getInstance() {
            if (instance == null) {
                instance = new rullBookOnJoin();
                return instance;
            } else {
                return instance;
        private ItemStack bookItem = new ItemStack(Material.WRITTEN_BOOK);
        private String Bookname,Authorname;
        private List<String> lore,pages = new ArrayList<String>();
        public ItemStack getBookitem() {
            return bookItem;
        public BookMeta getGhavaninBookmeta() {
            return (BookMeta) getBookitem().getItemMeta();
        public String getBookname() {
            Bookname = "┬ž6&lKetabe Ghavanin";
            return Bookname;
        public String getAuthorname() {
            Authorname = "┬žaServer";
            return Authorname;
        public List<String> getLore() {
            lore.add("In ketab majmoe amalist ke Shoma Karbare aziz movazaf Be re'ayate on hastid.");
            return lore;
        public List<String> getPages() {
            String pagestxt = ""
                    + "Amale ba ketabe Ghanon vazife'ye har player mibashad va hargone ta'aroz va shekastane ghavanin"
                    + "mitavanad monjar be mahromiat movaghat ya da'emie shoma az server shavad."
                    + "\nGhavanine Fani:"
                    + "\n1.Hargone grief,cheat ya hack mamno mibashad."
                    + "\n2. Tablighate bedone hamahangi mamno mibashad."
                    + "\n3. Spam va ersale payame na marbot mamno mibahad."
                    + "\n4. Estefade az dastore /report bedone dalil movajah mamno mibashad."
                    + "\n Ghavanine Ejtemayi:"
                    + "\n1. Darkhaste Rank az admin mamno mibashad."
                    + "\n2. Ijade mozahemat baraye karbarane digar mamno mibashad."
                    + "\n3. Hargone fahashi va estefade az loghate na monaseb mamno mibashad."
                    + "\n4. Ersale payame khososi dar chate omomi mamno mibashad."
                    + "\n5. Enteghadat va pishnehadat tanha dar site majmoe {website} va estefade az dastore /nazar <matn> mojaz mibashad."
                    + "";
            return pages;
        public void giveRullBook(Player player) {
            String pname = player.getDisplayName();
            getGhavaninBookmeta().setPages(pname + ", " + getPages());
        public void onPlayerDropItem(PlayerDropItemEvent e) {
            if (!e.getItemDrop().getCustomName().equalsIgnoreCase("Ketabe Ghavanin"))
            if (e.getPlayer().isOp())
    Last edited: Jan 19, 2017
  2. Offline


    Are you sure line 46 is the line that is causing the error? If so, that means that the lore is null. Nullcheck it before you use it.
  3. Offline


    Fixed with:
    if (lore == null){
        lore = new ArrayList<String>();
    But it's give the player a written book which contain invalid book tag with no changed display name and even doesn't have the lore and etc!

    :confused: Guys... No one know what's wrong or any thing about invalid book tag issue?!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jan 20, 2017
Thread Status:
Not open for further replies.

Share This Page