Interface Damageable

All Superinterfaces:
Cloneable, ConfigurationSerializable, ItemMeta, PersistentDataHolder, PersistentDataViewHolder

public interface Damageable extends ItemMeta
Represents an item that has durability and can take damage.
  • Method Details

    • hasDamage

      boolean hasDamage()
      Checks to see if this item has damage greater than 0.
      Returns:
      true if this has damage > 0
    • getDamage

      int getDamage()
      Gets the damage

      Call hasDamageValue() to be sure a damage value is set.

      Returns:
      the damage
    • setDamage

      void setDamage(int damage)
      Sets the damage
      Parameters:
      damage - item damage
      See Also:
    • hasDamageValue

      boolean hasDamageValue()
      Checks if any damage value, including 0, is set on this meta.
      Returns:
      true if any value is set
    • resetDamage

      void resetDamage()
      Clears the damage component from the meta. Differs from setDamage(0) in that it removes the component instead of adding the component with a value of 0.
    • hasMaxDamage

      boolean hasMaxDamage()
      Checks to see if this item has a maximum amount of damage.
      Returns:
      true if this has maximum amount of damage
    • getMaxDamage

      int getMaxDamage()
      Gets the maximum amount of damage. Plugins should check hasMaxDamage() before calling this method.
      Returns:
      the maximum amount of damage
    • setMaxDamage

      void setMaxDamage(@Nullable @Nullable Integer maxDamage)
      Sets the maximum amount of damage.
      Parameters:
      maxDamage - maximum amount of damage
    • clone

      Specified by:
      clone in interface ItemMeta