Commits

DerFrZocker authored 7c6bf15d443
Fix SkullMeta configuration serialization / deserialization with note block sound
No tags
master

src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java

Modified
91 91 Object object = map.get(SKULL_OWNER.BUKKIT);
92 92 if (object instanceof PlayerProfile) {
93 93 setOwnerProfile((PlayerProfile) object);
94 94 } else {
95 95 setOwner(SerializableMeta.getString(map, SKULL_OWNER.BUKKIT, true));
96 96 }
97 97 }
98 98
99 99 if (noteBlockSound == null) {
100 100 Object object = map.get(NOTE_BLOCK_SOUND.BUKKIT);
101 - if (object instanceof NamespacedKey) {
102 - setNoteBlockSound((NamespacedKey) object);
103 - } else {
104 - setNoteBlockSound(SerializableMeta.getObject(NamespacedKey.class, map, NOTE_BLOCK_SOUND.BUKKIT, true));
101 + if (object != null) {
102 + setNoteBlockSound(NamespacedKey.fromString(object.toString()));
105 103 }
106 104 }
107 105 }
108 106
109 107 @Override
110 108 void deserializeInternal(NBTTagCompound tag, Object context) {
111 109 super.deserializeInternal(tag, context);
112 110
113 111 if (tag.contains(SKULL_PROFILE.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
114 112 NBTTagCompound skullTag = tag.getCompound(SKULL_PROFILE.NBT);
298 296 }
299 297
300 298 @Override
301 299 Builder<String, Object> serialize(Builder<String, Object> builder) {
302 300 super.serialize(builder);
303 301 if (this.profile != null) {
304 302 return builder.put(SKULL_OWNER.BUKKIT, new CraftPlayerProfile(this.profile));
305 303 }
306 304 NamespacedKey namespacedKeyNB = this.getNoteBlockSound();
307 305 if (namespacedKeyNB != null) {
308 - return builder.put(NOTE_BLOCK_SOUND.BUKKIT, namespacedKeyNB);
306 + return builder.put(NOTE_BLOCK_SOUND.BUKKIT, namespacedKeyNB.toString());
309 307 }
310 308 return builder;
311 309 }
312 310
313 311 private void checkForInconsistency() {
314 312 if (profile != null && serializedProfile == null) {
315 313 // SPIGOT-7510: Fix broken reflection usage from plugins
316 314 Bukkit.getLogger().warning("""
317 315 Found inconsistent skull meta, this should normally not happen and is not a Bukkit / Spigot issue, but one from a plugin you are using.
318 316 Bukkit will attempt to fix it this time for you, but may not be able to do this every time.

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut