From f6134370195d24e249237c89e54cb8d87f80164a 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) --- .../server/0141-Basic-PlayerProfile-API.patch | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/patches/server/0141-Basic-PlayerProfile-API.patch b/patches/server/0141-Basic-PlayerProfile-API.patch index 2dbf82216b..20c78c20ae 100644 --- a/patches/server/0141-Basic-PlayerProfile-API.patch +++ b/patches/server/0141-Basic-PlayerProfile-API.patch @@ -17,10 +17,10 @@ public org.bukkit.craftbukkit.profile.CraftPlayerProfile setProperty(Ljava/lang/ diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java new file mode 100644 -index 0000000000000000000000000000000000000000..b7da8606e24b216b39020130fd2c42c7cd387a3a +index 0000000000000000000000000000000000000000..daa157eaa021d039f9a092bea0b78f7c1f746e3b --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java -@@ -0,0 +1,402 @@ +@@ -0,0 +1,409 @@ +package com.destroystokyo.paper.profile; + +import com.mojang.authlib.yggdrasil.ProfileResult; @@ -59,7 +59,7 @@ index 0000000000000000000000000000000000000000..b7da8606e24b216b39020130fd2c42c7 + } + + 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..b7da8606e24b216b39020130fd2c42c7 + 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..b7da8606e24b216b39020130fd2c42c7 + @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..b7da8606e24b216b39020130fd2c42c7 + } + } + ++ 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()); + }