Class SetLoreFunction

java.lang.Object
com.github.darksoulq.abyssallib.world.data.loot.LootFunction
com.github.darksoulq.abyssallib.world.data.loot.function.SetLoreFunction

public class SetLoreFunction extends LootFunction
A loot function that overrides the lore (description) of a generated item.

This function utilizes Adventure Components to support modern text formatting, including RGB colors, gradients, and translatable strings. The lore is applied via the DataComponentTypes.LORE data component.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Codec<SetLoreFunction>
    The codec used for serializing and deserializing the set lore function.
    The registered type definition for the set lore loot function.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SetLoreFunction(List<net.kyori.adventure.text.Component> lore)
    Constructs a new SetLoreFunction with the specified lore lines.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.inventory.ItemStack
    apply(org.bukkit.inventory.ItemStack stack, LootContext context)
    Applies the configured lore to the provided ItemStack.
    Retrieves the specific type definition for this loot function.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CODEC

      public static final Codec<SetLoreFunction> CODEC
      The codec used for serializing and deserializing the set lore function.

      It expects a "lore" field containing a list of serialized text components.

    • TYPE

      public static final LootFunctionType<SetLoreFunction> TYPE
      The registered type definition for the set lore loot function.
  • Constructor Details

    • SetLoreFunction

      public SetLoreFunction(List<net.kyori.adventure.text.Component> lore)
      Constructs a new SetLoreFunction with the specified lore lines.
      Parameters:
      lore - A List of Adventure Components.
  • Method Details

    • apply

      public org.bukkit.inventory.ItemStack apply(org.bukkit.inventory.ItemStack stack, LootContext context)
      Applies the configured lore to the provided ItemStack.

      This method wraps the component list into an ItemLore instance and sets it as the item's lore data component.

      Specified by:
      apply in class LootFunction
      Parameters:
      stack - The ItemStack generated by the loot entry.
      context - The LootContext providing environmental data.
      Returns:
      The modified ItemStack with the new lore applied.
    • getType

      public LootFunctionType<?> getType()
      Retrieves the specific type definition for this loot function.
      Specified by:
      getType in class LootFunction
      Returns:
      The LootFunctionType associated with SetLoreFunction.