Class NameModifier
java.lang.Object
io.github.projectunified.craftitem.modifier.NameModifier
- All Implemented Interfaces:
ItemModifier
Item modifier that sets the item's display name.
The provided name is passed through the translator before being applied to the item, allowing for variable substitution and dynamic name generation.
Example Usage:
ItemModifier modifier = new NameModifier("Sword of ${owner}");
modifier.modify(item, s -> s.replace("${owner}", "Player123"));
// Item name becomes: "Sword of Player123"
-
Constructor Summary
ConstructorsConstructorDescriptionNameModifier(String name) Creates a new NameModifier with the specified name. -
Method Summary
Modifier and TypeMethodDescriptionvoidmodify(Item item, UnaryOperator<String> translator) Applies the translated name to the item.
-
Constructor Details
-
NameModifier
Creates a new NameModifier with the specified name.- Parameters:
name- the display name (can contain variables for translation)
-
-
Method Details
-
modify
Applies the translated name to the item.- Specified by:
modifyin interfaceItemModifier- Parameters:
item- the item to modifytranslator- the string translator for variable substitution
-