Class DurabilityModifier
java.lang.Object
io.github.projectunified.craftitem.spigot.modifier.DurabilityModifier
- All Implemented Interfaces:
ItemModifier,SpigotItemModifier
Spigot modifier that sets item durability (damage value).
Durability can be provided as a short value or a string. The string value is translated before parsing to support dynamic durability.
Example Usage:
// Direct durability value
ItemModifier mod1 = new DurabilityModifier((short) 50);
// String with variable
ItemModifier mod2 = new DurabilityModifier("${damage}");
mod2.modify(item, s -> s.replace("${damage}", "100"));
-
Constructor Summary
ConstructorsConstructorDescriptionDurabilityModifier(short durability) Creates a new DurabilityModifier with the specified durability value.DurabilityModifier(String durability) Creates a new DurabilityModifier with the specified durability as a string. -
Method Summary
Modifier and TypeMethodDescriptionvoidmodify(SpigotItem item, UnaryOperator<String> translator) Applies the translated durability to the item.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.projectunified.craftitem.spigot.core.SpigotItemModifier
modify
-
Constructor Details
-
DurabilityModifier
public DurabilityModifier(short durability) Creates a new DurabilityModifier with the specified durability value.- Parameters:
durability- the durability value (0 = full durability)
-
DurabilityModifier
Creates a new DurabilityModifier with the specified durability as a string. The string can contain variables for translation.- Parameters:
durability- the durability value as a string
-
-
Method Details
-
modify
Applies the translated durability to the item. Invalid durability values are silently ignored.- Specified by:
modifyin interfaceSpigotItemModifier- Parameters:
item- the SpigotItem to modifytranslator- the string translator for variable substitution
-