#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.
This commit is contained in:
SydMontague 2020-09-25 17:09:59 +10:00 committed by md_5
parent f8d4da08e1
commit 1dabfdc82f
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -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));
}
}