2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/ChestLock.java
|
|
|
|
+++ b/net/minecraft/world/ChestLock.java
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -6,6 +6,11 @@
|
|
|
|
import net.minecraft.network.chat.IChatBaseComponent;
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.item.ItemStack;
|
2021-03-08 22:47:33 +01:00
|
|
|
|
2021-02-20 23:47:11 +01:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.ChatColor;
|
|
|
|
+import org.bukkit.craftbukkit.util.CraftChatMessage;
|
|
|
|
+// CraftBukkit end
|
2021-03-08 22:47:33 +01:00
|
|
|
+
|
2024-04-23 17:15:00 +02:00
|
|
|
public record ChestLock(String key) {
|
2021-03-08 22:47:33 +01:00
|
|
|
|
2024-04-23 17:15:00 +02:00
|
|
|
public static final ChestLock NO_LOCK = new ChestLock("");
|
|
|
|
@@ -18,7 +23,19 @@
|
|
|
|
} else {
|
|
|
|
IChatBaseComponent ichatbasecomponent = (IChatBaseComponent) itemstack.get(DataComponents.CUSTOM_NAME);
|
2021-02-20 23:47:11 +01:00
|
|
|
|
2024-04-23 17:15:00 +02:00
|
|
|
- return ichatbasecomponent != null && this.key.equals(ichatbasecomponent.getString());
|
|
|
|
+ // CraftBukkit start - SPIGOT-6307: Check for color codes if the lock contains color codes
|
|
|
|
+ if (this.key.isEmpty()) return true;
|
|
|
|
+ if (ichatbasecomponent != null) {
|
|
|
|
+ if (this.key.indexOf(ChatColor.COLOR_CHAR) == -1) {
|
|
|
|
+ // The lock key contains no color codes, so let's ignore colors in the item display name (vanilla Minecraft behavior):
|
|
|
|
+ return this.key.equals(ichatbasecomponent.getString());
|
|
|
|
+ } else {
|
|
|
|
+ // The lock key contains color codes, so let's take them into account:
|
|
|
|
+ return this.key.equals(CraftChatMessage.fromComponent(ichatbasecomponent));
|
|
|
|
+ }
|
2021-02-20 23:47:11 +01:00
|
|
|
+ }
|
2024-04-23 17:15:00 +02:00
|
|
|
+ return false;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2021-02-20 23:47:11 +01:00
|
|
|
}
|
|
|
|
|