Interface ComponentService


public interface ComponentService
A utility api class for dealing with rich and less-rich Minecraft message formats.
See Also:
  • Method Details

    • getInstance

      static ComponentService getInstance()
      Obtain the instance of ComponentService.
      Returns:
      ComponentService implementation.
      Throws:
      NoClassDefFoundError - If Plan is not installed and this class can not be found or if older Plan version is installed.
      IllegalStateException - If Plan is installed, but not enabled.
    • translateLegacy

      default String translateLegacy(String input)
      Translates ampersands into section signs for color codes. Defaults to Component.AMPERSAND to Component.SECTION. Example: &ctext to §ctext.
      Parameters:
      input - the input color string with color codes using ampersands (&)
      Returns:
      the same input string with ampersands (&) for color codes replaced with section signs (§)
      See Also:
    • translateLegacy

      String translateLegacy(String input, char inputCharacter, char outputCharacter)
      Translates ampersands into section signs for color codes. Example: &ctext to §ctext.
      Parameters:
      input - the input color string with color codes using ampersands (&)
      inputCharacter - the input character for translation, usually &.
      outputCharacter - the output character for translation, usually §.
      Returns:
      the same input string with input characters for color codes replaced with output characters
      See Also:
    • fromAutoDetermine

      Component fromAutoDetermine(String unknown)
      Converts the given input into a Component. Converts an unknown format legacy/minimessage string into a component by attempting to guess the input format.
      Parameters:
      unknown - the unknown format input string
      Returns:
      a Component
    • fromLegacy

      default Component fromLegacy(String legacy)
      Converts the given input into a Component. Input example §ctext.
      Parameters:
      legacy - the input legacy
      Returns:
      a Component
      See Also:
    • fromLegacy

      Component fromLegacy(String legacy, char character)
      Converts the given input into a Component. Input example §ctext.
      Parameters:
      legacy - the input legacy
      character - the character to use as the color prefix, usually §.
      Returns:
      a Component
      See Also:
    • fromAdventureLegacy

      default Component fromAdventureLegacy(String adventureLegacy)
      Converts the given input into a Component. Input example: &#rrggbbtext.
      Parameters:
      adventureLegacy - the input adventure legacy
      Returns:
      a Component
      See Also:
    • fromAdventureLegacy

      Component fromAdventureLegacy(String adventureLegacy, char character)
      Converts the given input into a Component. Input example: &#rrggbbtext.
      Parameters:
      adventureLegacy - the input adventure legacy
      character - the character to use as the color prefix, usually &.
      Returns:
      a Component
      See Also:
    • fromBungeeLegacy

      default Component fromBungeeLegacy(String bungeeLegacy)
      Converts the given input into a Component. Input example: §x§r§r§g§g§b§btext.
      Parameters:
      bungeeLegacy - the input bungee legacy
      Returns:
      a Component
    • fromBungeeLegacy

      Component fromBungeeLegacy(String bungeeLegacy, char character)
      Converts the given input into a Component. Input example: §x§r§r§g§g§b§btext.
      Parameters:
      bungeeLegacy - the input bungee legacy
      character - the character to use as the color prefix, usually §.
      Returns:
      a Component
      See Also:
    • fromMiniMessage

      Component fromMiniMessage(String miniMessage)
      Converts the given input into a Component. Input example: <red>text</red>.
      Parameters:
      miniMessage - the input minimessage
      Returns:
      a Component
    • fromJson

      Component fromJson(String json)
      Converts the given input into a Component. Input example: {text:"text",color:"red"} (standard Minecraft json).
      Parameters:
      json - the input json
      Returns:
      a Component