From fd788636972d38949511d65a915e0d6cdd3760b5 Mon Sep 17 00:00:00 2001 From: Henry Le Grys Date: Thu, 18 Feb 2021 21:22:58 +0000 Subject: [PATCH] Make skin service return null on error --- .../launcher/auth/MicrosoftLoginService.java | 1 + .../launcher/auth/VisageSkinService.java | 19 -------------- .../launcher/auth/YggdrasilLoginService.java | 1 + .../launcher/auth/skin/VisageSkinService.java | 25 +++++++++++++++++++ 4 files changed, 27 insertions(+), 19 deletions(-) delete mode 100644 launcher/src/main/java/com/skcraft/launcher/auth/VisageSkinService.java create mode 100644 launcher/src/main/java/com/skcraft/launcher/auth/skin/VisageSkinService.java diff --git a/launcher/src/main/java/com/skcraft/launcher/auth/MicrosoftLoginService.java b/launcher/src/main/java/com/skcraft/launcher/auth/MicrosoftLoginService.java index 80d331a..d02d2d3 100644 --- a/launcher/src/main/java/com/skcraft/launcher/auth/MicrosoftLoginService.java +++ b/launcher/src/main/java/com/skcraft/launcher/auth/MicrosoftLoginService.java @@ -11,6 +11,7 @@ import com.skcraft.launcher.auth.microsoft.model.McAuthResponse; import com.skcraft.launcher.auth.microsoft.model.McProfileResponse; import com.skcraft.launcher.auth.microsoft.model.TokenResponse; import com.skcraft.launcher.auth.microsoft.model.XboxAuthorization; +import com.skcraft.launcher.auth.skin.VisageSkinService; import com.skcraft.launcher.util.HttpRequest; import lombok.Data; import lombok.RequiredArgsConstructor; diff --git a/launcher/src/main/java/com/skcraft/launcher/auth/VisageSkinService.java b/launcher/src/main/java/com/skcraft/launcher/auth/VisageSkinService.java deleted file mode 100644 index 12fe5d8..0000000 --- a/launcher/src/main/java/com/skcraft/launcher/auth/VisageSkinService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.skcraft.launcher.auth; - -import com.skcraft.launcher.util.HttpRequest; - -import java.io.IOException; - -import static com.skcraft.launcher.util.HttpRequest.url; - -public class VisageSkinService { - public static byte[] fetchSkinHead(String uuid) throws IOException, InterruptedException { - String skinUrl = String.format("https://visage.surgeplay.com/face/32/%s.png", uuid); - - return HttpRequest.get(url(skinUrl)) - .execute() - .expectResponseCode(200) - .returnContent() - .asBytes(); - } -} diff --git a/launcher/src/main/java/com/skcraft/launcher/auth/YggdrasilLoginService.java b/launcher/src/main/java/com/skcraft/launcher/auth/YggdrasilLoginService.java index 0f5ce87..874d159 100644 --- a/launcher/src/main/java/com/skcraft/launcher/auth/YggdrasilLoginService.java +++ b/launcher/src/main/java/com/skcraft/launcher/auth/YggdrasilLoginService.java @@ -7,6 +7,7 @@ package com.skcraft.launcher.auth; import com.fasterxml.jackson.annotation.*; +import com.skcraft.launcher.auth.skin.VisageSkinService; import com.skcraft.launcher.util.HttpRequest; import lombok.Data; import lombok.RequiredArgsConstructor; diff --git a/launcher/src/main/java/com/skcraft/launcher/auth/skin/VisageSkinService.java b/launcher/src/main/java/com/skcraft/launcher/auth/skin/VisageSkinService.java new file mode 100644 index 0000000..2f59cd3 --- /dev/null +++ b/launcher/src/main/java/com/skcraft/launcher/auth/skin/VisageSkinService.java @@ -0,0 +1,25 @@ +package com.skcraft.launcher.auth.skin; + +import com.skcraft.launcher.util.HttpRequest; + +import javax.annotation.Nullable; +import java.io.IOException; + +import static com.skcraft.launcher.util.HttpRequest.url; + +public class VisageSkinService { + @Nullable + public static byte[] fetchSkinHead(String uuid) throws InterruptedException { + String skinUrl = String.format("https://visage.surgeplay.com/face/32/%s.png", uuid); + + try { + return HttpRequest.get(url(skinUrl)) + .execute() + .expectResponseCode(200) + .returnContent() + .asBytes(); + } catch (IOException e) { + return null; + } + } +}