Skip to content

Class endstone::ItemMeta

ClassList > endstone > ItemMeta

Represents the metadata of a generic item.

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

Inherited by the following classes: endstone::MapMeta

Public Types

Type Name
enum Type

Public Functions

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 ~ItemMeta () = default

Public Types Documentation

enum Type

enum endstone::ItemMeta::Type {
    Item,
    Map
};

Public Functions Documentation

function addEnchant

Adds the specified enchantment to this item meta.

virtual bool endstone::ItemMeta::addEnchant (
    EnchantmentId id,
    int level,
    bool force
) = 0

Parameters:

  • id Enchantment id to add
  • level Level for the enchantment
  • force this indicates the enchantment should be applied, ignoring the level limit

Returns:

true if the item meta changed as a result of this call, false otherwise


function as [½]

template<typename  T>
inline T * endstone::ItemMeta::as () 

function as [2/2]

template<typename  T>
inline const  T * endstone::ItemMeta::as () const

function clone

Creates a clone of the current metadata.

virtual std::unique_ptr< ItemMeta > endstone::ItemMeta::clone () const = 0

Returns:

A copy of the metadata containing the same state as the original.


function getDamage

Gets the damage.

virtual int endstone::ItemMeta::getDamage () const = 0

Returns:

the damage


function getDisplayName

Gets the display name that is set.

virtual std::string endstone::ItemMeta::getDisplayName () const = 0

Returns:

the display name that is set


function getEnchantLevel

Checks for the level of the specified enchantment.

virtual int endstone::ItemMeta::getEnchantLevel (
    EnchantmentId id
) const = 0

Parameters:

  • id enchantment id to check

Returns:

The level that the specified enchantment has, or 0 if none


function getEnchants

Returns a copy the enchantments in this ItemMeta .

virtual std::unordered_map< const  Enchantment *, int > endstone::ItemMeta::getEnchants () const = 0

Returns an empty map if none.

Returns:

An immutable copy of the enchantments


function getLore

Gets the lore that is set.

virtual std::vector< std::string > endstone::ItemMeta::getLore () const = 0

Returns:

a list of lore that is set


function getRepairCost

Gets the repair penalty.

virtual int endstone::ItemMeta::getRepairCost () const = 0

Returns:

the repair penalty


function getType

Gets the type of this item meta.

virtual Type endstone::ItemMeta::getType () const = 0

Returns:

type of this item meta


function hasConflictingEnchant

virtual bool endstone::ItemMeta::hasConflictingEnchant (
    EnchantmentId id
) const = 0

Checks if the specified enchantment conflicts with any enchantments in this ItemMeta.

Parameters:

Returns:

true if the enchantment conflicts, false otherwise


function hasDamage

Checks to see if this item has damage.

virtual bool endstone::ItemMeta::hasDamage () const = 0

Returns:

true if this has damage


function hasDisplayName

Checks for existence of a display name.

virtual bool endstone::ItemMeta::hasDisplayName () const = 0

Returns:

true if this has a display name


function hasEnchant

Checks for existence of the specified enchantment.

virtual bool endstone::ItemMeta::hasEnchant (
    EnchantmentId id
) const = 0

Parameters:

  • id enchantment id to check

Returns:

true if this enchantment exists for this meta


function hasEnchants

Checks for the existence of any enchantments.

virtual bool endstone::ItemMeta::hasEnchants () const = 0

Returns:

true if an enchantment exists on this meta


function hasLore

Checks for existence of lore.

virtual bool endstone::ItemMeta::hasLore () const = 0

Returns:

true if this has lore


function hasRepairCost

Checks to see if this has a repair penalty.

virtual bool endstone::ItemMeta::hasRepairCost () const = 0

Returns:

true if this has a repair penalty


function isUnbreakable

Return if the unbreakable tag is true. An unbreakable item will not lose durability.

virtual bool endstone::ItemMeta::isUnbreakable () const = 0

Returns:

true if the unbreakable tag is true


function removeEnchant

Removes the specified enchantment from this item meta.

virtual bool endstone::ItemMeta::removeEnchant (
    EnchantmentId id
) = 0

Parameters:

Returns:

true if the item meta changed as a result of this call, false otherwise


function removeEnchants

Removes all enchantments from this item meta.

virtual void endstone::ItemMeta::removeEnchants () = 0


function setDamage

Sets the damage.

virtual void endstone::ItemMeta::setDamage (
    int damage
) = 0

Parameters:

  • damage item damage

function setDisplayName

Sets the display name.

virtual void endstone::ItemMeta::setDisplayName (
    std::optional< std::string > name
) = 0

Parameters:

  • name the name to set

function setLore

Sets the lore for this item or removes lore when given std::nullopt .

virtual void endstone::ItemMeta::setLore (
    std::optional< std::vector< std::string > > lore
) = 0

Parameters:

  • lore the lore that will be set

function setRepairCost

Sets the repair penalty.

virtual void endstone::ItemMeta::setRepairCost (
    int cost
) = 0

Parameters:

  • cost repair penalty

function setUnbreakable

Sets the unbreakable tag. An unbreakable item will not lose durability.

virtual void endstone::ItemMeta::setUnbreakable (
    bool unbreakable
) = 0

Parameters:

  • unbreakable true if set unbreakable

function ~ItemMeta

virtual endstone::ItemMeta::~ItemMeta () = default


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