endstone/inventory

Classes

NameDescription
BookMetaRepresents the meta for a written book that can have a title, an author, and pages.
CrossbowMetaRepresents the meta for a crossbow that can have charged projectiles.
Impl
InventoryInterface to the various inventories.
ItemFactory
ItemMetaRepresents the metadata of a generic item.
ItemStackRepresents a stack of items.
ItemType
MapMetaRepresents the metadata for a map item.
PlayerInventoryInterface to the inventory of a Player, including the four armor slots and any extra slots.
RecipeRepresents some type of crafting recipe.
WritableBookMetaRepresents the meta for a writable book that can have pages.

Enums

NameDescription
EquipmentSlot

Type Aliases

NameDescription
ItemTypeIdRepresents an item type.

classBookMeta

Defined in <endstone/inventory/meta/book_meta.h>

Bases: WritableBookMeta

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

Enums

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

Methods

NameDescription
hasTitleChecks for the existence of a title in the book.
getTitleGets the title of the book.
setTitleSets the title of the book.
hasAuthorChecks for the existence of an author in the book.
getAuthorGets the author of the book.
setAuthorSets the author of the book. Removes author when given std::nullopt.
hasGenerationChecks for the existence of generation level in the book.
getGenerationGets the generation of the book.
setGenerationSets the generation of the book. Removes generation when given std::nullopt.

enumGeneration

Generation

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

Values

NameValueDescription
OriginalBook written into a book-and-quill. Can be copied. (Default value)
CopyOfOriginalBook that was copied from an original. Can be copied.
CopyOfCopyBook that was copied from a copy of an original. Can't be copied.

methhasTitleabstractconst

bool hasTitle() const =0

Checks for the existence of a title in the book.

Returns

TypeDescription
booltrue if the book has a title

methgetTitleabstractconst

std::string getTitle() const =0

Gets the title of the book.

Note

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

Returns

TypeDescription
std::stringthe title of the book

methsetTitleabstract

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

Sets the title of the book.

Note

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

Parameters

NameTypeDescription
titlestd::optional<std::string>the title to set

Returns

TypeDescription
voidtrue if the title was successfully set

methhasAuthorabstractconst

bool hasAuthor() const =0

Checks for the existence of an author in the book.

Returns

TypeDescription
booltrue if the book has an author

methgetAuthorabstractconst

std::string getAuthor() const =0

Gets the author of the book.

Note

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

Returns

TypeDescription
std::stringthe author of the book

methsetAuthorabstract

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

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

Parameters

NameTypeDescription
authorstd::optional<std::string>the author to set

methhasGenerationabstractconst

bool hasGeneration() const =0

Checks for the existence of generation level in the book.

Returns

TypeDescription
booltrue if the book has a generation level

methgetGenerationabstractconst

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

Gets the generation of the book.

Note

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

Returns

TypeDescription
std::optional<Generation>the generation of the book

methsetGenerationabstract

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

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

Parameters

NameTypeDescription
generationstd::optional<Generation>the generation to set

classCrossbowMeta

Defined in <endstone/inventory/meta/crossbow_meta.h>

Bases: ItemMeta

Represents the meta for a crossbow that can have charged projectiles.

Methods

NameDescription
hasChargedProjectilesReturns whether the item has any charged projectiles.
getChargedProjectilesReturns an immutable list of the projectiles charged on this item.
setChargedProjectilesSets the projectiles charged on this item.
addChargedProjectileAdds a charged projectile to this item.

methhasChargedProjectilesabstractconst

bool hasChargedProjectiles() const =0

Returns whether the item has any charged projectiles.

Returns

TypeDescription
boolwhether charged projectiles are present

methgetChargedProjectilesabstractconst

std::vector<ItemStack> getChargedProjectiles() const =0

Returns an immutable list of the projectiles charged on this item.

Returns

TypeDescription
std::vector<ItemStack>charged projectiles

methsetChargedProjectilesabstract

void setChargedProjectiles(std::vector<ItemStack> projectiles) =0

Sets the projectiles charged on this item.

Parameters

NameTypeDescription
projectilesstd::vector<ItemStack>the projectiles to set

methaddChargedProjectileabstract

void addChargedProjectile(const ItemStack& item) =0

Adds a charged projectile to this item.

Parameters

NameTypeDescription
itemconst ItemStack&projectile

classImpl

Defined in <endstone/inventory/item_stack.h>

Methods

meth~Implvirtual

~Impl() =default

methcloneabstractconst

std::unique_ptr<Impl> clone() const =0

methgetTypeabstractconst

const ItemType& getType() const =0

methsetTypeabstract

void setType(ItemTypeId type) =0

methgetAmountabstractconst

int getAmount() const =0

methsetAmountabstract

void setAmount(int amount) =0

methgetDataabstractconst

int getData() const =0

methsetDataabstract

void setData(int data) =0

methgetTranslationKeyabstractconst

std::string getTranslationKey() const =0

methgetMaxStackSizeabstractconst

int getMaxStackSize() const =0

methisSimilarabstractconst

bool isSimilar(const Impl& other) const =0

methgetItemMetaabstractconst

std::unique_ptr<ItemMeta> getItemMeta() const =0

