From 88419b207579533646ab011da886030ea9ea4862 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Wed, 20 Mar 2024 21:47:50 +0000 Subject: [PATCH] Do not copy profile data if profiles are the same (#10259) --- patches/server/0134-Basic-PlayerProfile-API.patch | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/patches/server/0134-Basic-PlayerProfile-API.patch b/patches/server/0134-Basic-PlayerProfile-API.patch index a41c0666bc..2a1ca07786 100644 --- a/patches/server/0134-Basic-PlayerProfile-API.patch +++ b/patches/server/0134-Basic-PlayerProfile-API.patch @@ -16,10 +16,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..daa157eaa021d039f9a092bea0b78f7c1f746e3b +index 0000000000000000000000000000000000000000..68c99e29450e318d2b6eb83099e3e4012b6f0c01 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java -@@ -0,0 +1,409 @@ +@@ -0,0 +1,412 @@ +package com.destroystokyo.paper.profile; + +import com.mojang.authlib.yggdrasil.ProfileResult; @@ -236,7 +236,7 @@ index 0000000000000000000000000000000000000000..daa157eaa021d039f9a092bea0b78f7c + // if old has it, assume its newer, so overwrite, else use cached if it was set and ours wasn't + copyProfileProperties(this.profile, profile); + this.profile = profile; -+ } else { ++ } else if (profile != this.profile) { + copyProfileProperties(profile, this.profile); + } + } @@ -267,6 +267,9 @@ index 0000000000000000000000000000000000000000..daa157eaa021d039f9a092bea0b78f7c + } + + private static void copyProfileProperties(GameProfile source, GameProfile target, boolean clearTarget) { ++ if (source == target) { ++ throw new IllegalArgumentException("Source and target profiles are the same (" + source + ")"); ++ } + PropertyMap sourceProperties = source.getProperties(); + PropertyMap targetProperties = target.getProperties(); + if (clearTarget) targetProperties.clear();