Class RGBUtils

java.lang.Object
me.neznamy.tab.api.chat.rgb.RGBUtils

public class RGBUtils extends Object
A helper class to reformat all RGB formats into the default #RRGGBB and apply gradients
  • Constructor Details

    • RGBUtils

      public RGBUtils()
      Constructs new instance and loads all RGB patterns and gradients
  • Method Details

    • getInstance

      public static RGBUtils getInstance()
      Returns instance of this class
      Returns:
      instance
    • applyFormats

      public String applyFormats(String text)
      Applies all RGB formats and gradients to text and returns it.
      Parameters:
      text - original text
      Returns:
      text where everything is converted to #RRGGBB
    • applyCleanGradients

      public String applyCleanGradients(String text)
      Applies all gradient formats to text and returns it. This only affects usage where no placeholder is used inside.
      Parameters:
      text - original text
      Returns:
      text where all gradients with static text are converted to #RRGGBB
    • convertToBukkitFormat

      public String convertToBukkitFormat(String text, boolean rgbClient)
      Converts TAB's RGB format (#RRGGBB) into bukkit one (&x&r&r&g&g&b&b) for modern clients (1.16+), for legacy clients it will use the closest color.
      Parameters:
      text - text to convert
      rgbClient - whether client accepts RGB or not
      Returns:
      converted text
    • convertRGBtoLegacy

      public String convertRGBtoLegacy(String text)
      Converts all hex codes in given string to legacy codes
      Parameters:
      text - text to convert
      Returns:
      translated text
    • isHexCode

      public boolean isHexCode(String string)
      Returns true if entered string is a valid 6-digit combination of hexadecimal numbers, false if not
      Parameters:
      string - string to check
      Returns:
      true if valid, false if not