methhasItemMetaabstractconst

bool hasItemMeta() const =0

methsetItemMetaabstract

bool setItemMeta(const ItemMeta* meta) =0

methgetNbtabstractconst

CompoundTag getNbt() const =0

methsetNbtabstract

void setNbt(const CompoundTag& nbt) =0

classInventory

Defined in <endstone/inventory/inventory.h>

Interface to the various inventories.

Methods

NameDescription
~Inventory
getSizeReturns the size of the inventory.
getMaxStackSizeReturns the maximum stack size for an ItemStack in this inventory.
getItemReturns the ItemStack found in the slot at the given index.
setItemStores the ItemStack at the given index of the inventory.
addItemStores the given ItemStacks in the inventory.
removeItemRemoves the given ItemStacks from the inventory.
addItemStores the given ItemStacks in the inventory.
removeItemRemoves the given ItemStacks from the inventory.
getContentsReturns all ItemStacks from the inventory.
setContentsCompletely replaces the inventory's contents. Removes all existing contents and replaces it with the ItemStacks given in the array.
containsChecks if the inventory contains any ItemStacks with the given ItemType.
containsChecks if the inventory contains any ItemStacks with the given ItemStack.
containsChecks if the inventory contains at least the minimum amount specified of exactly matching ItemStacks.
containsAtLeastChecks if the inventory contains any ItemStacks with the given ItemType, adding to at least the minimum amount specified.
containsAtLeastChecks if the inventory contains ItemStacks matching the given ItemStack whose amounts sum to at least the minimum amount specified.
allFinds all slots in the inventory containing any ItemStacks with the given ItemType.
allFinds all slots in the inventory containing any ItemStacks with the given ItemStack.
firstFinds the first slot in the inventory containing an ItemStack with the given ItemType.
firstReturns the first slot in the inventory containing an ItemStack with the given stack.
firstEmptyReturns the first empty Slot.
isEmptyCheck whether this inventory is empty. An inventory is considered to be empty if there are no ItemStacks in any slot of this inventory.
removeRemoves all stacks in the inventory matching the given ItemType.
removeRemoves all stacks in the inventory matching the given stack.
clearClears out a particular slot in the index.
clearClears out the whole Inventory.

meth~Inventoryvirtual

~Inventory() =default

methgetSizeabstractconst

int getSize() const =0

Returns the size of the inventory.

Returns

TypeDescription
intThe size of the inventory

methgetMaxStackSizeabstractconst

int getMaxStackSize() const =0

Returns the maximum stack size for an ItemStack in this inventory.

Returns

TypeDescription
intThe maximum size for an ItemStack in this inventory.

methgetItemabstractconst

std::optional<ItemStack> getItem(int index) const =0

Returns the ItemStack found in the slot at the given index.

Parameters

NameTypeDescription
indexintThe index of the Slot's ItemStack to return

Returns

TypeDescription
std::optional<ItemStack>The ItemStack in the slot

methsetItemabstract

void setItem(int index, std::optional<ItemStack> item) =0

Stores the ItemStack at the given index of the inventory.

Parameters

NameTypeDescription
indexintThe index where to put the ItemStack
itemstd::optional<ItemStack>The ItemStack to set

methaddItemabstract

Stores the given ItemStacks in the inventory.

Note

This will try to fill existing stacks and empty slots as well as it can.

Note

The returned map contains what it couldn't store, where the key is the index, and the value is the ItemStack. If all items are stored, it will return an empty map.

Parameters

NameTypeDescription
itemsstd::vector<ItemStack>The ItemStacks to add

Returns

TypeDescription
std::unordered_map<int, ItemStack>A map containing items that couldn't be added.

methremoveItemabstract

Removes the given ItemStacks from the inventory.

Note

It will try to remove 'as much as possible' from the types and amounts you give as arguments.

Note

The returned HashMap contains what it couldn't remove, where the key is the index, and the value is the ItemStack. If all the given ItemStacks are removed, it will return an empty map.

Parameters

NameTypeDescription
itemsstd::vector<ItemStack>The ItemStacks to remove

Returns

TypeDescription
std::unordered_map<int, ItemStack>A map containing items that couldn't be removed.

methaddItem

std::unordered_map<int, ItemStack> addItem(Args&&... items)

Stores the given ItemStacks in the inventory.

Note

This will try to fill existing stacks and empty slots as well as it can.

Note

The returned map contains what it couldn't store, where the key is the index, and the value is the ItemStack. If all items are stored, it will return an empty map.

Parameters

NameTypeDescription
itemsArgs&&...The ItemStacks to add

Returns

TypeDescription
std::unordered_map<int, ItemStack>A map containing items that couldn't be added.

methremoveItem

std::unordered_map<int, ItemStack> removeItem(Args&&... items)

Removes the given ItemStacks from the inventory.

Note

It will try to remove 'as much as possible' from the types and amounts you give as arguments.

Note

The returned HashMap contains what it couldn't remove, where the key is the index, and the value is the ItemStack. If all the given ItemStacks are removed, it will return an empty map.

Parameters

NameTypeDescription
itemsArgs&&...The ItemStacks to remove

Returns

