From 85d19c8d5bd911f5f2dac881e3f8fb78ebf39d32 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Mon, 16 Sep 2024 20:53:00 +0200 Subject: [PATCH] Prevent NPE when serializing unresolved profile (#11407) In the recent upstream update, the paper player profile was updated to correctly return null for both name and id if constructed as such. This change however broke the serialisation logic, as it depended on the name never being null. The commit moves the checks over to the newly introduced emptyName/UUID fields that track if the profile was constructed with a null name or uuid to differentiate it against an empty string or the NIL_UUID. --- patches/server/Basic-PlayerProfile-API.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/server/Basic-PlayerProfile-API.patch b/patches/server/Basic-PlayerProfile-API.patch index 8ae62d2813..4ba854c14b 100644 --- a/patches/server/Basic-PlayerProfile-API.patch +++ b/patches/server/Basic-PlayerProfile-API.patch @@ -357,10 +357,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public @NotNull Map serialize() { + Map map = new LinkedHashMap<>(); -+ if (this.getId() != null) { ++ if (!this.emptyUUID) { + map.put("uniqueId", this.getId().toString()); + } -+ if (!this.getName().isEmpty()) { ++ if (!this.emptyName) { + map.put("name", getName()); + } + if (!this.properties.isEmpty()) {