Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Added colorize method
Browse files Browse the repository at this point in the history
  • Loading branch information
fromgate authored and fromgate committed Dec 10, 2015
1 parent e051002 commit 1cf64a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/cn/nukkit/utils/TextFormat.java
Expand Up @@ -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.