TypeDescription
std::unordered_map<int, ItemStack>A map containing items that couldn't be removed.

methgetContentsabstractconst

std::vector<std::optional<ItemStack>> getContents() const =0

Returns all ItemStacks from the inventory.

Returns

TypeDescription
std::vector<std::optional<ItemStack>>An array of ItemStacks from the inventory. Empty slots are represented as std::nullopt.

methsetContentsabstract

void setContents(std::vector<std::optional<ItemStack>> items) =0

Completely replaces the inventory's contents. Removes all existing contents and replaces it with the ItemStacks given in the array.

Parameters

NameTypeDescription
itemsstd::vector<std::optional<ItemStack>>A complete replacement for the contents; the length must be less than or equal to getSize().

methcontainsabstractconst

bool contains(const std::string& type) const =0

Checks if the inventory contains any ItemStacks with the given ItemType.

Parameters

NameTypeDescription
typeconst std::string&The item type to check for

Returns

TypeDescription
booltrue if an ItemStack is found with the given ItemType

methcontainsabstractconst

bool contains(const ItemStack& item) const =0

Checks if the inventory contains any ItemStacks with the given ItemStack.

Note

This will only return true if both the type and the amount of the stack match.

Parameters

NameTypeDescription
itemconst ItemStack&The ItemStack to match against

Returns

TypeDescription
booltrue if any exactly matching ItemStacks were found, false otherwise

methcontainsabstractconst

bool contains(const ItemStack& item, int amount) const =0

Checks if the inventory contains at least the minimum amount specified of exactly matching ItemStacks.

Note

An ItemStack only counts if both the type and the amount of the stack match.

Parameters

NameTypeDescription
itemconst ItemStack&the ItemStack to match against
amountinthow many identical stacks to check for

Returns

TypeDescription
booltrue if amount less than 1 or if amount of exactly matching ItemStacks were found, false otherwise

methcontainsAtLeastabstractconst

bool containsAtLeast(const std::string& type, int amount) const =0

Checks if the inventory contains any ItemStacks with the given ItemType, adding to at least the minimum amount specified.

Parameters

NameTypeDescription
typeconst std::string&The ItemType to check for
amountintThe minimum amount

Returns

TypeDescription
booltrue if amount is less than 1, true if enough ItemStacks were found to add to the given amount

methcontainsAtLeastabstractconst

bool containsAtLeast(const ItemStack& item, int amount) const =0

Checks if the inventory contains ItemStacks matching the given ItemStack whose amounts sum to at least the minimum amount specified.

Parameters

NameTypeDescription
itemconst ItemStack&the ItemStack to match against
amountintthe minimum amount

Returns

TypeDescription
booltrue if amount less than 1 or enough ItemStacks were found to add to the given amount, false otherwise

methallabstractconst

std::unordered_map<int, ItemStack> all(const std::string& type) const =0

Finds all slots in the inventory containing any ItemStacks with the given ItemType.

The returned map contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ItemStack is found, an empty map is returned.

Parameters

NameTypeDescription
typeconst std::string&The ItemType to match against

Returns

TypeDescription
std::unordered_map<int, ItemStack>A map from slot indexes to item at index

methallabstractconst

std::unordered_map<int, ItemStack> all(const ItemStack& item) const =0

Finds all slots in the inventory containing any ItemStacks with the given ItemStack.

Note

This will only match slots if both the type and the amount of the stack match

The returned map contains entries where, the key is the slot index, and the value is the ItemStack in that slot. If no matching ItemStack is found, an empty map is returned.

Parameters

NameTypeDescription
itemconst ItemStack&The ItemStack to match against

Returns

TypeDescription
std::unordered_map<int, ItemStack>A map from slot indexes to item at index

methfirstabstractconst

int first(const std::string& type) const =0

Finds the first slot in the inventory containing an ItemStack with the given ItemType.

Parameters

NameTypeDescription
typeconst std::string&The ItemType to look for

Returns

TypeDescription
intThe slot index of the given ItemType or -1 if not found

methfirstabstractconst

int first(const ItemStack& item) const =0

Returns the first slot in the inventory containing an ItemStack with the given stack.

Parameters

NameTypeDescription
itemconst ItemStack&The ItemStack to match against

Returns

TypeDescription
intThe slot index of the given ItemStack or -1 if not found

methfirstEmptyabstractconst

int firstEmpty() const =0

Returns the first empty Slot.

Returns

TypeDescription
intThe first empty Slot found, or -1 if no empty slots.

methisEmptyabstractconst

bool isEmpty() const =0

Check whether this inventory is empty. An inventory is considered to be empty if there are no ItemStacks in any slot of this inventory.

Returns

TypeDescription
booltrue if empty, false otherwise

methremoveabstract

void remove(const std::string& type) =0

Removes all stacks in the inventory matching the given ItemType.

Parameters

NameTypeDescription
typeconst std::string&The ItemType to remove

methremoveabstract

void remove(const ItemStack& item) =0

Removes all stacks in the inventory matching the given stack.

Note

This will only match a slot if both the type and the amount of the stack match

Parameters

NameTypeDescription
itemconst ItemStack&The ItemStack to match against

methclearabstract

void clear(int index) =0

Clears out a particular slot in the index.

