Paper/patches/api/0214-Support-hex-colors-in-getLastColors.patch
Nassim Jahnke 928bcc8d3a
Updated Upstream (Bukkit/CraftBukkit) (#8430)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
09943450 Update SnakeYAML version
5515734f SPIGOT-7162: Incorrect description for Entity#getVehicle javadoc
6f82b381 PR-788: Add getHand() to all relevant events

CraftBukkit Changes:
aaf484f6f SPIGOT-7163: CraftMerchantRecipe doesn't copy demand and specialPrice from BukkitMerchantRecipe
5329dd6fd PR-1107: Add getHand() to all relevant events
93061706e SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
2022-10-02 09:56:36 +02:00

35 lines
1.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Gerrygames <gecam59@gmail.com>
Date: Thu, 16 Jul 2020 10:40:10 +0200
Subject: [PATCH] Support hex colors in getLastColors
diff --git a/src/main/java/org/bukkit/ChatColor.java b/src/main/java/org/bukkit/ChatColor.java
index 24ade174df77d75339b44bcd4b035e0c46d95dc3..f6eb30f53dad684f156102cf7147b2f00c82c71e 100644
--- a/src/main/java/org/bukkit/ChatColor.java
+++ b/src/main/java/org/bukkit/ChatColor.java
@@ -363,6 +363,7 @@ public enum ChatColor {
return new String(b);
}
+ private static final Pattern HEX_COLOR_PATTERN = Pattern.compile(COLOR_CHAR + "x(?>" + COLOR_CHAR + "[0-9a-f]){6}", Pattern.CASE_INSENSITIVE); // Paper - Support hex colors in getLastColors
/**
* Gets the ChatColors used at the end of the given input string.
*
@@ -380,6 +381,15 @@ public enum ChatColor {
for (int index = length - 1; index > -1; index--) {
char section = input.charAt(index);
if (section == COLOR_CHAR && index < length - 1) {
+ // Paper start - Support hex colors
+ if (index > 11 && input.charAt(index - 12) == COLOR_CHAR && (input.charAt(index - 11) == 'x' || input.charAt(index - 11) == 'X')) {
+ String color = input.substring(index - 12, index + 2);
+ if (HEX_COLOR_PATTERN.matcher(color).matches()) {
+ result = color + result;
+ break;
+ }
+ }
+ // Paper end
char c = input.charAt(index + 1);
ChatColor color = getByChar(c);