diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/game/AccountHelper.java b/HMCL/src/main/java/org/jackhuang/hmcl/game/AccountHelper.java index ae4db1045..fdca46992 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/game/AccountHelper.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/game/AccountHelper.java @@ -83,9 +83,11 @@ public final class AccountHelper { } public static Image getSkin(YggdrasilAccount account, double scaleRatio) { - if (account.getCharacter() == null) - return getDefaultSkin(account, scaleRatio); - File file = getSkinFile(account.getUUID()); + UUID uuid = account.getUUID(); + if (uuid == null) + return getSteveSkin(scaleRatio); + + File file = getSkinFile(uuid); if (file.exists()) { Image original = new Image("file:" + file.getAbsolutePath()); return new Image("file:" + file.getAbsolutePath(), @@ -93,14 +95,14 @@ public final class AccountHelper { original.getHeight() * scaleRatio, false, false); } - return getDefaultSkin(account, scaleRatio); + return getDefaultSkin(uuid, scaleRatio); } public static Image getSkinImmediately(YggdrasilAccount account, GameProfile profile, double scaleRatio, Proxy proxy) throws Exception { File file = getSkinFile(profile.getId()); downloadSkin(account, profile, true, proxy); if (!file.exists()) - return getDefaultSkin(account, scaleRatio); + return getDefaultSkin(profile.getId(), scaleRatio); String url = "file:" + file.getAbsolutePath(); return scale(url, scaleRatio); @@ -187,11 +189,8 @@ public final class AccountHelper { return scale("/assets/img/alex.png", 4); } - public static Image getDefaultSkin(Account account, double scaleRatio) { - if (account == null) - return getSteveSkin(scaleRatio); - - int type = account.getUUID().hashCode() & 1; + public static Image getDefaultSkin(UUID uuid, double scaleRatio) { + int type = uuid.hashCode() & 1; if (type == 1) return getAlexSkin(scaleRatio); else diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AddAccountPane.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/AddAccountPane.java index 782606e0f..acfe68ba2 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/AddAccountPane.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/AddAccountPane.java @@ -208,6 +208,7 @@ public class AddAccountPane extends StackPane { try { image = AccountHelper.getSkinImmediately(yggdrasilAccount, profile, 4, Settings.INSTANCE.getProxy()); } catch (Exception e) { + Logging.LOG.log(Level.WARNING, "Failed to get skin for " + profile.getName(), e); image = FXUtils.DEFAULT_ICON; } ImageView portraitView = new ImageView(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java index 51f38a3b6..3fda2d12c 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java @@ -167,7 +167,7 @@ public final class LeftPaneController { Image image = AccountHelper.getSkin((YggdrasilAccount) account, 4); item.setImage(image, AccountHelper.getViewport(4)); } else - item.setImage(AccountHelper.getDefaultSkin(account, 4), AccountHelper.getViewport(4)); + item.setImage(AccountHelper.getDefaultSkin(account.getUUID(), 4), AccountHelper.getViewport(4)); if (account instanceof AuthlibInjectorAccount) Accounts.getAuthlibInjectorServerNameAsync((AuthlibInjectorAccount) account) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccount.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccount.java index f6dcbb7ca..200449925 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccount.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccount.java @@ -145,7 +145,7 @@ public class YggdrasilAccount extends Account { } public UUID getUUID() { - if (session == null) + if (session == null || session.getSelectedProfile() == null) return null; else return session.getSelectedProfile().getId();