Parameters

NameTypeDescription
indexintThe index to empty.

methclearabstract

void clear() =0

Clears out the whole Inventory.

classItemFactory

Defined in <endstone/inventory/item_factory.h>

Methods

NameDescription
~ItemFactory
getItemMetaThis creates a new item meta for the item type.
isApplicableThis method checks the item meta to confirm that it is applicable (no data lost if applied) to the specified ItemStack.
equalsThis method is used to compare two ItemMeta objects.
asMetaForReturns an appropriate item meta for the specified item type.

meth~ItemFactoryvirtual

~ItemFactory() =default

methgetItemMetaabstractconst

std::unique_ptr<ItemMeta> getItemMeta(ItemTypeId type) const =0

This creates a new item meta for the item type.

Parameters

NameTypeDescription
typeItemTypeIdThe item type to consider as base for the meta

Returns

TypeDescription
std::unique_ptr<ItemMeta>a new ItemMeta that could be applied to an item stack of the specified item type

methisApplicableabstractconst

bool isApplicable(const ItemMeta* meta, ItemTypeId type) const =0

This method checks the item meta to confirm that it is applicable (no data lost if applied) to the specified ItemStack.

Parameters

NameTypeDescription
metaconst ItemMeta*Meta to check
typeItemTypeIdThe item type that meta will be applied to

Returns

TypeDescription
booltrue if the meta can be applied without losing data, false otherwise

methequalsabstractconst

bool equals(const ItemMeta* meta1, const ItemMeta* meta2) const =0

This method is used to compare two ItemMeta objects.

Parameters

NameTypeDescription
meta1const ItemMeta*First meta to compare, and may be null to indicate no data
meta2const ItemMeta*Second meta to compare, and may be null to indicate no data

Returns

TypeDescription
boolfalse if one of the meta has data the other does not, otherwise true

methasMetaForabstractconst

std::unique_ptr<ItemMeta> asMetaFor(const ItemMeta* meta, ItemTypeId type) const =0

Returns an appropriate item meta for the specified item type.

The item meta returned will always be a valid meta for a given ItemStack of the specified item type. It may be a more or less specific meta, and could also be the same meta or meta type as the parameter. The item meta returned will also always be the most appropriate meta.

Parameters

NameTypeDescription
metaconst ItemMeta*the meta to convert
typeItemTypeIdthe item type to convert the meta for

Returns

TypeDescription
std::unique_ptr<ItemMeta>An appropriate item meta for the specified item type.

classItemMeta

Defined in <endstone/inventory/meta/item_meta.h>

Represents the metadata of a generic item.

Enums

NameDescription
Type

Methods

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

enumType

Type

Values

NameValueDescription
Item
Book
CrossBow
Map
WritableBook

meth~ItemMetavirtual

~ItemMeta() =default

methgetTypeabstractconst

Type getType() const =0

Gets the type of this item meta.

Returns

TypeDescription
Typetype of this item meta

methhasDisplayNameabstractconst

bool hasDisplayName() const =0

Checks for existence of a display name.

Returns

TypeDescription
booltrue if this has a display name

methgetDisplayNameabstractconst

std::string getDisplayName() const =0

Gets the display name that is set.

Returns

TypeDescription
std::stringthe display name that is set

methsetDisplayNameabstract

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

Sets the display name.

Parameters

NameTypeDescription
namestd::optional<std::string>the name to set

methhasLoreabstractconst

bool hasLore() const =0

Checks for existence of lore.

Returns

TypeDescription
booltrue if this has lore

methgetLoreabstractconst

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

Gets the lore that is set.

Returns

TypeDescription
std::vector<std::string>a list of lore that is set

methsetLoreabstract

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

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

Parameters

NameTypeDescription
lorestd::optional<std::vector<std::string>>the lore that will be set

methhasEnchantsabstractconst

bool hasEnchants() const =0

Checks for the existence of any enchantments.

Returns

TypeDescription
booltrue if an enchantment exists on this meta

methhasEnchantabstractconst

bool hasEnchant(EnchantmentId id) const =0

Checks for existence of the specified enchantment.

Parameters

NameTypeDescription
idEnchantmentIdenchantment id to check

Returns

TypeDescription
booltrue if this enchantment exists for this meta

methgetEnchantLevelabstractconst

int getEnchantLevel(EnchantmentId id) const =0

Checks for the level of the specified enchantment.

Parameters

NameTypeDescription
idEnchantmentIdenchantment id to check

Returns

TypeDescription
intThe level that the specified enchantment has, or 0 if none

methgetEnchantsabstractconst

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

Returns a copy the enchantments in this ItemMeta.

Returns an empty map if none.

Returns

TypeDescription
std::unordered_map<const Enchantment*, int>An immutable copy of the enchantments

methaddEnchantabstract

bool addEnchant(EnchantmentId id, int level, bool force) =0

Adds the specified enchantment to this item meta.

Parameters

NameTypeDescription
idEnchantmentIdEnchantment id to add
levelintLevel for the enchantment
forceboolthis indicates the enchantment should be applied, ignoring the level limit

Returns

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

methremoveEnchantabstract

bool removeEnchant(EnchantmentId id) =0

