Class TextUtils

java.lang.Object
io.github.thecsdev.tcdcommons.api.util.TextUtils

public final class TextUtils extends Object
Contains various Text related utilities.
It is not recommended to call Text related functions too frequently. Instead, store Texts in a field, and access them from there.
  • Method Details

    • literal

      public static net.minecraft.text.MutableText literal(String text)
      Returns a literal MutableText using the given String argument.
      Parameters:
      text - The literal text.
    • translatable

      public static net.minecraft.text.MutableText translatable(String translationKey, Object... params)
      Returns a translatable MutableText using the given translation key. The returned text will depend on the user's language settings.
      Parameters:
      translationKey - The translation key.
      params - The translatable Text formatting parameters.
    • fLiteral

      public static net.minecraft.text.MutableText fLiteral(String text)
      Same as literal(String), except it is also formatted using formatted(String).
      Parameters:
      text - The literal text.
    • fTranslatable

      public static net.minecraft.text.MutableText fTranslatable(String translationKey, Object... params)
      Same as translatable(String, Object...), except it is also formatted using formatted(Text).
      Parameters:
      translationKey - The translation key.
      params - The translatable text formatting parameters.
    • formatted

      public static net.minecraft.text.MutableText formatted(net.minecraft.text.Text text)
      Formats (styles) a given MutableText and returns the formatted MutableText.
      Please see formatted(String).
      Parameters:
      text - The Text to style/format.
    • formatted

      public static net.minecraft.text.MutableText formatted(String text)
      Formats (styles) a given text and returns the formatted MutableText. The Formatting.FORMATTING_CODE_PREFIX is used to format the given text.
      Parameters:
      text - The text to format.