Interface WritableBookMeta

All Superinterfaces:
Cloneable, ConfigurationSerializable, ItemMeta, PersistentDataHolder
All Known Subinterfaces:
BookMeta

public interface WritableBookMeta extends ItemMeta
Represents a book (Material.WRITABLE_BOOK) that can have pages.

For Material.WRITTEN_BOOK, use BookMeta.

Before using this type, make sure to check the itemstack's material with ItemStack.getType(). instanceof on the meta instance is not sufficient due to unusual inheritance with relation to BookMeta.

  • Method Details

    • hasPages

      boolean hasPages()
      Checks for the existence of pages in the book.
      Returns:
      true if the book has pages
    • getPage

      @NotNull @NotNull String getPage(int page)
      Gets the specified page in the book. The given page must exist.

      Pages are 1-indexed.

      Parameters:
      page - the page number to get, in range [1, getPageCount()]
      Returns:
      the page from the book
    • setPage

      void setPage(int page, @NotNull @NotNull String data)
      Sets the specified page in the book. Pages of the book must be contiguous.

      The data can be up to 1024 characters in length, additional characters are truncated.

      Pages are 1-indexed.

      Parameters:
      page - the page number to set, in range [1, getPageCount()]
      data - the data to set for that page
    • getPages

      Gets all the pages in the book.
      Returns:
      list of all the pages in the book
    • setPages

      void setPages(@NotNull @NotNull List<String> pages)
      Clears the existing book pages, and sets the book to use the provided pages. Maximum 100 pages with 1024 characters per page.
      Parameters:
      pages - A list of pages to set the book to use
    • setPages

      void setPages(@NotNull @NotNull String... pages)
      Clears the existing book pages, and sets the book to use the provided pages. Maximum 100 pages with 1024 characters per page.
      Parameters:
      pages - A list of strings, each being a page
    • addPage

      void addPage(@NotNull @NotNull String... pages)
      Adds new pages to the end of the book. Up to a maximum of 100 pages with 1024 characters per page.
      Parameters:
      pages - A list of strings, each being a page
    • getPageCount

      int getPageCount()
      Gets the number of pages in the book.
      Returns:
      the number of pages in the book
    • clone

      Specified by:
      clone in interface ItemMeta