Removes the specified enchantment from this item meta.

Parameters

NameTypeDescription
idEnchantmentIdEnchantment id to remove

Returns

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

methremoveEnchantsabstract

void removeEnchants() =0

Removes all enchantments from this item meta.

methhasConflictingEnchantabstractconst

bool hasConflictingEnchant(EnchantmentId id) const =0

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

Parameters

NameTypeDescription
idEnchantmentIdEnchantment id to test

Returns

TypeDescription
booltrue if the enchantment conflicts, false otherwise

methisUnbreakableabstractconst

bool isUnbreakable() const =0

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

Returns

TypeDescription
booltrue if the unbreakable tag is true

methsetUnbreakableabstract

void setUnbreakable(bool unbreakable) =0

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

Parameters

NameTypeDescription
unbreakablebooltrue if set unbreakable

methhasDamageabstractconst

bool hasDamage() const =0

Checks to see if this item has damage.

Returns

TypeDescription
booltrue if this has damage

methgetDamageabstractconst

int getDamage() const =0

Gets the damage.

Returns

TypeDescription
intthe damage

methsetDamageabstract

void setDamage(int damage) =0

Sets the damage.

Parameters

NameTypeDescription
damageintitem damage

methhasRepairCostabstractconst

bool hasRepairCost() const =0

Checks to see if this has a repair penalty.

Returns

TypeDescription
booltrue if this has a repair penalty

methgetRepairCostabstractconst

int getRepairCost() const =0

Gets the repair penalty.

Returns

TypeDescription
intthe repair penalty

methsetRepairCostabstract

void setRepairCost(int cost) =0

Sets the repair penalty.

Parameters

NameTypeDescription
costintrepair penalty

methcloneabstractconst

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

Creates a clone of the current metadata.

Returns

TypeDescription
std::unique_ptr<ItemMeta>A copy of the metadata containing the same state as the original.

methgetExtrasabstractconst

const core::ItemMetaExtras& getExtras() const =0

methas

T* as()

methasconst

const T* as() const

classItemStack

Defined in <endstone/inventory/item_stack.h>

Represents a stack of items.

Methods

NameDescription
ItemStackAn item stack.
ItemStack
ItemStack
operator=
operator=
~ItemStack
getTypeGets the type of this item.
setTypeSets the type of this item.
getAmountGets the amount of items in this stack.
setAmountSets the amount of items in this stack.
getDataGets the data for this stack of items.
setDataSets the data for this stack of items.
getTranslationKeyGet the translation key, suitable for use in a translation component.
getMaxStackSizeGet the maximum stack size for this item.
getNbtGets the NBT compound tag of this item stack.
setNbtSets the NBT compound tag of this item stack.
operator==
operator!=
isSimilarChecks if the two stacks are equal, but does not consider stack size (amount).
getItemMetaGets a copy of this ItemStack's ItemMeta.
hasItemMetaChecks to see if any metadata has been defined.
setItemMetaSet the ItemMeta of this ItemStack.

methItemStackexplicit

ItemStack(ItemTypeId type, int amount = 1, int data = 0)

An item stack.

Parameters

NameTypeDescription
typeItemTypeIdthe type
amountintthe amount in the stack
dataintthe data value

methItemStack

ItemStack(const ItemStack& other)

methItemStacknoexcept

ItemStack(ItemStack&& other) noexcept=default

methoperator=

ItemStack& operator=(const ItemStack& other)

methoperator=noexcept

ItemStack& operator=(ItemStack&& other) noexcept=default

meth~ItemStack

~ItemStack() =default

methgetTypeconst

const ItemType& getType() const

Gets the type of this item.

Returns

TypeDescription
const ItemType&Type of the items in this stack

methsetType

void setType(ItemTypeId type)

Sets the type of this item.

Parameters

NameTypeDescription
typeItemTypeIdNew type to set the items in this stack to

methgetAmountconst

int getAmount() const

Gets the amount of items in this stack.

Returns

TypeDescription
intAmount of items in this stack

methsetAmount

void setAmount(int amount)

Sets the amount of items in this stack.

Parameters

NameTypeDescription
amountintNew amount of items in this stack

methgetDataconst

int getData() const

Gets the data for this stack of items.

Returns

TypeDescription
intData for this item

methsetData

void setData(int data)

Sets the data for this stack of items.

Parameters

NameTypeDescription
dataintNew data for this item

methgetTranslationKeyconst

std::string getTranslationKey() const

Get the translation key, suitable for use in a translation component.

Returns

TypeDescription
std::stringthe translation key

methgetMaxStackSizeconst

int getMaxStackSize() const

Get the maximum stack size for this item.

Returns

TypeDescription
intThe maximum you can stack this item to.

methgetNbtconst

CompoundTag getNbt() const

Gets the NBT compound tag of this item stack.

Returns

TypeDescription
CompoundTagthe NBT compound tag

methsetNbt

void setNbt(const CompoundTag& nbt)

Sets the NBT compound tag of this item stack.

Parameters

NameTypeDescription
nbtconst CompoundTag&the NBT compound tag to set

methoperator==const

bool operator==(const ItemStack& other) const

methoperator!=const

bool operator!=(const ItemStack& other) const

