Class TextUtil
java.lang.Object
com.github.darksoulq.abyssallib.common.util.TextUtil
Utility methods for text handling, including:
- JSON serialization/deserialization with
Gson - MiniMessage parsing with
MiniMessage - String/array conversions
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidBuilds the globalGsoninstance using all registered type adapters.static String[]convertToArray(List<String> list) Converts aListof strings into aString[]array.convertToList(String[] arr) Converts aString[]into aList.static net.kyori.adventure.text.ComponentParses a MiniMessage string into aComponent.static net.kyori.adventure.text.ComponentParses a MiniMessage string with customTagResolvers into aComponent.static <T> voidregisterTypeAdapter(Class<T> clazz, Object adapter) Registers a type adapter for a specific class and rebuilds the globalGsoninstance.static <T> voidregisterTypeHierarchyAdapter(Class<T> clazz, Object adapter) Registers a type adapter for a class hierarchy and rebuilds the globalGsoninstance.
-
Field Details
-
GSON
public static com.google.gson.Gson GSONThe sharedGsoninstance configured with registered type adapters.Rebuilt whenever new type adapters are registered.
-
MM
public static final net.kyori.adventure.text.minimessage.MiniMessage MMThe sharedMiniMessageinstance used for parsing MiniMessage text.
-
-
Constructor Details
-
TextUtil
public TextUtil()
-
-
Method Details
-
buildGson
public static void buildGson()Builds the globalGsoninstance using all registered type adapters.This method is automatically called when registering new adapters.
-
registerTypeAdapter
-
registerTypeHierarchyAdapter
-
convertToList
-
convertToArray
-
parse
Parses a MiniMessage string into aComponent.- Parameters:
mmText- the MiniMessage string- Returns:
- the parsed
Component
-
parse
public static net.kyori.adventure.text.Component parse(String mmText, net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... resolvers) Parses a MiniMessage string with customTagResolvers into aComponent.- Parameters:
mmText- the MiniMessage stringresolvers- the tag resolvers to apply- Returns:
- the parsed
Component
-