From db9b9513527d6a5f6f1e9223442090664e2f891e Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Wed, 26 Jun 2024 22:35:54 -0400 Subject: [PATCH] Fix regression in properties get --- .../configuration/GeyserCustomSkullConfiguration.java | 10 ++++++++++ .../populator/CustomSkullRegistryPopulator.java | 1 + .../java/org/geysermc/geyser/skin/SkinProvider.java | 6 ++++-- .../main/java/org/geysermc/geyser/util/AssetUtils.java | 9 +++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/configuration/GeyserCustomSkullConfiguration.java b/core/src/main/java/org/geysermc/geyser/configuration/GeyserCustomSkullConfiguration.java index 46bbb2db1..48490fad0 100644 --- a/core/src/main/java/org/geysermc/geyser/configuration/GeyserCustomSkullConfiguration.java +++ b/core/src/main/java/org/geysermc/geyser/configuration/GeyserCustomSkullConfiguration.java @@ -57,4 +57,14 @@ public class GeyserCustomSkullConfiguration { public List getPlayerSkinHashes() { return Objects.requireNonNullElse(skinHashes, Collections.emptyList()); } + + @Override + public String toString() { + return "GeyserCustomSkullConfiguration{" + + "playerUsernames=" + playerUsernames + + ", playerUUIDs=" + playerUUIDs + + ", playerProfiles=" + playerProfiles + + ", skinHashes=" + skinHashes + + '}'; + } } diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java index 840834690..8494edc2b 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java @@ -65,6 +65,7 @@ public class CustomSkullRegistryPopulator { Path skullConfigPath = bootstrap.getConfigFolder().resolve("custom-skulls.yml"); File skullConfigFile = FileUtils.fileOrCopiedFromResource(skullConfigPath.toFile(), "custom-skulls.yml", Function.identity(), bootstrap); skullConfig = FileUtils.loadConfigNew(skullConfigFile, GeyserCustomSkullConfiguration.class); + System.out.println(skullConfig); } catch (IOException e) { GeyserImpl.getInstance().getLogger().severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e); return; diff --git a/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java b/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java index 16a939304..82c4a75f7 100644 --- a/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java +++ b/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java @@ -27,6 +27,7 @@ package org.geysermc.geyser.skin; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import it.unimi.dsi.fastutil.bytes.ByteArrays; @@ -487,12 +488,12 @@ public class SkinProvider { return CompletableFuture.supplyAsync(() -> { try { JsonObject node = WebUtils.getJson("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid); - JsonObject properties = node.getAsJsonObject("properties"); + JsonArray properties = node.getAsJsonArray("properties"); if (properties == null) { GeyserImpl.getInstance().getLogger().debug("No properties found in Mojang response for " + uuid); return null; } - return node.getAsJsonArray("properties").get(0).getAsJsonObject().get("value").getAsString(); + return properties.get(0).getAsJsonObject().get("value").getAsString(); } catch (Exception e) { GeyserImpl.getInstance().getLogger().debug("Unable to request textures for " + uuid); if (GeyserImpl.getInstance().getConfig().isDebugMode()) { @@ -514,6 +515,7 @@ public class SkinProvider { try { // Offline skin, or no present UUID JsonObject node = WebUtils.getJson("https://api.mojang.com/users/profiles/minecraft/" + username); + System.out.println(node); JsonElement id = node.get("id"); if (id == null) { GeyserImpl.getInstance().getLogger().debug("No UUID found in Mojang response for " + username); diff --git a/core/src/main/java/org/geysermc/geyser/util/AssetUtils.java b/core/src/main/java/org/geysermc/geyser/util/AssetUtils.java index 0c07f4237..81df9919d 100644 --- a/core/src/main/java/org/geysermc/geyser/util/AssetUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/AssetUtils.java @@ -296,6 +296,15 @@ public final class AssetUtils { @SerializedName("url") private String url; + + @Override + public String toString() { + return "VersionDownload{" + + "sha1='" + sha1 + '\'' + + ", size=" + size + + ", url='" + url + '\'' + + '}'; + } } @Getter