methisSimilarconst

bool isSimilar(const ItemStack& other) const

Checks if the two stacks are equal, but does not consider stack size (amount).

Parameters

NameTypeDescription
otherconst ItemStack&the item stack to compare to

Returns

TypeDescription
booltrue if the two stacks are equal, ignoring the amount

methgetItemMetaconst

std::unique_ptr<ItemMeta> getItemMeta() const

Gets a copy of this ItemStack's ItemMeta.

Returns

TypeDescription
std::unique_ptr<ItemMeta>a copy of the current ItemStack's ItemMeta

methhasItemMetaconst

bool hasItemMeta() const

Checks to see if any metadata has been defined.

Returns

TypeDescription
boolReturns true if some metadata has been set for this item

methsetItemMeta

bool setItemMeta(ItemMeta* meta)

Set the ItemMeta of this ItemStack.

Parameters

NameTypeDescription
metaItemMeta*new ItemMeta, or null to indicate meta data be cleared.

Returns

TypeDescription
boolTrue if successfully applied ItemMeta

classItemType

Defined in <endstone/inventory/item_type.h>

Bases: Registry<T>::Type

Variables

NameDescription
Air

Methods

NameDescription
getTranslationKeyGet the translation key, suitable for use in a translation component.
getTranslationKeyGet the translation key, suitable for use in a translation component.
getMaxStackSizeGets the maximum amount of this item type that can be held in a stack.
getMaxDurabilityGets the maximum durability of this item type.
createItemStackConstructs a new ItemStack with this item type that has the amount 1.
createItemStackConstructs a new ItemStack with this item type.

varAirstaticconstexpr

auto Air

methgetTranslationKeyabstractconstoverride

std::string getTranslationKey() const override=0

Get the translation key, suitable for use in a translation component.

Returns

TypeDescription
std::stringthe translation key

methgetTranslationKeyabstractconst

std::string getTranslationKey(int data) const =0

Get the translation key, suitable for use in a translation component.

Parameters

NameTypeDescription
dataintData for this item type

Returns

TypeDescription
std::stringthe translation key

methgetMaxStackSizeabstractconst

int getMaxStackSize() const =0

Gets the maximum amount of this item type that can be held in a stack.

Returns

TypeDescription
intMaximum stack size for this item type

methgetMaxDurabilityabstractconst

int getMaxDurability() const =0

Gets the maximum durability of this item type.

Returns

TypeDescription
intMaximum durability for this item type

methcreateItemStackabstractconst

ItemStack createItemStack() const =0

Constructs a new ItemStack with this item type that has the amount 1.

Returns

TypeDescription
ItemStackthe constructed item stack.

methcreateItemStackabstractconst

ItemStack createItemStack(int amount) const =0

Constructs a new ItemStack with this item type.

Parameters

NameTypeDescription
amountintthe amount in the stack

Returns

TypeDescription
ItemStackAn ItemStack of this item type

classMapMeta

Defined in <endstone/inventory/meta/map_meta.h>

Bases: ItemMeta

Represents the metadata for a map item.

Type Aliases

NameDescription
MapId

Methods

NameDescription
hasMapIdChecks for existence of a map ID number.
getMapIdGets the map ID that is set. This is used to determine what map is displayed.
setMapIdSets the map ID. This is used to determine what map is displayed.
hasMapViewChecks for existence of an associated map.
getMapViewGets the map view associated with this map item.
setMapViewSets the associated map. This is used to determine what map is displayed.

typeMapId

methhasMapIdabstractconst

bool hasMapId() const =0

Checks for existence of a map ID number.

Returns

TypeDescription
booltrue if this has a map ID number.

methgetMapIdabstractconst

MapId getMapId() const =0

Gets the map ID that is set. This is used to determine what map is displayed.

Returns

TypeDescription
MapIdthe map ID that is set

methsetMapIdabstract

void setMapId(MapId id) =0

Sets the map ID. This is used to determine what map is displayed.

Parameters

NameTypeDescription
idMapIdthe map id to set

methhasMapViewabstractconst

bool hasMapView() const =0

Checks for existence of an associated map.

Returns

TypeDescription
booltrue if this item has an associated map

methgetMapViewabstractconst

MapView* getMapView() const =0

Gets the map view associated with this map item.

Note

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

Returns

TypeDescription
MapView*the map view, or nullptr if the item hasMapView(), but this map does not exist on the server

methsetMapViewabstract

void setMapView(const MapView* map) =0

Sets the associated map. This is used to determine what map is displayed.

Parameters

NameTypeDescription
mapconst MapView*the map to set

classPlayerInventory

Defined in <endstone/inventory/player_inventory.h>

Bases: Inventory

Interface to the inventory of a Player, including the four armor slots and any extra slots.

Methods

NameDescription
getHelmetReturn the ItemStack from the helmet slot.
getChestplateReturn the ItemStack from the chestplate slot.
getLeggingsReturn the ItemStack from the leg slot.
getBootsReturn the ItemStack from the boots slot.
setHelmetPut the given ItemStack into the helmet slot.
setChestplatePut the given ItemStack into the chestplate slot.
setLeggingsPut the given ItemStack into the leggings slot.
setBootsPut the given ItemStack into the boots slot.
getItemInMainHandGets the item the player is currently holding in their main hand.
setItemInMainHandSets the item the player is holding in their main hand.
getItemInOffHandGets the item the player is currently holding in their off hand.
setItemInOffHandSets the item the player is holding in their off hand.
getHeldItemSlotGet the slot number of the currently held item.
setHeldItemSlotSet the slot number of the currently held item.

