Class WritableBookBuilder
java.lang.Object
io.github.lucfr1746.llibrary.itemstack.ItemBuilder
io.github.lucfr1746.llibrary.itemstack.WritableBookBuilder
- Direct Known Subclasses:
BookBuilder
The
WritableBookBuilder
class extends ItemBuilder
to provide
additional functionality for modifying WritableBookMeta
of an ItemStack
.
This class allows adding, setting, and retrieving pages in writable books.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aWritableBookBuilder
with a newMaterial.WRITABLE_BOOK
.WritableBookBuilder
(@NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aWritableBookBuilder
using an existingItemStack
. -
Method Summary
Modifier and TypeMethodDescriptionAdds new pages to the end of the book.Clears all pages in the book.getPage
(int page) Gets the specified page in the book.int
Gets the number of pages in the book.getPages()
Gets all the pages in the book.boolean
hasPages()
Checks if the book has any pages.Sets the content of a specific page.Sets the pages of the book, replacing any existing pages.Sets the pages of the book using a list, replacing any existing pages.Methods inherited from class io.github.lucfr1746.llibrary.itemstack.ItemBuilder
addAttributeModifier, addEnchant, addEnchant, addEnchant, addItemFlags, addLore, build, getAmount, getAttributeModifiers, getAttributeModifiers, getAttributeModifiers, getCustomModelData, getDamageResistant, getDisplayName, getEnchantable, getEnchantLevel, getEnchantmentGlintOverride, getEnchants, getEquippableComponent, getFoodComponent, getItemFlags, getItemMeta, getItemModel, getJukeboxPlayableComponent, getMaxStackSize, getRarity, getToolComponent, getTooltipStyle, getTranslationKey, getType, getUseCooldownComponent, getUseRemainder, hasAttributeModifiers, hasConflictingEnchant, hasCustomModelData, hasDamageResistant, hasEnchant, hasEnchantable, hasEnchantmentGlintOverride, hasEnchants, hasEquippableComponent, hasFoodComponent, hasItemFlag, hasItemModel, hasJukeboxPlayableComponent, hasMaxStackSize, hasRarity, hasToolComponent, hasTooltipStyle, hasUseCooldownComponent, hasUseRemainder, hideAllItemFlags, insertLore, isGlider, isHideTooltip, isUnbreakable, removeAttributeModifier, removeAttributeModifier, removeAttributeModifier, removeEnchant, removeEnchants, removeItemFlags, replaceLore, setAmount, setAttributeModifiers, setCustomModelData, setDamageResistant, setDisplayName, setEnchantable, setEnchantmentGlintOverride, setEquippableComponent, setEquippableComponent, setFood, setFoodComponent, setGlider, setHideTooltip, setItemModel, setItemModel, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setLores, setLores, setMaxStackSize, setRarity, setToolComponent, setToolComponent, setTooltipStyle, setTooltipStyle, setType, setUnbreakable, setUseCooldownComponent, setUseCooldownComponent, setUseCooldownComponent, setUseRemainder
-
Constructor Details
-
WritableBookBuilder
public WritableBookBuilder()Constructs aWritableBookBuilder
with a newMaterial.WRITABLE_BOOK
. -
WritableBookBuilder
public WritableBookBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aWritableBookBuilder
using an existingItemStack
.- Parameters:
itemStack
- the item stack to modify- Throws:
IllegalArgumentException
- if the item's meta is not an instance ofWritableBookMeta
-
-
Method Details
-
addPage
Adds new pages to the end of the book.- Parameters:
pages
- the pages to add- Returns:
- this
WritableBookBuilder
instance for method chaining
-
getPage
Gets the specified page in the book.- Parameters:
page
- the page number (1-based index)- Returns:
- the content of the specified page
- Throws:
IndexOutOfBoundsException
- if the page number is invalid
-
getPageCount
public int getPageCount()Gets the number of pages in the book.- Returns:
- the number of pages
-
getPages
Gets all the pages in the book.- Returns:
- a list of pages
-
hasPages
public boolean hasPages()Checks if the book has any pages.- Returns:
- true if the book has pages, false otherwise
-
setPage
Sets the content of a specific page.- Parameters:
page
- the page number (1-based index)content
- the content to set- Returns:
- this
WritableBookBuilder
instance for method chaining - Throws:
IndexOutOfBoundsException
- if the page number is invalid
-
setPages
Sets the pages of the book, replacing any existing pages.- Parameters:
pages
- the pages to set- Returns:
- this
WritableBookBuilder
instance for method chaining
-
setPages
Sets the pages of the book using a list, replacing any existing pages.- Parameters:
pages
- the list of pages to set- Returns:
- this
WritableBookBuilder
instance for method chaining
-
clearPages
Clears all pages in the book.- Returns:
- this
WritableBookBuilder
instance for method chaining
-