Interface BookMeta
- All Superinterfaces:
net.kyori.adventure.inventory.BookLike, Cloneable, ConfigurationSerializable, ItemMeta, PersistentDataHolder, PersistentDataViewHolder, WritableBookMeta
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.
- Since:
- 1.4.5
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumRepresents the generation (or level of copying) of a written bookstatic class -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.voidaddPages(@NotNull net.kyori.adventure.text.Component @NotNull ... pages) Adds new pages to the end of the book.@Nullable net.kyori.adventure.text.Componentauthor()Gets the author of the book.@NotNull BookMetaauthor(@Nullable net.kyori.adventure.text.Component author) Sets the author of the book.@NotNull BookMetaclone()@Nullable StringGets the author of the book.@Nullable BookMeta.GenerationGets the generation of the book.@NotNull StringgetPage(int page) Deprecated.usepage(int)getPages()Deprecated.usepages()@Nullable StringgetTitle()Gets the title of the book.booleanChecks for the existence of an author in the book.booleanChecks for the existence of generation level in the book.booleanhasTitle()Checks for the existence of a title in the book.@NotNull net.kyori.adventure.text.Componentpage(int page) Gets the specified page in the book.voidpage(int page, @NotNull net.kyori.adventure.text.Component data) Sets the specified page in the book.@NotNull List<net.kyori.adventure.text.Component> pages()Gets the list of pages.@NotNull BookMetaSets the pages of the book.default @NotNull BookMetapages(@NotNull net.kyori.adventure.text.Component @NotNull ... pages) Sets the pages of the book.voidSets the author of the book.voidsetGeneration(@Nullable BookMeta.Generation generation) Sets the generation of the book.voidDeprecated.voidDeprecated.voidDeprecated.usepages(List)booleanSets the title of the book.@NotNull BookMeta.Spigotspigot()@Nullable net.kyori.adventure.text.Componenttitle()Gets the title of the book.@NotNull BookMetatitle(@Nullable net.kyori.adventure.text.Component title) Sets the title of the book.Methods inherited from interface net.kyori.adventure.inventory.BookLike
asBookMethods inherited from interface ConfigurationSerializable
serializeMethods inherited from interface ItemMeta
addAttributeModifier, addEnchant, addItemFlags, customName, customName, displayName, displayName, getAsComponentString, getAsString, getAttributeModifiers, getAttributeModifiers, getAttributeModifiers, getCanDestroy, getCanPlaceOn, getCustomModelData, getCustomModelDataComponent, getCustomTagContainer, getDamageResistant, getDamageResistantTypes, getDestroyableKeys, getDisplayName, getDisplayNameComponent, getEnchantable, getEnchantLevel, getEnchantmentGlintOverride, getEnchants, getEquippable, getFood, getItemFlags, getItemModel, getItemName, getJukeboxPlayable, getLocalizedName, getLore, getLoreComponents, getMaxStackSize, getPlaceableKeys, getRarity, getTool, getTooltipStyle, getUseCooldown, getUseRemainder, hasAttributeModifiers, hasConflictingEnchant, hasCustomModelData, hasCustomModelDataComponent, hasCustomName, hasDamageResistant, hasDestroyableKeys, hasDisplayName, hasEnchant, hasEnchantable, hasEnchantmentGlintOverride, hasEnchants, hasEquippable, hasFood, hasItemFlag, hasItemModel, hasItemName, hasJukeboxPlayable, hasLocalizedName, hasLore, hasMaxStackSize, hasPlaceableKeys, hasRarity, hasTool, hasTooltipStyle, hasUseCooldown, hasUseRemainder, isFireResistant, isGlider, isHideTooltip, isUnbreakable, itemName, itemName, lore, lore, removeAttributeModifier, removeAttributeModifier, removeAttributeModifier, removeEnchant, removeEnchantments, removeItemFlags, setAttributeModifiers, setCanDestroy, setCanPlaceOn, setCustomModelData, setCustomModelDataComponent, setDamageResistant, setDamageResistantTypes, setDestroyableKeys, setDisplayName, setDisplayNameComponent, setEnchantable, setEnchantmentGlintOverride, setEquippable, setFireResistant, setFood, setGlider, setHideTooltip, setItemModel, setItemName, setJukeboxPlayable, setLocalizedName, setLore, setLoreComponents, setMaxStackSize, setPlaceableKeys, setRarity, setTool, setTooltipStyle, setUnbreakable, setUseCooldown, setUseRemainder, setVersionMethods inherited from interface PersistentDataHolder
getPersistentDataContainerMethods inherited from interface WritableBookMeta
getPageCount, hasPages
-
Method Details
-
hasTitle
boolean hasTitle()Checks for the existence of a title in the book.- Returns:
- true if the book has a title
- Since:
- 1.4.5
-
getTitle
Gets the title of the book.Plugins should check that hasTitle() returns true before calling this method.
- Returns:
- the title of the book
- Since:
- 1.4.5
-
setTitle
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
- Since:
- 1.4.5
-
hasAuthor
boolean hasAuthor()Checks for the existence of an author in the book.- Returns:
- true if the book has an author
- Since:
- 1.4.5
-
getAuthor
Gets the author of the book.Plugins should check that hasAuthor() returns true before calling this method.
- Returns:
- the author of the book
- Since:
- 1.4.5
-
setAuthor
Sets the author of the book. Removes author when given null.- Parameters:
author- the author to set- Since:
- 1.4.5
-
hasGeneration
boolean hasGeneration()Checks for the existence of generation level in the book.- Returns:
- true if the book has a generation level
- Since:
- 1.10.2
-
getGeneration
Gets the generation of the book.Plugins should check that hasGeneration() returns true before calling this method.
- Returns:
- the generation of the book
- Since:
- 1.9.4
-
setGeneration
Sets the generation of the book. Removes generation when given null.- Parameters:
generation- the generation to set- Since:
- 1.9.4
-
clone
- Specified by:
clonein interfaceItemMeta- Specified by:
clonein interfaceWritableBookMeta
-
getPage
Deprecated.usepage(int)Description copied from interface:WritableBookMetaGets the specified page in the book. The given page must exist.Pages are 1-indexed.
- Specified by:
getPagein interfaceWritableBookMeta- Parameters:
page- the page number to get, in range [1, getPageCount()]- Returns:
- the page from the book
- Since:
- 1.4.5
-
setPage
Deprecated.Description copied from interface:WritableBookMetaSets 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:
setPagein interfaceWritableBookMeta- Parameters:
page- the page number to set, in range [1, getPageCount()]data- the data to set for that page- Since:
- 1.4.5
-
getPages
Deprecated.usepages()Description copied from interface:WritableBookMetaGets all the pages in the book.- Specified by:
getPagesin interfaceWritableBookMeta- Returns:
- list of all the pages in the book
- Since:
- 1.4.5
-
setPages
Deprecated.usepages(List)Description copied from interface:WritableBookMetaClears the existing book pages, and sets the book to use the provided pages. Maximum 100 pages with 1024 characters per page.- Specified by:
setPagesin interfaceWritableBookMeta- Parameters:
pages- A list of pages to set the book to use- Since:
- 1.4.5
-
setPages
Deprecated.Description copied from interface:WritableBookMetaClears the existing book pages, and sets the book to use the provided pages. Maximum 100 pages with 1024 characters per page.- Specified by:
setPagesin interfaceWritableBookMeta- Parameters:
pages- A list of strings, each being a page- Since:
- 1.4.5
-
addPage
Deprecated.Description copied from interface:WritableBookMetaAdds new pages to the end of the book. Up to a maximum of 100 pages with 1024 characters per page.- Specified by:
addPagein interfaceWritableBookMeta- Parameters:
pages- A list of strings, each being a page- Since:
- 1.4.5
-
title
@Nullable net.kyori.adventure.text.Component title()Gets the title of the book.Plugins should check that hasTitle() returns true before calling this method.
- Returns:
- the title of the book
- Since:
- 1.16.5
-
title
-
author
@Nullable net.kyori.adventure.text.Component author()Gets the author of the book.Plugins should check that hasAuthor() returns true before calling this method.
- Returns:
- the author of the book
- Since:
- 1.16.5
-
author
-
page
@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
- Since:
- 1.16.5
-
page
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- Since:
- 1.16.5
-
addPages
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- Since:
- 1.16.5
-
pages
Gets the list of pages.The returned collection will be unmodifiable.
- Returns:
- the list of pages
- Since:
- 26.2
-
pages
-
pages
@Contract("_ -> this") @NotNull default @NotNull BookMeta pages(@NotNull @NotNull net.kyori.adventure.text.Component @NotNull ... pages) Sets the pages of the book.- Parameters:
pages- the pages to set- Returns:
- this book instance
- Since:
- 26.2
-
spigot
- Since:
- 1.12.2
-
addPages(net.kyori.adventure.text.Component...)