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 9688343..80d331a 100644 --- a/launcher/src/main/java/com/skcraft/launcher/auth/MicrosoftLoginService.java +++ b/launcher/src/main/java/com/skcraft/launcher/auth/MicrosoftLoginService.java @@ -115,7 +115,7 @@ public class MicrosoftLoginService implements LoginService { private final McProfileResponse profile; private final Map userProperties = Collections.emptyMap(); private String refreshToken; - private String avatarImage; + private byte[] avatarImage; @Override public String getUuid() { diff --git a/launcher/src/main/java/com/skcraft/launcher/auth/OfflineSession.java b/launcher/src/main/java/com/skcraft/launcher/auth/OfflineSession.java index 1e24b3b..cb2520a 100644 --- a/launcher/src/main/java/com/skcraft/launcher/auth/OfflineSession.java +++ b/launcher/src/main/java/com/skcraft/launcher/auth/OfflineSession.java @@ -58,7 +58,7 @@ public class OfflineSession implements Session { } @Override - public String getAvatarImage() { + public byte[] getAvatarImage() { return null; } diff --git a/launcher/src/main/java/com/skcraft/launcher/auth/SavedSession.java b/launcher/src/main/java/com/skcraft/launcher/auth/SavedSession.java index 33430ff..9e12f1b 100644 --- a/launcher/src/main/java/com/skcraft/launcher/auth/SavedSession.java +++ b/launcher/src/main/java/com/skcraft/launcher/auth/SavedSession.java @@ -1,12 +1,9 @@ package com.skcraft.launcher.auth; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Data; import org.apache.commons.lang.builder.HashCodeBuilder; -import java.util.Base64; - /** * Represents a session saved to disk. */ @@ -18,12 +15,7 @@ public class SavedSession { private String username; private String accessToken; private String refreshToken; - private String avatarImage; - - @JsonIgnore - public byte[] getAvatarBytes() { - return Base64.getDecoder().decode(avatarImage); - } + private byte[] avatarImage; @Override public boolean equals(Object o) { diff --git a/launcher/src/main/java/com/skcraft/launcher/auth/Session.java b/launcher/src/main/java/com/skcraft/launcher/auth/Session.java index 51a2841..6535c14 100644 --- a/launcher/src/main/java/com/skcraft/launcher/auth/Session.java +++ b/launcher/src/main/java/com/skcraft/launcher/auth/Session.java @@ -62,7 +62,7 @@ public interface Session { * * @return User's avatar as a base64 string. */ - String getAvatarImage(); + byte[] getAvatarImage(); /** * Return true if the user is in an online session. diff --git a/launcher/src/main/java/com/skcraft/launcher/auth/VisageSkinService.java b/launcher/src/main/java/com/skcraft/launcher/auth/VisageSkinService.java index a1b9136..12fe5d8 100644 --- a/launcher/src/main/java/com/skcraft/launcher/auth/VisageSkinService.java +++ b/launcher/src/main/java/com/skcraft/launcher/auth/VisageSkinService.java @@ -3,20 +3,17 @@ package com.skcraft.launcher.auth; import com.skcraft.launcher.util.HttpRequest; import java.io.IOException; -import java.util.Base64; import static com.skcraft.launcher.util.HttpRequest.url; public class VisageSkinService { - public static String fetchSkinHead(String uuid) throws IOException, InterruptedException { + public static byte[] fetchSkinHead(String uuid) throws IOException, InterruptedException { String skinUrl = String.format("https://visage.surgeplay.com/face/32/%s.png", uuid); - byte[] skinBytes = HttpRequest.get(url(skinUrl)) + return HttpRequest.get(url(skinUrl)) .execute() .expectResponseCode(200) .returnContent() .asBytes(); - - return Base64.getEncoder().encodeToString(skinBytes); } } 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 8951ebe..0f5ce87 100644 --- a/launcher/src/main/java/com/skcraft/launcher/auth/YggdrasilLoginService.java +++ b/launcher/src/main/java/com/skcraft/launcher/auth/YggdrasilLoginService.java @@ -112,7 +112,7 @@ public class YggdrasilLoginService implements LoginService { @JsonProperty("id") private String uuid; private String name; private boolean legacy; - private String avatarImage; + private byte[] avatarImage; @JsonIgnore private final Map userProperties = Collections.emptyMap(); @JsonBackReference private AuthenticateResponse response; diff --git a/launcher/src/main/java/com/skcraft/launcher/dialog/AccountSelectDialog.java b/launcher/src/main/java/com/skcraft/launcher/dialog/AccountSelectDialog.java index 05bd2b9..7b34a58 100644 --- a/launcher/src/main/java/com/skcraft/launcher/dialog/AccountSelectDialog.java +++ b/launcher/src/main/java/com/skcraft/launcher/dialog/AccountSelectDialog.java @@ -222,7 +222,7 @@ public class AccountSelectDialog extends JDialog { public Component getListCellRendererComponent(JList list, SavedSession value, int index, boolean isSelected, boolean cellHasFocus) { setText(value.getUsername()); if (value.getAvatarImage() != null) { - setIcon(new ImageIcon(value.getAvatarBytes())); + setIcon(new ImageIcon(value.getAvatarImage())); } else { setIcon(SwingHelper.createIcon(Launcher.class, "default_skin.png", 32, 32)); }