MCPcopy Create free account
hub / github.com/VolmitSoftware/Adapt / getLastColors

Method getLastColors

src/main/java/com/volmit/adapt/util/C.java:513–536  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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;

Callers 2

translateToEntryMethod · 0.95

Calls 4

getByCharMethod · 0.95
isColorMethod · 0.95
lengthMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected