Class TextProcessor

java.lang.Object
org.moddingx.libx.util.game.TextProcessor

public class TextProcessor extends Object
Allows text in the lang file to define style information. This is done by dollar commands. A dollar command looks like this: $(...) where the parts in the parens are multiple commands separated by ;. Using $() resets to the default style. A command can be one of these:
  • n or newline: A newline. When this is used, no other commands can be used in the same pair of parens.
  • #RRGGBB
  • : A color in hex
  • b or bold: Bold text.
  • i or italic: Italic text.
  • u or underline: Underlined text.
  • s or strikethrough: Strikethrough text.
Subclasses can also add custom commands with customCommand(Style, String).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final TextProcessor
    A text processor without any custom command.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.network.chat.Style
    customCommand(net.minecraft.network.chat.Style style, String command)
    Handles a custom command.
    List<net.minecraft.network.chat.Component>
    Processes a string.
    List<net.minecraft.network.chat.Component>
    process(net.minecraft.network.chat.Component text)
    Processes a text component.
    net.minecraft.network.chat.Component
    Processes a single-line string.
    net.minecraft.network.chat.Component
    processLine(net.minecraft.network.chat.Component line)
    Processes a single-line text component.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • INSTANCE

      public static final TextProcessor INSTANCE
      A text processor without any custom command.
  • Constructor Details

    • TextProcessor

      public TextProcessor()
  • Method Details

    • process

      public List<net.minecraft.network.chat.Component> process(net.minecraft.network.chat.Component text)
      Processes a text component.
      Returns:
      A list of components. Each entry represents one line in the text.
    • process

      public List<net.minecraft.network.chat.Component> process(String text)
      Processes a string.
      Returns:
      A list of components. Each entry represents one line in the text.
    • processLine

      public net.minecraft.network.chat.Component processLine(net.minecraft.network.chat.Component line)
      Processes a single-line text component.
    • processLine

      public net.minecraft.network.chat.Component processLine(String line)
      Processes a single-line string.
    • customCommand

      public net.minecraft.network.chat.Style customCommand(net.minecraft.network.chat.Style style, String command)
      Handles a custom command. The given style can be modified, or a completely new style can be created The default implementation does nothing.