[SPIGOT-7986] CraftPlayerProfile serialization converts empty name to null which is not considered equal Created: 22/Dec/24  Updated: 25/Dec/24  Resolved: 23/Dec/24

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

Type: Bug Priority: Minor
Reporter: blablubbabc Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Version: This server is running CraftBukkit version 4402-Spigot-33ece3e-665900b (MC: 1.21.4) (Implementing API version 1.21.4-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/8d52226914ce4b99f35be3d6954f35616d92476d#src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Fprofile%2FCraftPlayerProfile.java?f=245

I think we missed to also replace the `getName()` call in the serialization `map.put("name", getName());` to `this.name`. One side effect of this is that an empty name `""` gets converted to null during serialization, which is not considered equal in the CraftPlayerProfile.equals method once loaded again.

Alternatively, we could normalize empty names to null or vice versa. But I am not sure if this would be consistent with Minecraft, i.e. if Minecraft's GameProfile differentiates between non-present and empty name (which I think it does, looking at the decompiled source code), then CraftPlayerProfile should probably mimic that.

And related to that: Minecraft seems to convert ResolvableProfile's non-present Optional name to a GameProfile with an empty name (see ResolvableProfile.resolve()), whereas we convert it to a profile with a null name (see CraftPlayerProfile constructor). This inconsistency might be a problem as well.


Generated at Sun Mar 30 02:36:45 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.