Class BookBuilder


public class BookBuilder extends WritableBookBuilder
The BookMetaBuilder class extends WritableBookBuilder to provide additional functionality for modifying BookMeta of an ItemStack. This class allows setting the title, author, and generation of a written book.
  • Constructor Details

    • BookBuilder

      public BookBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Constructs a BookMetaBuilder using an existing ItemStack.
      Parameters:
      itemStack - the item stack to modify
      Throws:
      IllegalArgumentException - if the item's meta is not an instance of BookMeta
    • BookBuilder

      public BookBuilder(@NotNull @NotNull org.bukkit.Material material)
      Constructs a BookMetaBuilder with the specified Material.
      Parameters:
      material - the material for the item stack
      Throws:
      IllegalArgumentException - if the item's meta is not an instance of BookMeta
  • Method Details

    • setTitle

      public boolean setTitle(@NotNull @NotNull String title)
      Sets the title of the book.
      Parameters:
      title - the title to set
      Returns:
      true if the title was successfully set, false otherwise
    • getTitle

      public String getTitle()
      Gets the title of the book.
      Returns:
      the title of the book, or null if none is set
    • hasTitle

      public boolean hasTitle()
      Checks if the book has a title.
      Returns:
      true if the book has a title, false otherwise
    • setAuthor

      public BookBuilder setAuthor(@NotNull @NotNull String author)
      Sets the author of the book.
      Parameters:
      author - the author to set
      Returns:
      this BookMetaBuilder instance for method chaining
    • getAuthor

      public String getAuthor()
      Gets the author of the book.
      Returns:
      the author of the book, or null if none is set
    • hasAuthor

      public boolean hasAuthor()
      Checks if the book has an author.
      Returns:
      true if the book has an author, false otherwise
    • setGeneration

      public BookBuilder setGeneration(@NotNull org.bukkit.inventory.meta.BookMeta.Generation generation)
      Sets the generation of the book.
      Parameters:
      generation - the generation to set
      Returns:
      this BookMetaBuilder instance for method chaining
    • getGeneration

      public org.bukkit.inventory.meta.BookMeta.Generation getGeneration()
      Gets the generation of the book.
      Returns:
      the generation of the book, or null if none is set
    • hasGeneration

      public boolean hasGeneration()
      Checks if the book has a generation set.
      Returns:
      true if the book has a generation, false otherwise