methgetHelmetabstractconst

std::optional<ItemStack> getHelmet() const =0

Return the ItemStack from the helmet slot.

Returns

TypeDescription
std::optional<ItemStack>The ItemStack in the helmet slot

methgetChestplateabstractconst

std::optional<ItemStack> getChestplate() const =0

Return the ItemStack from the chestplate slot.

Returns

TypeDescription
std::optional<ItemStack>The ItemStack in the chestplate slot

methgetLeggingsabstractconst

std::optional<ItemStack> getLeggings() const =0

Return the ItemStack from the leg slot.

Returns

TypeDescription
std::optional<ItemStack>The ItemStack in the leg slot

methgetBootsabstractconst

std::optional<ItemStack> getBoots() const =0

Return the ItemStack from the boots slot.

Returns

TypeDescription
std::optional<ItemStack>The ItemStack in the boots slot

methsetHelmetabstract

void setHelmet(std::optional<ItemStack> helmet) =0

Put the given ItemStack into the helmet slot.

This does not check if the ItemStack is a helmet.

Parameters

NameTypeDescription
helmetstd::optional<ItemStack>The ItemStack to use as helmet

methsetChestplateabstract

void setChestplate(std::optional<ItemStack> chestplate) =0

Put the given ItemStack into the chestplate slot.

This does not check if the ItemStack is a chestplate.

Parameters

NameTypeDescription
chestplatestd::optional<ItemStack>The ItemStack to use as chestplate

methsetLeggingsabstract

void setLeggings(std::optional<ItemStack> leggings) =0

Put the given ItemStack into the leggings slot.

This does not check if the ItemStack is a pair of leggings.

Parameters

NameTypeDescription
leggingsstd::optional<ItemStack>The ItemStack to use as leggings

methsetBootsabstract

void setBoots(std::optional<ItemStack> boots) =0

Put the given ItemStack into the boots slot.

This does not check if the ItemStack is a pair of boots.

Parameters

NameTypeDescription
bootsstd::optional<ItemStack>The ItemStack to use as boots

methgetItemInMainHandabstractconst

std::optional<ItemStack> getItemInMainHand() const =0

Gets the item the player is currently holding in their main hand.

Returns

TypeDescription
std::optional<ItemStack>the currently held item

methsetItemInMainHandabstract

void setItemInMainHand(std::optional<ItemStack> item) =0

Sets the item the player is holding in their main hand.

Parameters

NameTypeDescription
itemstd::optional<ItemStack>The item to put into the player's hand

methgetItemInOffHandabstractconst

std::optional<ItemStack> getItemInOffHand() const =0

Gets the item the player is currently holding in their off hand.

Returns

TypeDescription
std::optional<ItemStack>the currently held item

methsetItemInOffHandabstract

void setItemInOffHand(std::optional<ItemStack> item) =0

Sets the item the player is holding in their off hand.

Parameters

NameTypeDescription
itemstd::optional<ItemStack>The item to put into the player's hand

methgetHeldItemSlotabstractconst

int getHeldItemSlot() const =0

Get the slot number of the currently held item.

Returns

TypeDescription
intHeld item slot number

methsetHeldItemSlotabstract

void setHeldItemSlot(int slot) =0

Set the slot number of the currently held item.

This validates whether the slot is between 0 and 8 inclusive.

Parameters

NameTypeDescription
slotintThe new slot number

classRecipe

Defined in <endstone/inventory/recipe.h>

Represents some type of crafting recipe.

Methods

NameDescription
~Recipe
getResultGet the result of this recipe.

meth~Recipevirtual

~Recipe() =default

methgetResultabstractconst

ItemStack getResult() const =0

Get the result of this recipe.

Returns

TypeDescription
ItemStackThe result stack

classWritableBookMeta

Defined in <endstone/inventory/meta/writable_book_meta.h>

Bases: ItemMeta

Represents the meta for a writable book that can have pages.

Methods

NameDescription
hasPagesChecks for the existence of pages in the book.
getPageGets the specified page in the book. The given page must exist.
setPageSets the specified page in the book. Pages of the book must be contiguous.
getPagesGets all the pages in the book.
setPagesClears the existing book pages, and sets the book to use the provided pages.
setPagesMaximum 50 pages with 798 characters per page.
addPageAdds new pages to the end of the book.
addPageAdds new pages to the end of the book.
getPageCountGets the number of pages in the book.

methhasPagesabstractconst

bool hasPages() const =0

Checks for the existence of pages in the book.

Returns

TypeDescription
booltrue if the book has pages

methgetPageabstractconst

std::string getPage(int page) const =0

Gets the specified page in the book. The given page must exist.

Note

Pages are 1-indexed.

Parameters

NameTypeDescription
pageintthe page number to get, in range [1, getPageCount()]

