Class TextComponentUtils
java.lang.Object
org.skriptlang.skript.bukkit.text.TextComponentUtils
Utilities for working with
Components.-
Method Summary
Modifier and TypeMethodDescriptionstatic net.kyori.adventure.text.ComponentappendToEnd(net.kyori.adventure.text.Component base, net.kyori.adventure.text.Component appendee) static @Nullable Expression<? extends net.kyori.adventure.text.Component> asComponentExpression(Expression<?> expression) Attempts to convert an expression into one that is guaranteed to return a component.static net.kyori.adventure.text.ComponentCreates a component from an object.static net.kyori.adventure.text.ComponentjoinByNewLine(net.kyori.adventure.text.Component... components) Joins components together with new line components.static StringReplaces all legacy formatting codes in a string withMiniMessageequivalents.
-
Method Details
-
from
Creates a component from an object.
Ifmessageis aComponent,messageis simply returned.
Ifmessageis aString, a safely-formatted Component (seeTextComponentParser.parseSafe(Object)) is returned.
Otherwise, a plain text component is returned.- Parameters:
message- The message to create a component from.- Returns:
- A component from the given message.
-
joinByNewLine
public static net.kyori.adventure.text.Component joinByNewLine(net.kyori.adventure.text.Component... components) Joins components together with new line components.- Parameters:
components- The components to join.- Returns:
- A component representing the provided components joined by new line components.
- See Also:
-
appendToEnd
public static net.kyori.adventure.text.Component appendToEnd(net.kyori.adventure.text.Component base, net.kyori.adventure.text.Component appendee) -
replaceLegacyFormattingCodes
Replaces all legacy formatting codes in a string withMiniMessageequivalents.- Parameters:
text- The string to reformat.- Returns:
- Reformatted
text.
-
asComponentExpression
@Nullable public static @Nullable Expression<? extends net.kyori.adventure.text.Component> asComponentExpression(Expression<?> expression) Attempts to convert an expression into one that is guaranteed to return a component.- Parameters:
expression- The expression to convert.- Returns:
- An expression that will wrap the output of
expressionin aComponent. Will return null ifexpressionis unable to be defended (seeLiteralUtils.defendExpression(Expression)).
-