Class DamageableItemBuilder
java.lang.Object
io.github.lucfr1746.llibrary.itemstack.ItemBuilder
io.github.lucfr1746.llibrary.itemstack.DamageableItemBuilder
The
DamageableBuilder
class extends ItemBuilder
to provide
additional functionality for modifying Damageable
items in an ItemStack
.
This class allows setting, retrieving, and checking damage values.-
Constructor Summary
ConstructorsConstructorDescriptionDamageableItemBuilder
(@NotNull org.bukkit.Material material) Constructs aDamageableItemBuilder
with the specifiedMaterial
.DamageableItemBuilder
(@NotNull org.bukkit.Material material, int amount) Constructs aDamageableItemBuilder
with the specifiedMaterial
and amount.DamageableItemBuilder
(@NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aDamageableItemBuilder
using an existingItemStack
. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the current damage value of the item.int
Gets the maximum amount of damage this item can take.boolean
Checks if the item has a damage value.boolean
Checks if the item has a maximum damage value.setDamage
(int damage) Sets the damage value of the item.setMaxDurability
(int maxDurability) Sets the maximum damage value for the item.Methods inherited from class io.github.lucfr1746.llibrary.itemstack.ItemBuilder
addAttributeModifier, addEnchant, addEnchant, addEnchant, addItemFlags, addLore, build, getAmount, getAttributeModifiers, getAttributeModifiers, getAttributeModifiers, getCustomModelData, getDamageResistant, getDisplayName, getEnchantable, getEnchantLevel, getEnchantmentGlintOverride, getEnchants, getEquippableComponent, getFoodComponent, getItemFlags, getItemMeta, getItemModel, getJukeboxPlayableComponent, getMaxStackSize, getRarity, getToolComponent, getTooltipStyle, getTranslationKey, getType, getUseCooldownComponent, getUseRemainder, hasAttributeModifiers, hasConflictingEnchant, hasCustomModelData, hasDamageResistant, hasEnchant, hasEnchantable, hasEnchantmentGlintOverride, hasEnchants, hasEquippableComponent, hasFoodComponent, hasItemFlag, hasItemModel, hasJukeboxPlayableComponent, hasMaxStackSize, hasRarity, hasToolComponent, hasTooltipStyle, hasUseCooldownComponent, hasUseRemainder, hideAllItemFlags, insertLore, isGlider, isHideTooltip, isUnbreakable, removeAttributeModifier, removeAttributeModifier, removeAttributeModifier, removeEnchant, removeEnchants, removeItemFlags, replaceLore, setAmount, setAttributeModifiers, setCustomModelData, setDamageResistant, setDisplayName, setEnchantable, setEnchantmentGlintOverride, setEquippableComponent, setEquippableComponent, setFood, setFoodComponent, setGlider, setHideTooltip, setItemModel, setItemModel, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setLores, setLores, setMaxStackSize, setRarity, setToolComponent, setToolComponent, setTooltipStyle, setTooltipStyle, setType, setUnbreakable, setUseCooldownComponent, setUseCooldownComponent, setUseCooldownComponent, setUseRemainder
-
Constructor Details
-
DamageableItemBuilder
public DamageableItemBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aDamageableItemBuilder
using an existingItemStack
.- Parameters:
itemStack
- the item stack to modify- Throws:
IllegalArgumentException
- if the item's meta is not an instance ofDamageable
-
DamageableItemBuilder
public DamageableItemBuilder(@NotNull @NotNull org.bukkit.Material material, int amount) Constructs aDamageableItemBuilder
with the specifiedMaterial
and amount.- Parameters:
material
- the material for the item stackamount
- the quantity of items in the stack- Throws:
IllegalArgumentException
- if the item's meta is not an instance ofDamageable
-
DamageableItemBuilder
public DamageableItemBuilder(@NotNull @NotNull org.bukkit.Material material) Constructs aDamageableItemBuilder
with the specifiedMaterial
.- Parameters:
material
- the material for the item stack- Throws:
IllegalArgumentException
- if the item's meta is not an instance ofDamageable
-
-
Method Details
-
getDamage
public int getDamage()Gets the current damage value of the item.- Returns:
- the current damage value
-
setDamage
Sets the damage value of the item.- Parameters:
damage
- the damage value to set- Returns:
- this
DamageableItemBuilder
instance for method chaining
-
getMaxDurability
public int getMaxDurability()Gets the maximum amount of damage this item can take.- Returns:
- the maximum damage value
-
setMaxDurability
Sets the maximum damage value for the item.- Parameters:
maxDurability
- the maximum damage value to set- Returns:
- this
DamageableItemBuilder
instance for method chaining
-
hasDamage
public boolean hasDamage()Checks if the item has a damage value.- Returns:
- true if the item has damage, false otherwise
-
hasMaxDurability
public boolean hasMaxDurability()Checks if the item has a maximum damage value.- Returns:
- true if the item has a max damage value, false otherwise
-