35 lines
		
	
	
	
		
			1.4 KiB
			
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			1.4 KiB
			
		
	
	
	
		
			Diff
		
	
	
	
	
	
| --- a/net/minecraft/world/ChestLock.java
 | |
| +++ b/net/minecraft/world/ChestLock.java
 | |
| @@ -4,6 +4,11 @@
 | |
|  import net.minecraft.nbt.NBTTagCompound;
 | |
|  import net.minecraft.world.item.ItemStack;
 | |
|  
 | |
| +// CraftBukkit start
 | |
| +import org.bukkit.ChatColor;
 | |
| +import org.bukkit.craftbukkit.util.CraftChatMessage;
 | |
| +// CraftBukkit end
 | |
| +
 | |
|  @Immutable
 | |
|  public class ChestLock {
 | |
|  
 | |
| @@ -16,7 +21,19 @@
 | |
|      }
 | |
|  
 | |
|      public boolean unlocksWith(ItemStack itemstack) {
 | |
| -        return this.key.isEmpty() || !itemstack.isEmpty() && itemstack.hasCustomHoverName() && this.key.equals(itemstack.getHoverName().getString());
 | |
| +        // CraftBukkit start - SPIGOT-6307: Check for color codes if the lock contains color codes
 | |
| +        if (this.key.isEmpty()) return true;
 | |
| +        if (!itemstack.isEmpty() && itemstack.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(itemstack.getHoverName().getString());
 | |
| +            } else {
 | |
| +                // The lock key contains color codes, so let's take them into account:
 | |
| +                return this.key.equals(CraftChatMessage.fromComponent(itemstack.getHoverName()));
 | |
| +            }
 | |
| +        }
 | |
| +        return false;
 | |
| +        // CraftBukkit end
 | |
|      }
 | |
|  
 | |
|      public void addToTag(NBTTagCompound nbttagcompound) {
 | 
