Interface BookMeta

All Superinterfaces:
net.kyori.adventure.inventory.Book, net.kyori.adventure.util.Buildable<net.kyori.adventure.inventory.Book,net.kyori.adventure.inventory.Book.Builder>, Cloneable, ConfigurationSerializable, net.kyori.examination.Examinable, ItemMeta, PersistentDataHolder, WritableBookMeta

public interface BookMeta extends WritableBookMeta, net.kyori.adventure.inventory.Book
Represents a Material.WRITTEN_BOOK that can have a title, an author, and pages.

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 WritableBookMeta.

  • Method Details Link icon

    • hasTitle Link icon

      boolean hasTitle()
      Checks for the existence of a title in the book.
      Returns:
      true if the book has a title
    • getTitle Link icon

      Gets the title of the book.

      Plugins should check that hasTitle() returns true before calling this method.

      Returns:
      the title of the book
    • setTitle Link icon

      boolean setTitle(@Nullable @Nullable String title)
      Sets the title of the book.

      Limited to 32 characters. Removes title when given null.

      Parameters:
      title - the title to set
      Returns:
      true if the title was successfully set
    • hasAuthor Link icon

      boolean hasAuthor()
      Checks for the existence of an author in the book.
      Returns:
      true if the book has an author
    • getAuthor Link icon

      Gets the author of the book.

      Plugins should check that hasAuthor() returns true before calling this method.

      Returns:
      the author of the book
    • setAuthor Link icon

      void setAuthor(@Nullable @Nullable String author)
      Sets the author of the book. Removes author when given null.
      Parameters:
      author - the author to set
    • hasGeneration Link icon

      boolean hasGeneration()
      Checks for the existence of generation level in the book.
      Returns:
      true if the book has a generation level
    • getGeneration Link icon

      Gets the generation of the book.

      Plugins should check that hasGeneration() returns true before calling this method.

      Returns:
      the generation of the book
    • setGeneration Link icon

      void setGeneration(@Nullable @Nullable BookMeta.Generation generation)
      Sets the generation of the book. Removes generation when given null.
      Parameters:
      generation - the generation to set
    • clone Link icon

      Specified by:
      clone in interface ItemMeta
      Specified by:
      clone in interface WritableBookMeta
    • getPage Link icon

      @Deprecated @NotNull @NotNull String getPage(int page)
      Deprecated.
      Description copied from interface: WritableBookMeta
      Gets the specified page in the book. The given page must exist.

      Pages are 1-indexed.

      Specified by:
      getPage in interface WritableBookMeta
      Parameters:
      page - the page number to get, in range [1, getPageCount()]
      Returns:
      the page from the book
    • setPage Link icon

      @Deprecated void setPage(int page, @NotNull @NotNull String data)
      Description copied from interface: WritableBookMeta
      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.

      Specified by:
      setPage in interface WritableBookMeta
      Parameters:
      page - the page number to set, in range [1, getPageCount()]
      data - the data to set for that page
    • getPages Link icon

      Deprecated.
      use Book.pages()
      Description copied from interface: WritableBookMeta
      Gets all the pages in the book.
      Specified by:
      getPages in interface WritableBookMeta
      Returns:
      list of all the pages in the book
    • setPages Link icon

      @Deprecated void setPages(@NotNull @NotNull List<String> pages)
      Deprecated.
      use Book.pages(List)
      Description copied from interface: WritableBookMeta
      Clears the existing book pages, and sets the book to use the provided pages. Maximum 100 pages with 1024 characters per page.
      Specified by:
      setPages in interface WritableBookMeta
      Parameters:
      pages - A list of pages to set the book to use
    • setPages Link icon

      @Deprecated void setPages(@NotNull @NotNull String... pages)
      Deprecated.
      use Book.pages(net.kyori.adventure.text.Component...)
      Description copied from interface: WritableBookMeta
      Clears the existing book pages, and sets the book to use the provided pages. Maximum 100 pages with 1024 characters per page.
      Specified by:
      setPages in interface WritableBookMeta
      Parameters:
      pages - A list of strings, each being a page
    • addPage Link icon

      @Deprecated void addPage(@NotNull @NotNull String... pages)
      Description copied from interface: WritableBookMeta
      Adds new pages to the end of the book. Up to a maximum of 100 pages with 1024 characters per page.
      Specified by:
      addPage in interface WritableBookMeta
      Parameters:
      pages - A list of strings, each being a page
    • title Link icon

      @Nullable net.kyori.adventure.text.Component title()
      Gets the title of the book.

      Plugins should check that hasTitle() returns true before calling this method.

      Specified by:
      title in interface net.kyori.adventure.inventory.Book
      Returns:
      the title of the book
    • title Link icon

      @Contract(value="_ -> this", pure=false) @NotNull @NotNull BookMeta title(@Nullable net.kyori.adventure.text.Component title)
      Sets the title of the book.

      Limited to 32 characters. Removes title when given null.

      Specified by:
      title in interface net.kyori.adventure.inventory.Book
      Parameters:
      title - the title to set
      Returns:
      the same BookMeta instance
    • author Link icon

      @Nullable net.kyori.adventure.text.Component author()
      Gets the author of the book.

      Plugins should check that hasAuthor() returns true before calling this method.

      Specified by:
      author in interface net.kyori.adventure.inventory.Book
      Returns:
      the author of the book
    • author Link icon

      @Contract(value="_ -> this", pure=false) @NotNull @NotNull BookMeta author(@Nullable net.kyori.adventure.text.Component author)
      Sets the author of the book. Removes author when given null.
      Specified by:
      author in interface net.kyori.adventure.inventory.Book
      Parameters:
      author - the author to set
      Returns:
      the same BookMeta instance
    • page Link icon

      @NotNull net.kyori.adventure.text.Component page(int page)
      Gets the specified page in the book. The page must exist.

      Pages are 1-indexed.

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

      void page(int page, @NotNull net.kyori.adventure.text.Component 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
    • addPages Link icon

      void addPages(@NotNull net.kyori.adventure.text.Component @NotNull ... 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
    • toBuilder Link icon

      Description copied from interface: net.kyori.adventure.inventory.Book
      Create a new builder initialized with the attributes of this book.
      Specified by:
      toBuilder in interface net.kyori.adventure.inventory.Book
      Specified by:
      toBuilder in interface net.kyori.adventure.util.Buildable<net.kyori.adventure.inventory.Book,net.kyori.adventure.inventory.Book.Builder>
      Returns:
      the builder
    • spigot Link icon