- StringReader reader = new StringReader(line);
-
- try {
- int inColorCode = 0;
- while (true) {
- int r = reader.read();
- if (r == -1) {
- break;
- }
- char c = (char) r;
- if ((c == 2) && (attributes.contains(Attributes.bold))) {
- continue;
- }
- if ((c == 3) && (attributes.contains(Attributes.color))) {
- inColorCode = 1;
- continue;
- }
- if ((c == 15) && (attributes.contains(Attributes.clear))) {
- continue;
- }
- if ((c == 22) && attributes.contains(reverse)) {
- continue;
- }
- if ((c == 29) && attributes.contains(italics)) {
- continue;
- }
- if ((c == 31) && attributes.contains(underline)) {
- continue;
- }
- if (inColorCode > 0) {
- if (inColorCode == 1) {
- if ((c < '0') || (c > '9')) {
- inColorCode = 0;
- } else {
- if (c == '9') {
- inColorCode = 8;
- } else {
- ++inColorCode;
- }
- continue;
- }
- } else if (inColorCode == 2) {
- if (c == ',') {
- inColorCode = 4;
- continue;
- }
- if ((c < '0') || (c > '5')) {
- inColorCode = 0;
- } else {
- ++inColorCode;
- continue;
- }
- } else if (inColorCode == 3) {
- if (c == ',') {
- ++inColorCode;
- continue;
- } else {
- inColorCode = 0;
- }
- } else if (inColorCode == 4) {
+ int inColorCode = 0;
+ for (char c : line.toCharArray()) {
+ if ((c == 2) && (attributes.contains(Attributes.bold))) {
+ continue;
+ }
+ if ((c == 3) && (attributes.contains(Attributes.color))) {
+ inColorCode = 1;
+ continue;
+ }
+ if ((c == 15) && (attributes.contains(Attributes.clear))) {
+ continue;
+ }
+ if ((c == 22) && attributes.contains(reverse)) {
+ continue;
+ }
+ if ((c == 29) && attributes.contains(italics)) {
+ continue;
+ }
+ if ((c == 31) && attributes.contains(underline)) {
+ continue;
+ }
+ if (inColorCode > 0) {
+ if (inColorCode == 1) {
+ if ((c < '0') || (c > '9')) {
+ inColorCode = 0;
+ } else {