diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/HttpRequester.java b/LaunchServer/src/main/java/pro/gravit/launchserver/HttpRequester.java index ad57e971..9bac27ff 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/HttpRequester.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/HttpRequester.java @@ -21,6 +21,10 @@ public SimpleErrorHandler makeEH(Class clazz) { return new SimpleErrorHandler<>(clazz); } + public SimpleErrorHandler makeEH(Type clazz) { + return new SimpleErrorHandler<>(clazz); + } + public HttpRequest get(String url, String token) { try { var requestBuilder = HttpRequest.newBuilder() @@ -59,6 +63,10 @@ public HttpHelper.HttpOptional send(HttpRequest request, Cla return HttpHelper.send(httpClient, request, makeEH(clazz)); } + public HttpHelper.HttpOptional send(HttpRequest request, Type type) throws IOException { + return HttpHelper.send(httpClient, request, makeEH(type)); + } + public static class SimpleErrorHandler implements HttpHelper.HttpJsonErrorHandler { private final Type type; 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 a47b3709..ed109c90 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 @@ -6,6 +6,7 @@ import pro.gravit.launcher.HTTPRequest; import pro.gravit.launcher.Launcher; import pro.gravit.launcher.profiles.Texture; +import pro.gravit.launchserver.HttpRequester; import pro.gravit.utils.helper.SecurityHelper; import java.io.IOException; @@ -19,7 +20,9 @@ public class JsonTextureProvider extends TextureProvider { private static final Type MAP_TYPE = new TypeToken>() { }.getType(); private transient final Logger logger = LogManager.getLogger(); + private transient final HttpRequester requester = new HttpRequester(); public String url; + public String bearerToken; @Override public void close() { @@ -41,8 +44,7 @@ public Texture getSkinTexture(UUID uuid, String username, String client) { @Override 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); + Map map = requester.>send(requester.get(RequestTextureProvider.getTextureURL(url, uuid, username, client), bearerToken), MAP_TYPE).getOrThrow(); return JsonTexture.convertMap(map); } catch (IOException e) { logger.error("JsonTextureProvider", e);