Commits
DerFrZocker authored and md_5 committed 6a54e5d374f
1 1 | package org.bukkit.craftbukkit.inventory; |
2 2 | |
3 3 | import com.google.common.collect.ImmutableMap.Builder; |
4 4 | import com.mojang.authlib.GameProfile; |
5 5 | import java.util.Map; |
6 6 | import java.util.UUID; |
7 7 | import net.minecraft.nbt.GameProfileSerializer; |
8 - | import net.minecraft.nbt.NBTBase; |
9 8 | import net.minecraft.nbt.NBTTagCompound; |
10 9 | import net.minecraft.world.level.block.entity.TileEntitySkull; |
11 10 | import org.bukkit.Bukkit; |
12 11 | import org.bukkit.Material; |
13 12 | import org.bukkit.OfflinePlayer; |
14 13 | import org.bukkit.configuration.serialization.DelegateDeserialization; |
15 14 | import org.bukkit.craftbukkit.entity.CraftPlayer; |
16 15 | import org.bukkit.craftbukkit.inventory.CraftMetaItem.ItemMetaKey; |
17 16 | import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta; |
18 17 | import org.bukkit.craftbukkit.profile.CraftPlayerProfile; |
72 71 | // convert type of stored Id from String to UUID for backwards compatibility |
73 72 | if (skullTag.contains("Id", CraftMagicNumbers.NBT.TAG_STRING)) { |
74 73 | UUID uuid = UUID.fromString(skullTag.getString("Id")); |
75 74 | skullTag.putUUID("Id", uuid); |
76 75 | } |
77 76 | |
78 77 | this.setProfile(GameProfileSerializer.readGameProfile(skullTag)); |
79 78 | } |
80 79 | } |
81 80 | |
82 - | |
83 - | void serializeInternal(final Map<String, NBTBase> internalTags) { |
84 - | if (profile != null) { |
85 - | internalTags.put(SKULL_PROFILE.NBT, serializedProfile); |
86 - | } |
87 - | } |
88 - | |
89 81 | private void setProfile(GameProfile profile) { |
90 82 | this.profile = profile; |
91 83 | this.serializedProfile = (profile == null) ? null : GameProfileSerializer.writeGameProfile(new NBTTagCompound(), profile); |
92 84 | } |
93 85 | |
94 86 | |
95 87 | void applyToItem(NBTTagCompound tag) { |
96 88 | super.applyToItem(tag); |
97 89 | |
98 90 | if (profile != null) { |
237 229 | } |
238 230 | |
239 231 | |
240 232 | boolean notUncommon(CraftMetaItem meta) { |
241 233 | return super.notUncommon(meta) && (meta instanceof CraftMetaSkull || isSkullEmpty()); |
242 234 | } |
243 235 | |
244 236 | |
245 237 | Builder<String, Object> serialize(Builder<String, Object> builder) { |
246 238 | super.serialize(builder); |
247 - | if (hasOwner()) { |
239 + | if (this.profile != null) { |
248 240 | return builder.put(SKULL_OWNER.BUKKIT, new CraftPlayerProfile(this.profile)); |
249 241 | } |
250 242 | return builder; |
251 243 | } |
252 244 | } |