Skip to content

Class endstone::BookMeta

ClassList > endstone > BookMeta

Represents the meta for a written book that can have a title, an author, and pages.

  • #include <endstone/inventory/meta/book_meta.h>

Inherits the following classes: endstone::WritableBookMeta

Public Types

Type Name
enum Generation
Represents the generation (or level of copying) of a written book.

Public Types inherited from endstone::ItemMeta

See endstone::ItemMeta

Type Name
enum Type

Public Functions

Type Name
virtual std::string getAuthor () const = 0
Gets the author of the book.
virtual std::optional< Generation > getGeneration () const = 0
Gets the generation of the book.
virtual std::string getTitle () const = 0
Gets the title of the book.
virtual bool hasAuthor () const = 0
Checks for the existence of an author in the book.
virtual bool hasGeneration () const = 0
Checks for the existence of generation level in the book.
virtual bool hasTitle () const = 0
Checks for the existence of a title in the book.
virtual void setAuthor (std::optional< std::string > author) = 0
Sets the author of the book. Removes author when given std::nullopt.
virtual void setGeneration (std::optional< Generation > generation) = 0
Sets the generation of the book. Removes generation when given std::nullopt.
virtual void setTitle (std::optional< std::string > title) = 0
Sets the title of the book.

Public Functions inherited from endstone::WritableBookMeta

See endstone::WritableBookMeta

Type Name
void addPage (Args &&... pages)
Adds new pages to the end of the book.
virtual void addPage (std::vector< std::string > pages) = 0
Adds new pages to the end of the book.
virtual std::string getPage (int page) const = 0
Gets the specified page in the book. The given page must exist.
virtual int getPageCount () const = 0
Gets the number of pages in the book.
virtual std::vector< std::string > getPages () const = 0
Gets all the pages in the book.
virtual bool hasPages () const = 0
Checks for the existence of pages in the book.
virtual void setPage (int page, std::string data) = 0
Sets the specified page in the book. Pages of the book must be contiguous.
void setPages (Args &&... pages)
Clears the existing book pages, and sets the book to use the provided pages.
virtual void setPages (std::vector< std::string > pages) = 0
Maximum 50 pages with 798 characters per page.

Public Functions inherited from endstone::ItemMeta

See endstone::ItemMeta

Type Name
virtual bool addEnchant (EnchantmentId id, int level, bool force) = 0
Adds the specified enchantment to this item meta.
T * as ()
const T * as () const
virtual std::unique_ptr< ItemMeta > clone () const = 0
Creates a clone of the current metadata.
virtual int getDamage () const = 0
Gets the damage.
virtual std::string getDisplayName () const = 0
Gets the display name that is set.
virtual int getEnchantLevel (EnchantmentId id) const = 0
Checks for the level of the specified enchantment.
virtual std::unordered_map< const Enchantment *, int > getEnchants () const = 0
Returns a copy the enchantments in this ItemMeta .
virtual std::vector< std::string > getLore () const = 0
Gets the lore that is set.
virtual int getRepairCost () const = 0
Gets the repair penalty.
virtual Type getType () const = 0
Gets the type of this item meta.
virtual bool hasConflictingEnchant (EnchantmentId id) const = 0
virtual bool hasDamage () const = 0
Checks to see if this item has damage.
virtual bool hasDisplayName () const = 0
Checks for existence of a display name.
virtual bool hasEnchant (EnchantmentId id) const = 0
Checks for existence of the specified enchantment.
virtual bool hasEnchants () const = 0
Checks for the existence of any enchantments.
virtual bool hasLore () const = 0
Checks for existence of lore.
virtual bool hasRepairCost () const = 0
Checks to see if this has a repair penalty.
virtual bool isUnbreakable () const = 0
Return if the unbreakable tag is true. An unbreakable item will not lose durability.
virtual bool removeEnchant (EnchantmentId id) = 0
Removes the specified enchantment from this item meta.
virtual void removeEnchants () = 0
Removes all enchantments from this item meta.
virtual void setDamage (int damage) = 0
Sets the damage.
virtual void setDisplayName (std::optional< std::string > name) = 0
Sets the display name.
virtual void setLore (std::optional< std::vector< std::string > > lore) = 0
Sets the lore for this item or removes lore when given std::nullopt .
virtual void setRepairCost (int cost) = 0
Sets the repair penalty.
virtual void setUnbreakable (bool unbreakable) = 0
Sets the unbreakable tag. An unbreakable item will not lose durability.
virtual CompoundTag toNbt () const = 0
virtual ~ItemMeta () = default

Public Types Documentation

enum Generation

Represents the generation (or level of copying) of a written book.

enum endstone::BookMeta::Generation {
    Original,
    CopyOfOriginal,
    CopyOfCopy
};


Public Functions Documentation

function getAuthor

Gets the author of the book.

virtual std::string endstone::BookMeta::getAuthor () const = 0

Note:

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

Returns:

the author of the book


function getGeneration

Gets the generation of the book.

virtual std::optional< Generation > endstone::BookMeta::getGeneration () const = 0

Note:

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

Returns:

the generation of the book


function getTitle

Gets the title of the book.

virtual std::string endstone::BookMeta::getTitle () const = 0

Note:

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

Returns:

the title of the book


function hasAuthor

Checks for the existence of an author in the book.

virtual bool endstone::BookMeta::hasAuthor () const = 0

Returns:

true if the book has an author


function hasGeneration

Checks for the existence of generation level in the book.

virtual bool endstone::BookMeta::hasGeneration () const = 0

Returns:

true if the book has a generation level


function hasTitle

Checks for the existence of a title in the book.

virtual bool endstone::BookMeta::hasTitle () const = 0

Returns:

true if the book has a title


function setAuthor

Sets the author of the book. Removes author when given std::nullopt.

virtual void endstone::BookMeta::setAuthor (
    std::optional< std::string > author
) = 0

Parameters:

  • author the author to set

function setGeneration

Sets the generation of the book. Removes generation when given std::nullopt.

virtual void endstone::BookMeta::setGeneration (
    std::optional< Generation > generation
) = 0

Parameters:

  • generation the generation to set

function setTitle

Sets the title of the book.

virtual void endstone::BookMeta::setTitle (
    std::optional< std::string > title
) = 0

Note:

Limited to 32 characters. Removes title when given std::nullopt.

Parameters:

  • title the title to set

Returns:

true if the title was successfully set



The documentation for this class was generated from the following file include/endstone/inventory/meta/book_meta.h