aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
diff options
context:
space:
mode:
authorohowe <42757516+carelesshippo@users.noreply.github.com>2021-06-02 11:55:36 -0600
committerohowe <42757516+carelesshippo@users.noreply.github.com>2021-06-02 11:55:36 -0600
commiteeb5c45d71997cb259fc35330490a19db7865603 (patch)
tree65771b27ed837896fa3140dec1af78306accebcd /src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
parent4d9e538ced80728bca74491698347333f515bfcc (diff)
parent1b172089ce502803f7644611afd618ce00dcb860 (diff)
downloadnotenoughupdates-eeb5c45d71997cb259fc35330490a19db7865603.tar.gz
notenoughupdates-eeb5c45d71997cb259fc35330490a19db7865603.tar.bz2
notenoughupdates-eeb5c45d71997cb259fc35330490a19db7865603.zip
Merge branch 'Moulberry:master' into master
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
index 4a72a85e..d77f3c9e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -194,6 +194,28 @@ public class Utils {
return chromaString(str, 0, false);
}
+ private static final Pattern CHROMA_REPLACE_PATTERN = Pattern.compile("\u00a7z(.+?)(?=\u00a7|$)");
+
+ public static String chromaStringByColourCode(String str) {
+ if(str.contains("\u00a7z")) {
+ Matcher matcher = CHROMA_REPLACE_PATTERN.matcher(str);
+
+ StringBuffer sb = new StringBuffer();
+
+ while(matcher.find()) {
+ matcher.appendReplacement(sb,
+ Utils.chromaString(matcher.group(1))
+ .replace("\\", "\\\\")
+ .replace("$", "\\$")
+ );
+ }
+ matcher.appendTail(sb);
+
+ str = sb.toString();
+ }
+ return str;
+ }
+
private static long startTime = 0;
public static String chromaString(String str, float offset, boolean bold) {
str = cleanColour(str);