Skip to content

Commit 74fe0aa

Browse files
committed
Add getStartColor method
1 parent de0e849 commit 74fe0aa

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/main/java/me/croabeast/prismatic/PrismaticAPI.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,21 @@ public boolean startsWithColor(String string) {
334334
return matcher.find();
335335
}
336336

337+
/**
338+
* Retrieves the start color code found in the provided string.
339+
*
340+
* @param string the string to search for color codes
341+
* @return the start color code as a {@link String}, or {@code null} if none is found
342+
*/
343+
@Nullable
344+
public String getStartColor(String string) {
345+
string = colorize(string);
346+
Matcher matcher = Pattern.compile(COLOR_PATTERN).matcher(string);
347+
String color = null;
348+
if (matcher.find()) color = matcher.group();
349+
return color;
350+
}
351+
337352
/**
338353
* Retrieves the end color code found in the provided string.
339354
*

0 commit comments

Comments
 (0)