Skip to content
Permalink
Browse files

Added colorize method

  • Loading branch information...
fromgate authored and fromgate committed Dec 10, 2015
1 parent e051002 commit 1cf64a97692e6c59c41d1b351550e458bc9bd8dc
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/main/java/cn/nukkit/utils/TextFormat.java
@@ -61,5 +61,15 @@ public static String toANSI(String string) {
string = string.replace(TextFormat.WHITE, (char) 0x1b + "[37;1m");
return string;
}
public static String colorize(String textToColorize){
char[] b = textToColorize.toCharArray();
for (int i = 0; i < b.length - 1; i++) {
if ((b[i] == '&') && ("0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[(i + 1)]) > -1)){
b[i] = '§';
b[(i + 1)] = Character.toLowerCase(b[(i + 1)]);
}
}
return new String(b);
}

}

0 comments on commit 1cf64a9

Please sign in to comment.
You can’t perform that action at this time.