From d304722608bca52b0cd7ef119d3ece6d42b303b5 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 1 Jul 2020 03:13:57 -0400
Subject: [PATCH] Fix supporting more places of the old UUID format

Fixes #3734
---
 ...ix-client-rendering-skulls-from-same-user.patch |  6 +++---
 .../0527-Support-old-UUID-format-for-NBT.patch     | 14 ++++++++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/Spigot-Server-Patches/0266-Fix-client-rendering-skulls-from-same-user.patch b/Spigot-Server-Patches/0266-Fix-client-rendering-skulls-from-same-user.patch
index a2d8011094..4fd155690f 100644
--- a/Spigot-Server-Patches/0266-Fix-client-rendering-skulls-from-same-user.patch
+++ b/Spigot-Server-Patches/0266-Fix-client-rendering-skulls-from-same-user.patch
@@ -25,7 +25,7 @@ index 7b2010ec4955fb5788c60178c6e306ea3098e9ba..95e801a9a7ca405ff7e80c920fa78493
      private Entity k;
      private ShapeDetectorBlock l;
 diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
-index 6e049c2e2a142ce022b9dc278a3bb302f723e42c..91235f7bc80967a759ed8bb25d74ff0af6e25ef4 100644
+index 6e049c2e2a142ce022b9dc278a3bb302f723e42c..7e116d83a62ef42e241ee9e05fdd7ecb30a2ed95 100644
 --- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
 +++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
 @@ -274,9 +274,18 @@ public class PacketDataSerializer extends ByteBuf {
@@ -39,8 +39,8 @@ index 6e049c2e2a142ce022b9dc278a3bb302f723e42c..91235f7bc80967a759ed8bb25d74ff0a
 +                // Paper start
 +                if (nbttagcompound != null && nbttagcompound.hasKeyOfType("SkullOwner", 10)) {
 +                    NBTTagCompound owner = nbttagcompound.getCompound("SkullOwner");
-+                    if (owner.hasKey("Id")) {
-+                        nbttagcompound.map.put("SkullOwnerOrig", owner.map.get("Id"));
++                    if (owner.hasUUID("Id")) {
++                        nbttagcompound.setUUID("SkullOwnerOrig", owner.getUUID("Id"));
 +                        TileEntitySkull.sanitizeUUID(owner);
 +                    }
 +                }
diff --git a/Spigot-Server-Patches/0527-Support-old-UUID-format-for-NBT.patch b/Spigot-Server-Patches/0527-Support-old-UUID-format-for-NBT.patch
index a40c1b1746..6146aec771 100644
--- a/Spigot-Server-Patches/0527-Support-old-UUID-format-for-NBT.patch
+++ b/Spigot-Server-Patches/0527-Support-old-UUID-format-for-NBT.patch
@@ -8,10 +8,10 @@ We have stored UUID in plenty of places that did not get DFU'd
 So just look for old format and load it if it exists.
 
 diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java
-index f608b35502890650adfc1df35e0794471f57ecbc..93b25e4580646ccfe8c671511e2250dbe7474a89 100644
+index f608b35502890650adfc1df35e0794471f57ecbc..74a8418b72f97a8956857a46fb06251602ad30e3 100644
 --- a/src/main/java/net/minecraft/server/NBTTagCompound.java
 +++ b/src/main/java/net/minecraft/server/NBTTagCompound.java
-@@ -142,6 +142,11 @@ public class NBTTagCompound implements NBTBase {
+@@ -142,11 +142,21 @@ public class NBTTagCompound implements NBTBase {
      @Nullable public UUID getUUID(String prefix) { return a(prefix); } // Paper - OBFHELPER
      @Nullable
      public UUID a(String s) {
@@ -23,3 +23,13 @@ index f608b35502890650adfc1df35e0794471f57ecbc..93b25e4580646ccfe8c671511e2250db
          return GameProfileSerializer.a(this.get(s));
      }
  
+     public final boolean hasUUID(String s) { return this.b(s); } // Paper - OBFHELPER
+     public boolean b(String s) {
++        // Paper start - support old format
++        if (hasKey(s + "Least") && hasKey(s + "Most")) {
++            return true;
++        }
++        // Paper end
+         NBTBase nbtbase = this.get(s);
+ 
+         return nbtbase != null && nbtbase.b() == NBTTagIntArray.a && ((NBTTagIntArray) nbtbase).getInts().length == 4;