1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2024-11-23 12:05:44 +01:00

Make skin service return null on error

This commit is contained in:
Henry Le Grys 2021-02-18 21:22:58 +00:00
parent 4177c15675
commit fd78863697
4 changed files with 27 additions and 19 deletions

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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;
}
}
}