Package com.thewinterframework.component
Class ComponentUtils
java.lang.Object
com.thewinterframework.component.ComponentUtils
Utility class for working with Adventure components.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddComponentModifier(@NotNull UnaryOperator<net.kyori.adventure.text.Component> modifier) Adds a component modifier.static <T> voidaddComponentResolver(@NotNull Class<T> clazz, @NotNull ComponentResolver<T> resolver) Adds a component resolver.static voidaddGlobalTagResolver(@NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver) Adds a global tag resolver.static net.kyori.adventure.text.ComponentlegacyAmpersand(@NotNull String message) Serializes a string into a legacy ampersand string.static net.kyori.adventure.text.ComponentlegacyAmpersand(@NotNull String message, boolean applyModifiers) Serializes a string into a legacy ampersand string.static List<net.kyori.adventure.text.Component> legacyAmpersand(@NotNull Collection<String> messages) Serializes multiple strings into legacy ampersand components.static List<net.kyori.adventure.text.Component> legacyAmpersand(@NotNull Collection<String> messages, boolean applyModifiers) Serializes multiple strings into legacy ampersand components.static StringlegacyAmpersand(@NotNull net.kyori.adventure.text.Component component) Serializes a component into a legacy ampersand string.static net.kyori.adventure.text.ComponentlegacySection(@NotNull String message) Serializes a string into a legacy section string.static net.kyori.adventure.text.ComponentlegacySection(@NotNull String message, boolean applyModifiers) Serializes a string into a legacy section string.static List<net.kyori.adventure.text.Component> legacySection(@NotNull Collection<String> messages) Serializes multiple strings into legacy section components.static List<net.kyori.adventure.text.Component> legacySection(@NotNull Collection<String> messages, boolean applyModifiers) Serializes multiple strings into legacy section components.static StringlegacySection(@NotNull net.kyori.adventure.text.Component component) Serializes a component into a legacy section string.static net.kyori.adventure.text.ComponentminiMessage(@NotNull String message, boolean applyModifiers, @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... tagResolvers) Parses a MiniMessage string into a component.static net.kyori.adventure.text.ComponentminiMessage(@NotNull String message, @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... tagResolvers) Parses a MiniMessage string into a component.static List<net.kyori.adventure.text.Component> miniMessage(@NotNull Collection<String> messages, boolean applyModifiers, @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... tagResolvers) Parses multiple MiniMessage strings into components.static List<net.kyori.adventure.text.Component> miniMessage(@NotNull Collection<String> messages, @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... tagResolvers) Parses multiple MiniMessage strings into components.miniMessage(@NotNull Collection<net.kyori.adventure.text.Component> components) Serializes multiple components into MiniMessage strings.static StringminiMessage(@NotNull net.kyori.adventure.text.Component component) Serializes a component into a MiniMessage string.static net.kyori.adventure.text.ComponentSerializes a string into a plain text component.static net.kyori.adventure.text.ComponentSerializes a string into a plain text component.plainText(@NotNull Collection<net.kyori.adventure.text.Component> components) Serializes multiple components into plain text strings.static StringplainText(@NotNull net.kyori.adventure.text.Component component) Serializes a component into a plain text string.static @NotNull net.kyori.adventure.text.ComponentResolves an object into a component.static @NotNull net.kyori.adventure.text.Component[]resolveMany(@NotNull Object... objects) Resolves multiple objects into components.
-
Method Details
-
addGlobalTagResolver
public static void addGlobalTagResolver(@NotNull @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver tagResolver) Adds a global tag resolver.- Parameters:
tagResolver- The tag resolver to add.
-
addComponentResolver
public static <T> void addComponentResolver(@NotNull @NotNull Class<T> clazz, @NotNull @NotNull ComponentResolver<T> resolver) Adds a component resolver.- Type Parameters:
T- The type of the class to resolve.- Parameters:
clazz- The class to resolve.resolver- The resolver to add.
-
addComponentModifier
public static void addComponentModifier(@NotNull @NotNull UnaryOperator<net.kyori.adventure.text.Component> modifier) Adds a component modifier.- Parameters:
modifier- The modifier to add.
-
miniMessage
Serializes a component into a MiniMessage string.- Parameters:
component- The component to serialize.- Returns:
- The serialized MiniMessage string.
-
miniMessage
public static List<String> miniMessage(@NotNull @NotNull Collection<net.kyori.adventure.text.Component> components) Serializes multiple components into MiniMessage strings.- Parameters:
components- The components to serialize.- Returns:
- The serialized MiniMessage strings.
-
miniMessage
public static net.kyori.adventure.text.Component miniMessage(@NotNull @NotNull String message, boolean applyModifiers, @NotNull @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... tagResolvers) Parses a MiniMessage string into a component.- Parameters:
message- The message to parse.applyModifiers- Whether to apply component modifiers.tagResolvers- The tag resolvers to use.- Returns:
- The parsed component.
-
miniMessage
public static net.kyori.adventure.text.Component miniMessage(@NotNull @NotNull String message, @NotNull @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... tagResolvers) Parses a MiniMessage string into a component.- Parameters:
message- The message to parse.tagResolvers- The tag resolvers to use.- Returns:
- The parsed component.
-
miniMessage
public static List<net.kyori.adventure.text.Component> miniMessage(@NotNull @NotNull Collection<String> messages, boolean applyModifiers, @NotNull @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... tagResolvers) Parses multiple MiniMessage strings into components.- Parameters:
messages- The messages to parse.applyModifiers- Whether to applycomponent modifiers.tagResolvers- The tag resolvers to use.- Returns:
- The parsed components.
-
miniMessage
public static List<net.kyori.adventure.text.Component> miniMessage(@NotNull @NotNull Collection<String> messages, @NotNull @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver... tagResolvers) Parses multiple MiniMessage strings into components.- Parameters:
messages- The messages to parse.tagResolvers- The tag resolvers to use.- Returns:
- The parsed components.
-
legacySection
public static net.kyori.adventure.text.Component legacySection(@NotNull @NotNull String message, boolean applyModifiers) Serializes a string into a legacy section string. This is a string where color codes are prefixed with §. For example, §cHello §fworld.- Parameters:
message- The message to serialize.- Returns:
- The serialized legacy section component.
-
legacySection
Serializes a string into a legacy section string. This is a string where color codes are prefixed with §. For example, §cHello §fworld.- Parameters:
message- The message to serialize.- Returns:
- The serialized legacy section component.
-
legacySection
public static List<net.kyori.adventure.text.Component> legacySection(@NotNull @NotNull Collection<String> messages, boolean applyModifiers) Serializes multiple strings into legacy section components.- Parameters:
messages- The messages to serialize.applyModifiers- Whether to apply component modifiers.- Returns:
- The serialized legacy section components.
-
legacySection
public static List<net.kyori.adventure.text.Component> legacySection(@NotNull @NotNull Collection<String> messages) Serializes multiple strings into legacy section components.- Parameters:
messages- The messages to serialize.- Returns:
- The serialized legacy section components.
-
legacySection
Serializes a component into a legacy section string. This is a string where color codes are prefixed with §. For example, §cHello §fworld.- Parameters:
component- The component to serialize.- Returns:
- The serialized legacy section component.
-
legacyAmpersand
public static net.kyori.adventure.text.Component legacyAmpersand(@NotNull @NotNull String message, boolean applyModifiers) Serializes a string into a legacy ampersand string. This is a string where color codes are prefixed with ampersand.- Parameters:
message- The message to serialize.applyModifiers- Whether to apply component modifiers.- Returns:
- The serialized legacy ampersand component.
-
legacyAmpersand
Serializes a string into a legacy ampersand string. This is a string where color codes are prefixed with ampersand.- Parameters:
message- The message to serialize.- Returns:
- The serialized legacy ampersand component.
-
legacyAmpersand
public static List<net.kyori.adventure.text.Component> legacyAmpersand(@NotNull @NotNull Collection<String> messages, boolean applyModifiers) Serializes multiple strings into legacy ampersand components.- Parameters:
messages- The messages to serialize.applyModifiers- Whether to applycomponent modifiers.- Returns:
- The serialized legacy ampersand components.
-
legacyAmpersand
public static List<net.kyori.adventure.text.Component> legacyAmpersand(@NotNull @NotNull Collection<String> messages) Serializes multiple strings into legacy ampersand components.- Parameters:
messages- The messages to serialize.- Returns:
- The serialized legacy ampersand components.
-
legacyAmpersand
public static String legacyAmpersand(@NotNull @NotNull net.kyori.adventure.text.Component component) Serializes a component into a legacy ampersand string. This is a string where color codes are prefixed with ampersand.- Parameters:
component- The component to serialize.- Returns:
- The serialized legacy ampersand component.
-
plainText
Serializes a component into a plain text string. This is a string where all formatting is removed.- Parameters:
component- The component to serialize.- Returns:
- The serialized plain text component.
-
plainText
public static List<String> plainText(@NotNull @NotNull Collection<net.kyori.adventure.text.Component> components) Serializes multiple components into plain text strings.- Parameters:
components- The components to serialize.- Returns:
- The serialized plain text components.
-
plainText
public static net.kyori.adventure.text.Component plainText(@NotNull @NotNull String message, boolean applyModifiers) Serializes a string into a plain text component. This is a component where all formatting is removed.- Parameters:
message- The message to serialize.- Returns:
- The serialized plain text component.
-
plainText
Serializes a string into a plain text component. This is a component where all formatting is removed.- Parameters:
message- The message to serialize.- Returns:
- The serialized plain text component.
-
resolve
@NotNull public static @NotNull net.kyori.adventure.text.Component resolve(@NotNull @NotNull Object object) Resolves an object into a component.- Parameters:
object- The object to resolve.- Returns:
- The resolved component.
-
resolveMany
@NotNull public static @NotNull net.kyori.adventure.text.Component[] resolveMany(@NotNull @NotNull Object... objects) Resolves multiple objects into components.- Parameters:
objects- The objects to resolve.- Returns:
- The resolved components.
-