From cfa7b4832a9443bfd740a380298f88ee829d1e2b Mon Sep 17 00:00:00 2001 From: huangyuhui Date: Sun, 11 Jun 2017 21:46:54 +0800 Subject: [PATCH] try to avoid not supporting translucent --- .../hmcl/core/asset/MinecraftAssetService.java | 2 ++ .../hmcl/core/auth/OfflineAuthenticator.java | 7 ++++++- .../hmcl/laf/popup/TranslucentPopupFactory.java | 13 +++++++++---- .../hmcl/laf/utils/WindowTranslucencyHelper.java | 4 +++- common.gradle | 2 +- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/asset/MinecraftAssetService.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/asset/MinecraftAssetService.java index a6f125638..55d64b547 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/asset/MinecraftAssetService.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/asset/MinecraftAssetService.java @@ -135,6 +135,8 @@ public class MinecraftAssetService extends IMinecraftAssetService { public File getAssetObject(String assetId, String name) throws IOException { try { AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.read(getIndexFile(assetId), "UTF-8"), AssetsIndex.class); + if (index == null || index.getFileMap() == null || index.getFileMap().get(name) == null) + throw new IOException("Assets file format malformed."); return getAssetObject(assetId, (AssetsObject) index.getFileMap().get(name)); } catch (JsonSyntaxException e) { throw new IOException("Assets file format malformed.", e); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/auth/OfflineAuthenticator.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/auth/OfflineAuthenticator.java index 9cfb550b1..843981f44 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/auth/OfflineAuthenticator.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/auth/OfflineAuthenticator.java @@ -59,7 +59,12 @@ public final class OfflineAuthenticator extends AbstractAuthenticator { public UserProfileProvider login(LoginInfo info) throws AuthenticationException { if (StrUtils.isBlank(info.username)) throw new AuthenticationException(C.i18n("login.no_Player007")); - String uuid = getUUIDFromUserName(info.username); + String uuid; + try { + uuid = getUUIDFromUserName(info.username); + } catch(IllegalArgumentException e) { + throw new AuthenticationException("Could not find md5 digest algorithm, please reinstall Java or even your OS.", e); + } if (uuidMap != null && uuidMap.containsKey(info.username) && uuidMap.get(info.username) instanceof String) uuid = (String) uuidMap.get(info.username); else { diff --git a/HMCLaF/src/main/java/org/jackhuang/hmcl/laf/popup/TranslucentPopupFactory.java b/HMCLaF/src/main/java/org/jackhuang/hmcl/laf/popup/TranslucentPopupFactory.java index 5808fc5da..0314b3c34 100644 --- a/HMCLaF/src/main/java/org/jackhuang/hmcl/laf/popup/TranslucentPopupFactory.java +++ b/HMCLaF/src/main/java/org/jackhuang/hmcl/laf/popup/TranslucentPopupFactory.java @@ -15,6 +15,7 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Frame; import java.awt.Graphics; +import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Window; @@ -182,10 +183,14 @@ public class TranslucentPopupFactory extends PopupFactory { boolean isComboBoxPopup = (contents instanceof BasicComboPopup); if (WindowTranslucencyHelper.isTranslucencySupported()) { - //每像素透明 - WindowTranslucencyHelper.setWindowOpaque(w, false); - //内容组件半透明 - w.setOpacity(isTooltip ? 1.0f : isComboBoxPopup ? 0.95f : 0.95f);//0.85f : 0.95f);//0.8f : 0.95f); + try { + //每像素透明 + WindowTranslucencyHelper.setWindowOpaque(w, false); + //内容组件半透明 + w.setOpacity(isTooltip ? 1.0f : isComboBoxPopup ? 0.95f : 0.95f);//0.85f : 0.95f);//0.8f : 0.95f); + } catch(Exception e) { + // ignore + } } // component.getContentPane().add(contents, BorderLayout.CENTER); diff --git a/HMCLaF/src/main/java/org/jackhuang/hmcl/laf/utils/WindowTranslucencyHelper.java b/HMCLaF/src/main/java/org/jackhuang/hmcl/laf/utils/WindowTranslucencyHelper.java index a40fa82e5..311aa663b 100644 --- a/HMCLaF/src/main/java/org/jackhuang/hmcl/laf/utils/WindowTranslucencyHelper.java +++ b/HMCLaF/src/main/java/org/jackhuang/hmcl/laf/utils/WindowTranslucencyHelper.java @@ -27,7 +27,9 @@ public class WindowTranslucencyHelper { * @return true, if is translucency supported */ public static boolean isTranslucencySupported() { - return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT); + GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + return device.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT) && + device.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT); } /** diff --git a/common.gradle b/common.gradle index 4259068b5..f35b30b9c 100755 --- a/common.gradle +++ b/common.gradle @@ -27,7 +27,7 @@ apply plugin: 'maven' dependencies { compile 'com.google.code.gson:gson:2.2.4' // Apache License 2.0 - compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.2" + //compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.2" } task sourcesJar(type: Jar, dependsOn: classes, description: 'Creates a jar from the source files.') {