From 66819aee83b4106f7856f6debfb12ebabbe717a3 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Fri, 3 Dec 2021 19:24:22 -0500 Subject: [PATCH] Null check for player textures in GameProfile Fixes an issue with the ZNPCs plugin. --- .../org/geysermc/geyser/skin/SkinManager.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java b/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java index 02b4123e5..16833d634 100644 --- a/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java +++ b/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java @@ -240,7 +240,12 @@ public class SkinManager { // Likely offline mode return loadBedrockOrOfflineSkin(profile); } - return loadFromJson(skinProperty.getValue()); + GameProfileData data = loadFromJson(skinProperty.getValue()); + if (data != null) { + return data; + } else { + return loadBedrockOrOfflineSkin(profile); + } } catch (IOException exception) { GeyserImpl.getInstance().getLogger().debug("Something went wrong while processing skin for " + profile.getName()); if (GeyserImpl.getInstance().getConfig().isDebugMode()) { @@ -254,18 +259,21 @@ public class SkinManager { JsonNode skinObject = GeyserImpl.JSON_MAPPER.readTree(new String(Base64.getDecoder().decode(encodedJson), StandardCharsets.UTF_8)); JsonNode textures = skinObject.get("textures"); - JsonNode skinTexture = textures.get("SKIN"); - String skinUrl = skinTexture.get("url").asText().replace("http://", "https://"); + if (textures != null) { + JsonNode skinTexture = textures.get("SKIN"); + String skinUrl = skinTexture.get("url").asText().replace("http://", "https://"); - boolean isAlex = skinTexture.has("metadata"); + boolean isAlex = skinTexture.has("metadata"); - String capeUrl = null; - JsonNode capeTexture = textures.get("CAPE"); - if (capeTexture != null) { - capeUrl = capeTexture.get("url").asText().replace("http://", "https://"); + String capeUrl = null; + JsonNode capeTexture = textures.get("CAPE"); + if (capeTexture != null) { + capeUrl = capeTexture.get("url").asText().replace("http://", "https://"); + } + + return new GameProfileData(skinUrl, capeUrl, isAlex); } - - return new GameProfileData(skinUrl, capeUrl, isAlex); + return null; } /**