From 1dabfdc82f7ae656b4d9d9304b23dbb8881b4057 Mon Sep 17 00:00:00 2001 From: SydMontague Date: Fri, 25 Sep 2020 17:09:59 +1000 Subject: [PATCH] #754: Fix pre-1.16 serialized SkullMeta being broken on 1.16+, losing textures The underlying issue is a change by Mojang how UUID are stored in NBT. This patch will have CraftBukkit convert the format during deserialization. --- .../bukkit/craftbukkit/inventory/CraftMetaSkull.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java index bb48da6056..55c86a893f 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.inventory; import com.google.common.collect.ImmutableMap.Builder; import com.mojang.authlib.GameProfile; import java.util.Map; +import java.util.UUID; import net.minecraft.server.GameProfileSerializer; import net.minecraft.server.NBTBase; import net.minecraft.server.NBTTagCompound; @@ -59,7 +60,14 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { super.deserializeInternal(tag, context); if (tag.hasKeyOfType(SKULL_PROFILE.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) { - this.setProfile(GameProfileSerializer.deserialize(tag.getCompound(SKULL_PROFILE.NBT))); + NBTTagCompound skullTag = tag.getCompound(SKULL_PROFILE.NBT); + // convert type of stored Id from String to UUID for backwards compatibility + if (skullTag.hasKeyOfType("Id", CraftMagicNumbers.NBT.TAG_STRING)) { + UUID uuid = UUID.fromString(skullTag.getString("Id")); + skullTag.a("Id", uuid); + } + + this.setProfile(GameProfileSerializer.deserialize(skullTag)); } }