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,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.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic enumRepresents the generation (or level of copying) of a written bookstatic classNested classes/interfaces inherited from interface net.kyori.adventure.inventory.Book
net.kyori.adventure.inventory.Book.Builder -
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.useBook.pages()@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.voidSets the author of the book.voidsetGeneration(@Nullable BookMeta.Generation generation) Sets the generation of the book.voidDeprecated.voidDeprecated.useBook.pages(net.kyori.adventure.text.Component...)voidDeprecated.useBook.pages(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.@NotNull BookMeta.BookMetaBuilderCreate a new builder initialized with the attributes of this book.Methods inherited from interface net.kyori.adventure.inventory.Book
pages, pages, pagesMethods inherited from interface org.bukkit.configuration.serialization.ConfigurationSerializable
serializeMethods inherited from interface net.kyori.examination.Examinable
examinableName, examinableProperties, examineMethods inherited from interface org.bukkit.inventory.meta.ItemMeta
addAttributeModifier, addEnchant, addItemFlags, customName, customName, displayName, displayName, getAsComponentString, getAsString, getAttributeModifiers, getAttributeModifiers, getAttributeModifiers, getCanDestroy, getCanPlaceOn, getCustomModelData, getCustomModelDataComponent, getCustomTagContainer, getDamageResistant, 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, 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 org.bukkit.persistence.PersistentDataHolder
getPersistentDataContainerMethods inherited from interface org.bukkit.inventory.meta.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
-
getTitle
Gets the title of the book.Plugins should check that hasTitle() returns true before calling this method.
- Returns:
- the title of the book
-
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
-
hasAuthor
boolean hasAuthor()Checks for the existence of an author in the book.- Returns:
- true if the book has an author
-
getAuthor
Gets the author of the book.Plugins should check that hasAuthor() returns true before calling this method.
- Returns:
- the author of the book
-
setAuthor
Sets the author of the book. Removes author when given null.- Parameters:
author- the author to set
-
hasGeneration
boolean hasGeneration()Checks for the existence of generation level in the book.- Returns:
- true if the book has a generation level
-
getGeneration
Gets the generation of the book.Plugins should check that hasGeneration() returns true before calling this method.
- Returns:
- the generation of the book
-
setGeneration
Sets the generation of the book. Removes generation when given null.- Parameters:
generation- the generation to set
-
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
-
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
-
getPages
Deprecated.useBook.pages()Description copied from interface:WritableBookMetaGets all the pages in the book.- Specified by:
getPagesin interfaceWritableBookMeta- Returns:
- list of all the pages in the book
-
setPages
Deprecated.useBook.pages(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
-
setPages
Deprecated.useBook.pages(net.kyori.adventure.text.Component...)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
-
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
-
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.
- Specified by:
titlein interfacenet.kyori.adventure.inventory.Book- Returns:
- the title of the book
-
title
@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:
titlein interfacenet.kyori.adventure.inventory.Book- Parameters:
title- the title to set- Returns:
- the same
BookMetainstance
-
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.
- Specified by:
authorin interfacenet.kyori.adventure.inventory.Book- Returns:
- the author of the book
-
author
@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:
authorin interfacenet.kyori.adventure.inventory.Book- Parameters:
author- the author to set- Returns:
- the same
BookMetainstance
-
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
-
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
-
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
-
toBuilder
Description copied from interface:net.kyori.adventure.inventory.BookCreate a new builder initialized with the attributes of this book.- Specified by:
toBuilderin interfacenet.kyori.adventure.inventory.Book- Specified by:
toBuilderin interfacenet.kyori.adventure.util.Buildable<net.kyori.adventure.inventory.Book,net.kyori.adventure.inventory.Book.Builder> - Returns:
- the builder
-
spigot
-
addPages(net.kyori.adventure.text.Component...)