Skip to content

Commit

Permalink
Do not NPE on uuid resolution in player profile (#11449)
Browse files Browse the repository at this point in the history
Band-aid fix for the player profile api resolution for a profile with
name but without uuid. The real solution is a proper refactoring of the
completeFromCache and complete method internally, however this needs
further consideration regarding existing faulty behaviour around name
lookups from uuid-only profiles.
  • Loading branch information
lynxplay authored Sep 29, 2024
1 parent b410fe8 commit ea00be3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions patches/server/0136-Basic-PlayerProfile-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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..9a7add1a7b137a0c9ca9c69fec674a7720d954eb
index 0000000000000000000000000000000000000000..8849862b45ccbbc635a1c316e9870bca81e55c04
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
@@ -0,0 +1,449 @@
@@ -0,0 +1,451 @@
+package com.destroystokyo.paper.profile;
+
+import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -250,6 +250,7 @@ index 0000000000000000000000000000000000000000..9a7add1a7b137a0c9ca9c69fec674a77
+ // 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;
+ this.emptyUUID = false; // UUID was just retrieved from user cache and profile isn't null (so a completed profile was found)
+ }
+ }
+
Expand All @@ -261,6 +262,7 @@ index 0000000000000000000000000000000000000000..9a7add1a7b137a0c9ca9c69fec674a77
+ // 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;
+ this.emptyName = false; // Name was just retrieved via the userCache
+ } else if (profile != this.profile) {
+ copyProfileProperties(profile, this.profile);
+ }
Expand All @@ -281,7 +283,7 @@ index 0000000000000000000000000000000000000000..9a7add1a7b137a0c9ca9c69fec674a77
+ MinecraftServer server = MinecraftServer.getServer();
+ boolean isCompleteFromCache = this.completeFromCache(true, onlineMode);
+ if (onlineMode && (!isCompleteFromCache || (textures && !hasTextures()))) {
+ ProfileResult result = server.getSessionService().fetchProfile(this.getId(), true);
+ ProfileResult result = server.getSessionService().fetchProfile(this.profile.getId(), true);
+ if (result != null && result.profile() != null) {
+ copyProfileProperties(result.profile(), this.profile, true);
+ }
Expand Down

0 comments on commit ea00be3

Please sign in to comment.