Skip to Content
⚠ Under Construction
ReferenceC++ APIItemMeta

endstone::ItemMeta

Represents the metadata of a generic item.

Types:

NameDescription
Type

Functions:

NameDescription
addEnchantAdds the specified enchantment to this item meta.
cloneCreates a clone of the current metadata.
getDamageGets the damage.
getDisplayNameGets the display name that is set.
getEnchantLevelChecks for the level of the specified enchantment.
getEnchantsReturns a copy the enchantments in this ItemMeta .
getLoreGets the lore that is set.
getRepairCostGets the repair penalty.
getTypeGets the type of this item meta.
hasDamageChecks to see if this item has damage.
hasDisplayNameChecks for existence of a display name.
hasEnchantChecks for existence of the specified enchantment.
hasEnchantsChecks for the existence of any enchantments.
hasLoreChecks for existence of lore.
hasRepairCostChecks to see if this has a repair penalty.
isEmptyChecks if the item metadata is empty.
isUnbreakableReturn if the unbreakable tag is true. An unbreakable item will not lose durability.
removeEnchantRemoves the specified enchantment from this item meta.
removeEnchantsRemoves all enchantments from this item meta.
setDamageSets the damage.
setDisplayNameSets the display name.
setLoreSets the lore for this item or removes lore when given std::nullopt.
setRepairCostSets the repair penalty.
setUnbreakableSets the unbreakable tag. An unbreakable item will not lose durability.

Type

enum Type { Item = 0, Map = 1, Count, None = Item };

addEnchant

bool addEnchant(const std::string &id, int level, bool force)

Adds the specified enchantment to this item meta.

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

clone

std::unique_ptr<ItemMeta> clone() const

Creates a clone of the current metadata.

Returns:

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

getDamage

int getDamage() const

Gets the damage.

Returns:

the damage

getDisplayName

std::optional<std::string> getDisplayName() const

Gets the display name that is set.

Returns:

the display name that is set

getEnchantLevel

int getEnchantLevel(const std::string &id) const

Checks for the level of the specified enchantment.

Parameters:

  • id enchantment id to check

Returns:

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

getEnchants

std::unordered_map<std::string, int> getEnchants() const

Returns a copy the enchantments in this ItemMeta .

Returns an empty map if none.

Returns:

An immutable copy of the enchantments

getLore

std::optional<std::vector<std::string>> getLore() const

Gets the lore that is set.

Returns:

a list of lore that is set

getRepairCost

int getRepairCost() const

Gets the repair penalty.

Returns:

the repair penalty

getType

Type getType() const

Gets the type of this item meta.

Returns:

type of this item meta

hasDamage

bool hasDamage() const

Checks to see if this item has damage.

Returns:

true if this has damage

hasDisplayName

bool hasDisplayName() const

Checks for existence of a display name.

Returns:

true if this has a display name

hasEnchant

bool hasEnchant(const std::string &id) const

Checks for existence of the specified enchantment.

Parameters:

  • id enchantment id to check

Returns:

true if this enchantment exists for this meta

hasEnchants

bool hasEnchants() const

Checks for the existence of any enchantments.

Returns:

true if an enchantment exists on this meta

hasLore

bool hasLore() const

Checks for existence of lore.

Returns:

true if this has lore

hasRepairCost

bool hasRepairCost() const

Checks to see if this has a repair penalty.

Returns:

true if this has a repair penalty

isEmpty

bool isEmpty() const

Checks if the item metadata is empty.

Returns:

true if the metadata is empty, false otherwise.

isUnbreakable

bool isUnbreakable() const

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

Returns:

true if the unbreakable tag is true

removeEnchant

bool removeEnchant(const std::string &id)

Removes the specified enchantment from this item meta.

Parameters:

Returns:

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

removeEnchants

void removeEnchants()

Removes all enchantments from this item meta.

setDamage

void setDamage(int damage)

Sets the damage.

Parameters:

  • damage item damage

setDisplayName

void setDisplayName(std::optional<std::string> name)

Sets the display name.

Parameters:

  • name the name to set

setLore

void setLore(std::optional<std::vector<std::string>> lore)

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

Parameters:

  • lore the lore that will be set

setRepairCost

void setRepairCost(int cost)

Sets the repair penalty.

Parameters:

  • cost repair penalty

setUnbreakable

void setUnbreakable(bool unbreakable)

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

Parameters:

  • unbreakable true if set unbreakable
Last updated on