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 int
abstract boolean
isDamageable
(@NotNull ItemStack item) abstract boolean
isUnbreakable
(@NotNull ItemMeta meta) abstract ItemStack
abstract ItemMeta
setUnbreakable
(@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
ItemMeta
to 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
- theItemMeta
to check- Returns:
true
if the item is unbreakable,false
otherwise- Since:
- 1.1.3
Checks if an item is unbreakable through its
ItemMeta
.This method retrieves the unbreakable status from the provided
ItemMeta
. It returnstrue
if the item is unbreakable, andfalse
otherwise.The implementation handles version-specific differences in how the unbreakable flag is stored and accessed in item metadata.
-
setDamage
- Parameters:
item
- theItemStack
to 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
- theItemStack
to 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
- theItemStack
to check- Returns:
true
if the item is damageable,false
otherwise- Since:
- 1.1.5
Checks if the given item is damageable (i.e., has durability).
This method determines if the provided
ItemStack
can 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.
-