[SPIGOT-7735] SkullMeta serialization fails if both profile and note block sound are set Created: 09/Jun/24  Updated: 25/Dec/24  Resolved: 09/Jun/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Gadse Assignee: blablubbabc
Resolution: Fixed Votes: 0
Labels: SkullMeta, serialization
Environment:

Spigot 1.20.6, Spigot 1.20.4, Spigot 1.20


Attachments: File TestSerialize-1.0.0.jar     Zip Archive TestSerialize.zip    
Version: This server is running CraftBukkit version 4189-Spigot-fcd94e2-fd2f418 (MC: 1.20.6) (Implementing API version 1.20.6-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

The following is tested on the (at the time of writing) latest BuildTools built revisions for 1.20.6, 1.20.4 and 1.20.1. Only one plugin to create the item and test serialization/deserialization was running. Testing lower versions does not make sense as the note block tag was added in 1.20.

Creating a player head item and saving it to YAML comes with the following issue:

If the new note block sound tag is set, Spigot writes a note block tag during serialization,

  • 1.20.6 an "unhandled" tag is written as well. Some plugins may fail loading this.
  • 1.20.4 this works as expected.
  • 1.20 the "note_block_sound" key is written, but the value is set to "!!org.bukkit.NamespacedKey {}". This has been fixed in a later commit.

If just the profile/owning player is set, serialization works as expected.

If the profile/owning player and the note block sound are set, Spigot writes only the profile tag during serialization and does not write the note block sound. On 1.20.6, an "unhandled" tag is written as well.

Attached you may find a plugin to test this with. Use /itemboth to get a player head with a profile and a noteblock sound. Use /itemsound to get a player head with a noteblock sound. Use /itemprofile to get a player head with a profile. Use /serialize to display the serialized config in chat. The source to it has been attached as well for convenience.



 Comments   
Comment by Gadse [ 09/Jun/24 ]

Totally missed that return when reading it myself,  thanks for being so quick about it! Should I create a new issue for the unhandled tag? As you said, it's out of scope of the issue title/core.

Comment by blablubbabc [ 09/Jun/24 ]

Seems like CraftMetaItem.HANDLED_TAG is missing an entry for CraftMetaSkull.NOTE_BLOCK_SOUND.

Also, I briefly experimented with the provided test plugin, and trying to deserialize the item on 1.20.6 results in a crash (NRE), likely due to:
CraftMetaItem line 594 (https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java#594):
`ByteArrayInputStream buf = new ByteArrayInputStream(Base64.getDecoder().decode(internal));` should probably be
`ByteArrayInputStream buf = new ByteArrayInputStream(Base64.getDecoder().decode(unhandled));`

But I would currently expect these issues to be present regardless of whether or not a profile is assigned. Spotted the issue regarding the combination of a profile and a note block sound: There is a return in the serialization if a profile is set, skipping the note block sound serialization.

Will prepare a fix.

Generated at Sat Dec 13 19:00:15 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.