MCPcopy Create free account
hub / github.com/Teneted/Tenet / getLastColors

Method getLastColors

src/main/java/org/bukkit/ChatColor.java:372–398  ·  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.

(@NotNull String input)

Source from the content-addressed store, hash-verified

370 * @return Any remaining ChatColors to pass onto the next line.
371 */
372 @NotNull
373 public static String getLastColors(@NotNull String input) {
374 Validate.notNull(input, "Cannot get last colors from null text");
375
376 String result = "";
377 int length = input.length();
378
379 // Search backwards from the end as it is faster
380 for (int index = length - 1; index > -1; index--) {
381 char section = input.charAt(index);
382 if (section == COLOR_CHAR && index < length - 1) {
383 char c = input.charAt(index + 1);
384 ChatColor color = getByChar(c);
385
386 if (color != null) {
387 result = color.toString() + result;
388
389 // Once we find a color or reset we can stop searching
390 if (color.isColor() || color.equals(RESET)) {
391 break;
392 }
393 }
394 }
395 }
396
397 return result;
398 }
399
400 static {
401 for (ChatColor color : values()) {

Callers

nothing calls this directly

Calls 5

getByCharMethod · 0.95
toStringMethod · 0.95
isColorMethod · 0.95
equalsMethod · 0.65
lengthMethod · 0.45

Tested by

no test coverage detected