java.lang.Object
com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder
Direct Known Subclasses:
ComponentHolder, StringHolder

public abstract class TextHolder extends Object
Immutable wrapper of a text-like value. Support for both Adventure and legacy strings is achieved through this class. To get an instance of this class please refer to either StringHolder.of(String) or ComponentHolder.of(Component). Other methods like empty() and deserialize(String) also exist, but their use cases are very limited.
Since:
0.10.0
See Also:
  • Method Details

    • empty

      @NotNull @Contract(pure=true) public static @NotNull TextHolder empty()
      Gets an instance that contains no characters and no formatting.
      Returns:
      an instance without any characters or formatting
      Since:
      0.10.0
    • deserialize

      @NotNull @Contract(pure=true) public static @NotNull TextHolder deserialize(@NotNull @NotNull String string)
      Deserializes the specified String as a TextHolder. This method is still WIP and may change drastically in the future:
      • Are we going to use MiniMessage if it's present?
      • Is MiniMessage going to be opt-in? If yes, how do we opt-in?
      Parameters:
      string - the raw data to deserialize
      Returns:
      an instance containing the text from the string
      Since:
      0.10.0
    • toString

      @NotNull @Contract(pure=true) public abstract @NotNull String toString()
      Overrides:
      toString in class Object
    • hashCode

      public abstract int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public abstract boolean equals(Object other)
      Overrides:
      equals in class Object
    • asLegacyString

      @NotNull @Contract(pure=true) public abstract @NotNull String asLegacyString()
      Converts the text wrapped by this class instance to a legacy string, keeping the original formatting.
      Returns:
      the wrapped value represented as a legacy string
      Since:
      0.10.0
    • asInventoryTitle

      @NotNull @Contract(pure=true) public abstract @NotNull Inventory asInventoryTitle(InventoryHolder holder, InventoryType type)
      Creates a new inventory with the wrapped value as the inventory's title.
      Parameters:
      holder - the holder to use for the new inventory
      type - the type of inventory to create
      Returns:
      a newly created inventory with the wrapped value as its title
      Since:
      0.10.0
    • asInventoryTitle

      @NotNull @Contract(pure=true) public abstract @NotNull Inventory asInventoryTitle(InventoryHolder holder, int size)
      Creates a new inventory with the wrapped value as the inventory's title.
      Parameters:
      holder - the holder to use for the new inventory
      size - the count of slots the inventory should have (normal size restrictions apply)
      Returns:
      a newly created inventory with the wrapped value as its title
      Since:
      0.10.0
    • asMerchantTitle

      @NotNull @Contract(pure=true) public abstract @NotNull Merchant asMerchantTitle()
      Creates a new merchant with the wrapped value as the merchant's title.
      Returns:
      a newly created inventory with the wrapped value as its title
      Since:
      0.10.0
    • asItemDisplayName

      public abstract void asItemDisplayName(ItemMeta meta)
      Modifies the specified meta: sets the display name to the wrapped value.
      Parameters:
      meta - the meta whose display name to set
      Since:
      0.10.0
    • asItemLoreAtEnd

      public abstract void asItemLoreAtEnd(ItemMeta meta)
      Modifies the specified meta: adds the wrapped value as a new lore line at the end
      Parameters:
      meta - the meta whose lore to append to
      Since:
      0.10.0