From ceb100058200b6a6ba1ac8eebb278b8b66e4f193 Mon Sep 17 00:00:00 2001 From: OptimisticDeving <173472493+OptimisticDeving@users.noreply.github.com> Date: Wed, 8 Oct 2025 11:24:59 +0000 Subject: [PATCH] Respect overridden sessionserver & api urls --- .../modules/player/skin/SkinManager.java | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/main/java/pw/kaboom/extras/modules/player/skin/SkinManager.java b/src/main/java/pw/kaboom/extras/modules/player/skin/SkinManager.java index 299b34de..02fec19e 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/skin/SkinManager.java +++ b/src/main/java/pw/kaboom/extras/modules/player/skin/SkinManager.java @@ -37,6 +37,24 @@ public final class SkinManager { private static final Gson GSON = new Gson(); private static final ExecutorService executorService = Executors .newCachedThreadPool(); + private static final URI SESSION_HOST = + URI.create( + System.getProperty( + "minecraft.api.session.host", + "https://sessionserver.mojang.com" + ) + ); + private static final URI PROFILE_ENDPOINT = URI.create( + // 1.21.9+ + System.getProperty( + "minecraft.api.profiles.host", + System.getProperty( + // 1.21.9- + "minecraft.api.session.host", + "https://api.mojang.com" + ) + ) + ); public static void resetSkin(final Player player, final boolean shouldSendMessage) { executorService.submit(() -> { @@ -128,8 +146,10 @@ public static CompletableFuture getSkinData(final String playerName) { public static CompletableFuture getSkinData(final UUID uuid) { return CompletableFuture.supplyAsync(() -> { final SkinResponse response = sendRequestForJSON( - "https://sessionserver.mojang.com/session/minecraft/profile/" - + uuid + "?unsigned=false", SkinResponse.class); + SESSION_HOST, + "/session/minecraft/profile/" + uuid + "?unsigned=false", + SkinResponse.class + ); final List properties = response.properties(); @@ -145,10 +165,10 @@ public static CompletableFuture getSkinData(final UUID uuid) { }, executorService); } - private static T sendRequestForJSON(String url, Class clazz) { + private static T sendRequestForJSON(URI uri, String endpoint, Class clazz) { final HttpRequest request = HttpRequest.newBuilder() .GET() - .uri(URI.create(url)) + .uri(uri.resolve(endpoint)) .build(); final HttpResponse response; @@ -164,9 +184,11 @@ private static T sendRequestForJSON(String url, Class clazz) { private static CompletableFuture getUUID(final String playerName) { return CompletableFuture.supplyAsync(() -> { - final ProfileResponse parsedResponse = sendRequestForJSON - ("https://api.mojang.com/users/profiles/minecraft/" + playerName, - ProfileResponse.class); + final ProfileResponse parsedResponse = sendRequestForJSON( + PROFILE_ENDPOINT, + "/users/profiles/minecraft/" + playerName, + ProfileResponse.class + ); final String dashedUuid = parsedResponse .id()