Gets the ChatColors used at the end of the given input string. @param input Input string to retrieve the colors from. @return Any remaining ChatColors to pass onto the next line.
(String input)
| 511 | * @return Any remaining ChatColors to pass onto the next line. |
| 512 | */ |
| 513 | public static String getLastColors(String input) { |
| 514 | String result = ""; |
| 515 | int length = input.length(); |
| 516 | |
| 517 | // Search backwards from the end as it is faster |
| 518 | for (int index = length - 1; index > -1; index--) { |
| 519 | char section = input.charAt(index); |
| 520 | if (section == COLOR_CHAR && index < length - 1) { |
| 521 | char c = input.charAt(index + 1); |
| 522 | C color = getByChar(c); |
| 523 | |
| 524 | if (color != null) { |
| 525 | result = color + result; |
| 526 | |
| 527 | // Once we find a color or reset we can stop searching |
| 528 | if (color.isColor() || color.equals(RESET)) { |
| 529 | break; |
| 530 | } |
| 531 | } |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | return result; |
| 536 | } |
| 537 | |
| 538 | public net.md_5.bungee.api.ChatColor asBungee() { |
| 539 | return net.md_5.bungee.api.ChatColor.RESET; |
no test coverage detected