From 0d443603be7771d7edc18e9fe5558a2194002f7a Mon Sep 17 00:00:00 2001 From: lol768 Date: Sun, 21 Oct 2012 22:36:28 +0200 Subject: [PATCH] Add translateAlternateColorCodes method --- src/main/java/net/md_5/bungee/ChatColor.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/net/md_5/bungee/ChatColor.java b/src/main/java/net/md_5/bungee/ChatColor.java index c5cfddbd..c42fc866 100644 --- a/src/main/java/net/md_5/bungee/ChatColor.java +++ b/src/main/java/net/md_5/bungee/ChatColor.java @@ -139,4 +139,17 @@ public enum ChatColor return STRIP_COLOR_PATTERN.matcher(input).replaceAll(""); } + public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) + { + char[] b = textToTranslate.toCharArray(); + for (int i = 0; i < b.length - 1; i++) + { + if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1) + { + b[i] = ChatColor.COLOR_CHAR; + b[i+1] = Character.toLowerCase(b[i+1]); + } + } + return new String(b); + } }