diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/texture/JsonTextureProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/texture/JsonTextureProvider.java index 44499d89..a47b3709 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/texture/JsonTextureProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/texture/JsonTextureProvider.java @@ -42,24 +42,8 @@ public Texture getSkinTexture(UUID uuid, String username, String client) { public Map getAssets(UUID uuid, String username, String client) { try { var result = HTTPRequest.jsonRequest(null, "GET", new URL(RequestTextureProvider.getTextureURL(url, uuid, username, client))); - Map map = Launcher.gsonManager.gson.fromJson(result, MAP_TYPE); - if (map == null) { - return new HashMap<>(); - } - if (map.get("skin") != null) { // Legacy script - map.put("SKIN", map.get("skin")); - map.remove("skin"); - } - if (map.get("cloak") != null) { - map.put("CAPE", map.get("cloak")); - map.remove("cloak"); - } - Map res = new HashMap<>(); - for(var e : map.entrySet()) { - res.put(e.getKey(), e.getValue().toTexture()); - } - return res; + return JsonTexture.convertMap(map); } catch (IOException e) { logger.error("JsonTextureProvider", e); return new HashMap<>(); @@ -70,5 +54,16 @@ public record JsonTexture(String url, String hash, Map metadata) public Texture toTexture() { return new Texture(url, hash == null ? null : SecurityHelper.fromHex(hash), metadata); } + + public static Map convertMap(Map map) { + if (map == null) { + return new HashMap<>(); + } + Map res = new HashMap<>(); + for(var e : map.entrySet()) { + res.put(e.getKey(), e.getValue().toTexture()); + } + return res; + } } }