Class AbstractItemEditor
ItemMeta properties that may vary across Minecraft versions.
This abstraction handles the differences in item metadata manipulation between different Minecraft versions, particularly for features that were added or changed in newer versions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract intabstract booleanisDamageable(@NotNull ItemStack item) abstract booleanisUnbreakable(@NotNull ItemMeta meta) abstract ItemStackabstract ItemMetasetUnbreakable(@NotNull ItemMeta meta, boolean unbreakable) Sets the unbreakable status of an item through itsItemMeta.
-
Constructor Details
-
AbstractItemEditor
public AbstractItemEditor()
-
-
Method Details
-
setUnbreakable
Sets the unbreakable status of an item through itsItemMeta.This method modifies the provided
ItemMetato set whether the item should be unbreakable. Unbreakable items do not lose durability when used, regardless of their material type.The implementation handles version-specific differences in how the unbreakable flag is stored and accessed in item metadata.
-
isUnbreakable
- Parameters:
meta- theItemMetato check- Returns:
trueif the item is unbreakable,falseotherwise- Since:
- 1.1.3
Checks if an item is unbreakable through its
ItemMeta.This method retrieves the unbreakable status from the provided
ItemMeta. It returnstrueif the item is unbreakable, andfalseotherwise.The implementation handles version-specific differences in how the unbreakable flag is stored and accessed in item metadata.
-
setDamage
- Parameters:
item- theItemStackto modifydamage- the damage value to set (0 for undamaged, higher values for more damage)- Throws:
IllegalArgumentException- if the item's meta does not support damage (e.g., non-damageable items)- Since:
- 1.1.4
Sets the damage (or 'durability') of an item.
In pre-1.13 versions of Minecraft, item durability is set directly on the
ItemStack
In 1.13 and later versions, item durability is managed through theItemMeta.
-
getDamage
- Parameters:
item- theItemStackto check- Returns:
- the current damage value (0 for undamaged, higher values for more damage)
- Throws:
IllegalArgumentException- if the item's meta does not support damage (e.g., non-damageable items)- Since:
- 1.1.4
Gets the damage (or 'durability') of an item.
In pre-1.13 versions of Minecraft, item durability is retrieved directly from the
ItemStack
In 1.13 and later versions, item durability is managed through theItemMeta.
-
isDamageable
- Parameters:
item- theItemStackto check- Returns:
trueif the item is damageable,falseotherwise- Since:
- 1.1.5
Checks if the given item is damageable (i.e., has durability).
This method determines if the provided
ItemStackcan take damage.
- In pre-1.13 versions this checks if the item's material has a max durability greater than 0.
- In 1.13 and later versions this checks if the item's meta is an instance of Damageable.
-