Class ItemFlagModifier

java.lang.Object
io.github.projectunified.craftitem.spigot.modifier.ItemFlagModifier
All Implemented Interfaces:
ItemModifier, SpigotItemModifier

public class ItemFlagModifier extends Object implements SpigotItemModifier
Spigot modifier that adds item flags to hide or show specific item attributes.

Flags control what information is displayed in the item tooltip. Special value "all" applies all available flags.

Example Usage:


 // Hide enchantments and attributes
 ItemModifier mod1 = new ItemFlagModifier(List.of(
     "HIDE_ENCHANTS",
     "HIDE_ATTRIBUTES"
 ));

 // Hide everything
 ItemModifier mod2 = new ItemFlagModifier(List.of("all"));

 // From ItemFlag enum
 ItemModifier mod3 = new ItemFlagModifier(
     List.of(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_ATTRIBUTES)
 );
 
  • Constructor Details

    • ItemFlagModifier

      public ItemFlagModifier(List<String> flags)
      Creates a new ItemFlagModifier with the specified flag names. Flag names are case-insensitive and spaces are converted to underscores.
      Parameters:
      flags - the list of item flag names (or "all")
    • ItemFlagModifier

      public ItemFlagModifier(Collection<org.bukkit.inventory.ItemFlag> flags)
      Creates a new ItemFlagModifier from ItemFlag enum values.
      Parameters:
      flags - the collection of ItemFlag enums
  • Method Details

    • modify

      public void modify(SpigotItem item, UnaryOperator<String> translator)
      Applies the parsed item flags to the item.
      Specified by:
      modify in interface SpigotItemModifier
      Parameters:
      item - the SpigotItem to modify
      translator - the string translator for variable substitution