From bbe584bd910d62422c88493c3b8309e8c37fd171 Mon Sep 17 00:00:00 2001 From: yushijinhun Date: Sat, 2 Jun 2018 19:21:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=9C=AA=E8=AE=BE=E7=BD=AE=E7=9A=AE=E8=82=A4=E7=9A=84?= =?UTF-8?q?Yggdrasil=E8=B4=A6=E6=88=B7=E7=9A=84=E7=9A=AE=E8=82=A4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jackhuang/hmcl/game/AccountHelper.java | 19 +++++++++---------- .../org/jackhuang/hmcl/ui/AddAccountPane.java | 1 + .../jackhuang/hmcl/ui/LeftPaneController.java | 2 +- .../hmcl/auth/yggdrasil/YggdrasilAccount.java | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) 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();