Class MessageUtils

java.lang.Object
me.lokka30.levelledmobs.util.MessageUtils

public class MessageUtils extends Object
This class contains a bunch of methods which make it very easy to translate '&'-based color codes in messages. You can colorize standard codes (&a, &b, &1, &2, etc), and even hex codes (&#abccdef), and also both in one method :)
Since:
1.0.0
  • Constructor Details

    • MessageUtils

      public MessageUtils()
  • Method Details

    • colorizeAll

      @NotNull public static @NotNull String colorizeAll(String msg)
      Colorize a message, using '&' color codes - e.g. '&a' for ChatColor.GREEN. If the server is 1.16 or newer, then it will also translate hex codes - e.g. '&#abcdef'.
      Parameters:
      msg - the message to translate color codes from.
      Returns:
      the color-translated message.
      Since:
      unknown
      See Also:
    • colorizeHexCodes

      public static String colorizeHexCodes(String msg)
      This defaults the 'startTag' to '&#' and endTag to '' (nothing) to colorizeHexCodes.
      Parameters:
      msg - message to translate
      Returns:
      the translated string
      Since:
      unknown
      See Also:
    • colorizeHexCodes

      public static String colorizeHexCodes(String startTag, String endTag, String message)
      (WARNING!) This does NOT colorize standard codes, ONLY hex codes. This translates all hex codes in a message. Hex codes are prefixed by '&#', e.g. '&#abcdef'. This method ensures the version is 1.16 or newer before translating - else, it will not translate the message.
      Parameters:
      startTag - what the tag should begin with - '&#' is recommended
      endTag - what the tag should end with - '' (nothing) is recommended
      message - the message that should be translated
      Returns:
      the translated string
      Since:
      unknown
    • colorizeStandardCodes

      @NotNull public static @NotNull String colorizeStandardCodes(String msg)
      This does NOT colorize hex codes, ONLY standard codes. This translated all standard codes in a message. Standard codes are prefixed by '&', e.g. '&a'.
      Parameters:
      msg - the message to translate standard color codes from.
      Returns:
      the color-translated message.
      Since:
      unknown