mirror of
https://github.com/SKCraft/Launcher.git
synced 2025-01-05 19:09:03 +01:00
Convert avatarImage fields to type byte[]
This commit is contained in:
parent
a7dcd2c7fb
commit
ff12d154c8
@ -115,7 +115,7 @@ public class MicrosoftLoginService implements LoginService {
|
||||
private final McProfileResponse profile;
|
||||
private final Map<String, String> userProperties = Collections.emptyMap();
|
||||
private String refreshToken;
|
||||
private String avatarImage;
|
||||
private byte[] avatarImage;
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
|
@ -58,7 +58,7 @@ public class OfflineSession implements Session {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAvatarImage() {
|
||||
public byte[] getAvatarImage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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<String, String> userProperties = Collections.emptyMap();
|
||||
@JsonBackReference private AuthenticateResponse response;
|
||||
|
||||
|
@ -222,7 +222,7 @@ public class AccountSelectDialog extends JDialog {
|
||||
public Component getListCellRendererComponent(JList<? extends SavedSession> 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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user