Returns

TypeDescription
std::stringthe page from the book

methsetPageabstract

void setPage(int page, std::string data) =0

Sets the specified page in the book. Pages of the book must be contiguous.

Note

The data can be up to 1024 characters in length, additional characters are truncated.

Pages are 1-indexed.

Parameters

NameTypeDescription
pageintthe page number to set, in range [1, getPageCount()]
datastd::stringthe data to set for that page

methgetPagesabstractconst

std::vector<std::string> getPages() const =0

Gets all the pages in the book.

Returns

TypeDescription
std::vector<std::string>list of all the pages in the book

methsetPages

void setPages(Args&&... pages)

Clears the existing book pages, and sets the book to use the provided pages.

Note

Maximum 50 pages with 798 characters per page.

Parameters

NameTypeDescription
pagesArgs&&...A list of pages to set the book to use

methsetPagesabstract

void setPages(std::vector<std::string> pages) =0

Maximum 50 pages with 798 characters per page.

Note

Clears the existing book pages, and sets the book to use the provided pages.

Parameters

NameTypeDescription
pagesstd::vector<std::string>A list of strings, each being a page

methaddPage

void addPage(Args&&... pages)

Adds new pages to the end of the book.

Note

Up to a maximum of 50 pages with 798 characters per page.

Parameters

NameTypeDescription
pagesArgs&&...A list of strings, each being a page

methaddPageabstract

void addPage(std::vector<std::string> pages) =0

Adds new pages to the end of the book.

Note

Up to a maximum of 50 pages with 798 characters per page.

Parameters

NameTypeDescription
pagesstd::vector<std::string>A list of strings, each being a page

methgetPageCountabstractconst

int getPageCount() const =0

Gets the number of pages in the book.

Returns

TypeDescription
intthe number of pages in the book

enumEquipmentSlot

EquipmentSlot

Values

NameValueDescription
Hand
OffHand
Feet
Legs
Chest
Head
Body

Note

Only for certain entities such as horses and wolves.

typeItemTypeId

Identifier<ItemType> ItemTypeId

Represents an item type.

On this page

classBookMetaenumGenerationmethhasTitlemethgetTitlemethsetTitlemethhasAuthormethgetAuthormethsetAuthormethhasGenerationmethgetGenerationmethsetGenerationclassCrossbowMetamethhasChargedProjectilesmethgetChargedProjectilesmethsetChargedProjectilesmethaddChargedProjectileclassImplmeth~ImplmethclonemethgetTypemethsetTypemethgetAmountmethsetAmountmethgetDatamethsetDatamethgetTranslationKeymethgetMaxStackSizemethisSimilarmethgetItemMetamethhasItemMetamethsetItemMetamethgetNbtmethsetNbtclassInventorymeth~InventorymethgetSizemethgetMaxStackSizemethgetItemmethsetItemmethaddItemmethremoveItemmethaddItemmethremoveItemmethgetContentsmethsetContentsmethcontainsmethcontainsmethcontainsmethcontainsAtLeastmethcontainsAtLeastmethallmethallmethfirstmethfirstmethfirstEmptymethisEmptymethremovemethremovemethclearmethclearclassItemFactorymeth~ItemFactorymethgetItemMetamethisApplicablemethequalsmethasMetaForclassItemMetaenumTypemeth~ItemMetamethgetTypemethhasDisplayNamemethgetDisplayNamemethsetDisplayNamemethhasLoremethgetLoremethsetLoremethhasEnchantsmethhasEnchantmethgetEnchantLevelmethgetEnchantsmethaddEnchantmethremoveEnchantmethremoveEnchantsmethhasConflictingEnchantmethisUnbreakablemethsetUnbreakablemethhasDamagemethgetDamagemethsetDamagemethhasRepairCostmethgetRepairCostmethsetRepairCostmethclonemethgetExtrasmethasmethasclassItemStackmethItemStackmethItemStackmethItemStackmethoperator=methoperator=meth~ItemStackmethgetTypemethsetTypemethgetAmountmethsetAmountmethgetDatamethsetDatamethgetTranslationKeymethgetMaxStackSizemethgetNbtmethsetNbtmethoperator==methoperator!=methisSimilarmethgetItemMetamethhasItemMetamethsetItemMetaclassItemTypevarAirmethgetTranslationKeymethgetTranslationKeymethgetMaxStackSizemethgetMaxDurabilitymethcreateItemStackmethcreateItemStackclassMapMetatypeMapIdmethhasMapIdmethgetMapIdmethsetMapIdmethhasMapViewmethgetMapViewmethsetMapViewclassPlayerInventorymethgetHelmetmethgetChestplatemethgetLeggingsmethgetBootsmethsetHelmetmethsetChestplatemethsetLeggingsmethsetBootsmethgetItemInMainHandmethsetItemInMainHandmethgetItemInOffHandmethsetItemInOffHandmethgetHeldItemSlotmethsetHeldItemSlotclassRecipemeth~RecipemethgetResultclassWritableBookMetamethhasPagesmethgetPagemethsetPagemethgetPagesmethsetPagesmethsetPagesmethaddPagemethaddPagemethgetPageCountenumEquipmentSlottypeItemTypeId