aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/LockCode.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/LockCode.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/LockCode.java.patch58
1 files changed, 58 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/LockCode.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/LockCode.java.patch
new file mode 100644
index 0000000000..17b2d74885
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/LockCode.java.patch
@@ -0,0 +1,58 @@
+--- a/net/minecraft/world/LockCode.java
++++ b/net/minecraft/world/LockCode.java
+@@ -4,29 +4,46 @@
+ import net.minecraft.nbt.CompoundTag;
+ import net.minecraft.world.item.ItemStack;
+
++// CraftBukkit start
++import org.bukkit.ChatColor;
++import org.bukkit.craftbukkit.util.CraftChatMessage;
++// CraftBukkit end
++
+ @Immutable
+ public class LockCode {
+
+ public static final LockCode NO_LOCK = new LockCode("");
+ public static final String TAG_LOCK = "Lock";
+- private final String key;
++ public final String key;
+
+- public LockCode(String s) {
+- this.key = s;
++ public LockCode(String key) {
++ this.key = key;
+ }
+
+- public boolean unlocksWith(ItemStack itemstack) {
+- return this.key.isEmpty() || !itemstack.isEmpty() && itemstack.hasCustomHoverName() && this.key.equals(itemstack.getHoverName().getString());
++ public boolean unlocksWith(ItemStack stack) {
++ // CraftBukkit start - SPIGOT-6307: Check for color codes if the lock contains color codes
++ if (this.key.isEmpty()) return true;
++ if (!stack.isEmpty() && stack.hasCustomHoverName()) {
++ 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(stack.getHoverName().getString());
++ } else {
++ // The lock key contains color codes, so let's take them into account:
++ return this.key.equals(CraftChatMessage.fromComponent(stack.getHoverName()));
++ }
++ }
++ return false;
++ // CraftBukkit end
+ }
+
+- public void addToTag(CompoundTag compoundtag) {
++ public void addToTag(CompoundTag nbt) {
+ if (!this.key.isEmpty()) {
+- compoundtag.putString("Lock", this.key);
++ nbt.putString("Lock", this.key);
+ }
+
+ }
+
+- public static LockCode fromTag(CompoundTag compoundtag) {
+- return compoundtag.contains("Lock", 8) ? new LockCode(compoundtag.getString("Lock")) : LockCode.NO_LOCK;
++ public static LockCode fromTag(CompoundTag nbt) {
++ return nbt.contains("Lock", 8) ? new LockCode(nbt.getString("Lock")) : LockCode.NO_LOCK;
+ }
+ }