Class ItemSpec.Builder

java.lang.Object
com.ultikits.ultitools.item.ItemSpec.Builder
Enclosing class:
ItemSpec

public static final class ItemSpec.Builder extends Object
A non-thread-safe builder; repeated builds produce independent immutable descriptions.
  • Field Details

    • itemType

      private final net.kyori.adventure.key.Key itemType
    • amount

      private int amount
    • name

      @Nullable private @Nullable Text name
    • lore

      private final List<Text> lore
    • model

      @Nullable private @Nullable net.kyori.adventure.key.Key model
    • glint

      @Nullable private @Nullable Boolean glint
    • tooltipHidden

      private boolean tooltipHidden
    • hiddenInTooltip

      private final Map<org.bukkit.NamespacedKey, io.papermc.paper.datacomponent.DataComponentType> hiddenInTooltip
    • patches

      private final List<DataPatch> patches
    • markers

      private final Map<org.bukkit.NamespacedKey, ItemMarker<?,?>> markers
  • Constructor Details

    • Builder

      private Builder(net.kyori.adventure.key.Key itemType)
  • Method Details

    • amount

      public ItemSpec.Builder amount(int amount)
      Sets the amount. @throws IllegalArgumentException outside 1..99
    • name

      public ItemSpec.Builder name(@Nullable @Nullable Text name)
      Sets the deferred name, or clears it with null.
    • name

      public ItemSpec.Builder name(MessageKey key, Arg... args)
      Sets a translated name with uniquely named arguments.
    • lore

      public ItemSpec.Builder lore(List<? extends Text> lines)
      Replaces lore with a defensive copy of the lines.
    • addLore

      public ItemSpec.Builder addLore(Text line)
      Appends a deferred lore line.
    • addLore

      public ItemSpec.Builder addLore(MessageKey key, Arg... args)
      Appends a translated lore line with uniquely named arguments.
    • model

      public ItemSpec.Builder model(@Nullable @Nullable net.kyori.adventure.key.Key model)
      Sets ITEM_MODEL, or clears the override with null.
    • glint

      public ItemSpec.Builder glint(@Nullable @Nullable Boolean glint)
      Sets the glint override, or clears it with null.
    • tooltipHidden

      public ItemSpec.Builder tooltipHidden(boolean hidden)
      Sets whether the whole tooltip is hidden.
    • hiddenInTooltip

      public ItemSpec.Builder hiddenInTooltip(Set<? extends io.papermc.paper.datacomponent.DataComponentType> types)
      Replaces the set of components whose tooltip lines are hidden, for example DataComponentTypes.ATTRIBUTE_MODIFIERS to hide "+7 Attack Damage". Any component type is allowed. An empty set hides none. Types are compared by key; for two types with the same key the first is kept. The renderer writes it together with tooltipHidden(boolean) into one TOOLTIP_DISPLAY value.
    • data

      public <T> ItemSpec.Builder data(io.papermc.paper.datacomponent.DataComponentType.Valued<T> type, T value)
      Appends a component value, applied unchanged and without localization. The value must be immutable with value equals; Paper's own component values are.
      Throws:
      IllegalArgumentException - for any of the five typed component keys
    • data

      public ItemSpec.Builder data(io.papermc.paper.datacomponent.DataComponentType.NonValued type)
      Appends a flag component.
      Throws:
      IllegalArgumentException - for any of the five typed component keys
    • remove

      public ItemSpec.Builder remove(io.papermc.paper.datacomponent.DataComponentType type)
      Removes a prototype component.
      Throws:
      IllegalArgumentException - for any of the five typed component keys
    • marker

      public <P,C> ItemSpec.Builder marker(org.bukkit.NamespacedKey key, org.bukkit.persistence.PersistentDataType<P,C> type, C value)
      Adds a marker, replacing a previous marker with the same key in its original position. The value must be immutable with value equals; Paper's own component values are.
    • build

      public ItemSpec build()
      Returns an independent description with all current builder attributes.
    • validatePassThrough

      private static void validatePassThrough(io.papermc.paper.datacomponent.DataComponentType type)