From c5941e1633e366f38358b2c135c69d8580a5a396 Mon Sep 17 00:00:00 2001 From: SplotyCode <31861387+SplotyCode@users.noreply.github.com> Date: Thu, 12 Oct 2023 03:20:25 +0200 Subject: [PATCH] Fix CraftPlayerProfile#setId regression (#9822) --- patches/server/Basic-PlayerProfile-API.patch | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/patches/server/Basic-PlayerProfile-API.patch b/patches/server/Basic-PlayerProfile-API.patch index ebd5d30baf..78af17ac4c 100644 --- a/patches/server/Basic-PlayerProfile-API.patch +++ b/patches/server/Basic-PlayerProfile-API.patch @@ -59,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + public CraftPlayerProfile(UUID id, String name) { -+ this.profile = new GameProfile(id != null ? id : Util.NIL_UUID, name != null ? name : ""); ++ this.profile = createAuthLibProfile(id, name); + } + + public CraftPlayerProfile(GameProfile profile) { @@ -111,7 +111,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public UUID setId(@Nullable UUID uuid) { + final GameProfile previousProfile = this.profile; + final UUID previousId = this.getId(); -+ this.profile = new GameProfile(previousProfile.getId(), previousProfile.getName()); ++ this.profile = createAuthLibProfile(uuid, previousProfile.getName()); + copyProfileProperties(previousProfile, this.profile); + return previousId; + } @@ -131,7 +131,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Deprecated(forRemoval = true) + public String setName(@Nullable String name) { + GameProfile prev = this.profile; -+ this.profile = new GameProfile(prev.getId(), name != null ? name : ""); ++ this.profile = createAuthLibProfile(prev.getId(), name); + copyProfileProperties(prev, this.profile); + return prev.getName(); + } @@ -281,6 +281,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + ++ private static GameProfile createAuthLibProfile(UUID uniqueId, String name) { ++ return new GameProfile( ++ uniqueId != null ? uniqueId : Util.NIL_UUID, ++ name != null ? name : "" ++ ); ++ } ++ + private static ProfileProperty toBukkit(Property property) { + return new ProfileProperty(property.name(), property.value(), property.signature()); + }