CraftPlayerProfile serialization converts empty name to null which is not considered equal

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None
    • This server is running CraftBukkit version 4402-Spigot-33ece3e-665900b (MC: 1.21.4) (Implementing API version 1.21.4-R0.1-SNAPSHOT)
    • Yes

      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.

            Assignee:
            Unassigned
            Reporter:
            blablubbabc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: