mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 12dec20 Bump paerweight to 1.1.7 e33ed89 Get short commit ref using a more proper method 7d6147d Remove now unneeded patch due to paperweight 1.1.7 e72fa41 Update task dependency for includeMappings so the new task isn't skipped 0ad5526 Trim whitspace off of git hash (oops) Tuinity Changes: e878ba9 Update paper 2bd2849 Bring back fix codec spam patch
42 lines
1.5 KiB
Diff
42 lines
1.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Fri, 10 Jul 2020 12:43:25 -0500
|
|
Subject: [PATCH] ChatColor conveniences
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/ChatColor.java b/src/main/java/org/bukkit/ChatColor.java
|
|
index 4594701d77c5d0f744bece871b98d9f6f73eb5a7..499b222dee1f11d497a29a9a263a5596401ca1eb 100644
|
|
--- a/src/main/java/org/bukkit/ChatColor.java
|
|
+++ b/src/main/java/org/bukkit/ChatColor.java
|
|
@@ -413,4 +413,30 @@ public enum ChatColor {
|
|
BY_CHAR.put(color.code, color);
|
|
}
|
|
}
|
|
+
|
|
+ // Purpur start
|
|
+ public static final Pattern HEX_PATTERN = Pattern.compile("(#[A-Fa-f0-9]{6})");
|
|
+
|
|
+ @Nullable
|
|
+ public static String replaceHex(@Nullable String str) {
|
|
+ if (str != null) {
|
|
+ java.util.regex.Matcher matcher = HEX_PATTERN.matcher(str);
|
|
+ while (matcher.find()) {
|
|
+ String group = matcher.group(1);
|
|
+ str = str.replace(group, net.md_5.bungee.api.ChatColor.of(group).toString());
|
|
+ }
|
|
+ }
|
|
+ return str;
|
|
+ }
|
|
+
|
|
+ @Nullable
|
|
+ public static String color(@Nullable String str) {
|
|
+ return color(str, true);
|
|
+ }
|
|
+
|
|
+ @Nullable
|
|
+ public static String color(@Nullable String str, boolean parseHex) {
|
|
+ return str != null ? net.md_5.bungee.api.ChatColor.translateAlternateColorCodes('&', parseHex ? replaceHex(str) : str) : str;
|
|
+ }
|
|
+ // Purpur end
|
|
}
|