Class TextHolder
java.lang.Object
com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder
- Direct Known Subclasses:
ComponentHolder,StringHolder
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 Summary
Modifier and TypeMethodDescriptionabstract @NotNull InventoryasInventoryTitle(InventoryHolder holder, int size) Creates a new inventory with the wrapped value as the inventory's title.abstract @NotNull InventoryasInventoryTitle(InventoryHolder holder, InventoryType type) Creates a new inventory with the wrapped value as the inventory's title.abstract voidasItemDisplayName(ItemMeta meta) Modifies the specified meta: sets the display name to the wrapped value.abstract voidasItemLoreAtEnd(ItemMeta meta) Modifies the specified meta: adds the wrapped value as a new lore line at the endabstract @NotNull StringConverts the text wrapped by this class instance to a legacy string, keeping the original formatting.abstract @NotNull MerchantCreates a new merchant with the wrapped value as the merchant's title.static @NotNull TextHolderdeserialize(@NotNull String string) Deserializes the specifiedStringas aTextHolder.static @NotNull TextHolderempty()Gets an instance that contains no characters and no formatting.abstract booleanabstract inthashCode()abstract @NotNull StringtoString()
-
Method Details
-
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 specifiedStringas aTextHolder. 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
-
hashCode
public abstract int hashCode() -
equals
-
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 inventorytype- 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 inventorysize- 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
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
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
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
-