This commit is contained in:
huanghongxun
2015-08-16 17:29:09 +08:00
parent a77275cfc0
commit 9ae9b5b912
16 changed files with 92 additions and 75 deletions

View File

@@ -117,7 +117,13 @@ public class TaskList extends Thread {
for (DoingDoneListener<Task> d : t.getTaskListeners())
d.onDoing(t);
if (t.executeTask()) {
boolean returns = false;
try {
returns = t.executeTask();
} catch(Throwable e) {
t.setFailReason(e);
}
if (returns) {
HMCLog.log((t.isAborted() ? "Task aborted: " : "Task finished: ") + t.getInfo());
for (DoingDoneListener<Task> d : taskListener)
d.onDone(t);

View File

@@ -51,7 +51,7 @@ public class TaskWindow extends javax.swing.JDialog
initComponents();
setLocationRelativeTo(null);
if (lstDownload.getColumnModel().getColumnCount() > 1) {
int i = 35;
lstDownload.getColumnModel().getColumn(1).setMinWidth(i);
@@ -68,6 +68,8 @@ public class TaskWindow extends javax.swing.JDialog
}
public void clean() {
if (isVisible())
throw new RuntimeException("This error should not appear, please contact the author.");
taskList = null;
taskList = new TaskList();
taskList.addTaskListener(this);
@@ -170,7 +172,8 @@ public class TaskWindow extends javax.swing.JDialog
}
if (!suc) {
SwingUtilities.invokeLater(taskList::abort);
if (taskList != null)
SwingUtilities.invokeLater(taskList::abort);
HMCLog.log("Tasks have been canceled by user.");
}
}//GEN-LAST:event_formWindowClosed

View File

@@ -22,13 +22,7 @@ import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.X509TrustManager;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.tasks.Task;
@@ -43,37 +37,6 @@ import org.jackhuang.hellominecraft.utils.system.IOUtils;
// This class downloads a file from a URL.
public class FileDownloadTask extends Task implements PreviousResult<File>, PreviousResultRegistrar<String> {
private static final X509TrustManager xtm = new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
private static final HostnameVerifier hnv = (hostname, session) -> true;
static {
SSLContext sslContext = null;
try {
sslContext = SSLContext.getInstance("TLS");
X509TrustManager[] xtmArray = new X509TrustManager[]{xtm};
sslContext.init(null, xtmArray, new java.security.SecureRandom());
} catch (GeneralSecurityException gse) {
}
if (sslContext != null)
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(hnv);
}
// Max size of download buffer.
private static final int MAX_BUFFER_SIZE = 2048;

View File

@@ -19,7 +19,6 @@ package org.jackhuang.hellominecraft.utils;
import java.awt.FontMetrics;
import java.net.URI;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollBar;
@@ -153,11 +152,12 @@ public class SwingUtils {
}
public static String getParsedJPanelText(JLabel jLabel1, String longString) {
if(StrUtils.isBlank(longString)) return longString;
if (StrUtils.isBlank(longString)) return longString;
StringBuilder builder = new StringBuilder();
char[] chars = longString.toCharArray();
FontMetrics fontMetrics = jLabel1.getFontMetrics(jLabel1.getFont());
for (int beginIndex = 0, limit = 1;; limit++) {
if (beginIndex + limit >= chars.length) break;
if (fontMetrics.charsWidth(chars, beginIndex, limit) < jLabel1.getWidth()) {
if (beginIndex + limit < chars.length)
continue;

View File

@@ -4,7 +4,7 @@
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="logwindow.title" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="logwindow.title" replaceFormat="C.I18N.getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<SyntheticProperties>
@@ -99,7 +99,7 @@
<Component class="javax.swing.JButton" name="btnClear">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="ui.button.clear" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="ui.button.clear" replaceFormat="C.I18N.getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
@@ -109,7 +109,7 @@
<Component class="javax.swing.JButton" name="btnClose">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="ui.button.close" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="ui.button.close" replaceFormat="C.I18N.getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
@@ -119,7 +119,7 @@
<Component class="javax.swing.JButton" name="btnCopy">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="ui.button.copy" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="ui.button.copy" replaceFormat="C.I18N.getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
@@ -144,7 +144,7 @@
<Component class="javax.swing.JButton" name="btnTieBa">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="logwindow.tieba" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="logwindow.tieba" replaceFormat="C.I18N.getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
@@ -162,7 +162,7 @@
<Component class="javax.swing.JButton" name="btnTerminateGame">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="logwindow.terminate_game" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="logwindow.terminate_game" replaceFormat="C.I18N.getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>

View File

@@ -76,8 +76,7 @@ public class LogWindow extends javax.swing.JFrame {
btnGitHub = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jackhuang/hellominecraft/launcher/I18N"); // NOI18N
setTitle(bundle.getString("logwindow.title")); // NOI18N
setTitle(C.I18N.getString("logwindow.title")); // NOI18N
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosed(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
@@ -89,21 +88,21 @@ public class LogWindow extends javax.swing.JFrame {
txtLog.setRows(5);
jScrollPane1.setViewportView(txtLog);
btnClear.setText(bundle.getString("ui.button.clear")); // NOI18N
btnClear.setText(C.I18N.getString("ui.button.clear")); // NOI18N
btnClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnClearActionPerformed(evt);
}
});
btnClose.setText(bundle.getString("ui.button.close")); // NOI18N
btnClose.setText(C.I18N.getString("ui.button.close")); // NOI18N
btnClose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCloseActionPerformed(evt);
}
});
btnCopy.setText(bundle.getString("ui.button.copy")); // NOI18N
btnCopy.setText(C.I18N.getString("ui.button.copy")); // NOI18N
btnCopy.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCopyActionPerformed(evt);
@@ -119,7 +118,7 @@ public class LogWindow extends javax.swing.JFrame {
}
});
btnTieBa.setText(bundle.getString("logwindow.tieba")); // NOI18N
btnTieBa.setText(C.I18N.getString("logwindow.tieba")); // NOI18N
btnTieBa.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTieBaActionPerformed(evt);
@@ -133,7 +132,7 @@ public class LogWindow extends javax.swing.JFrame {
}
});
btnTerminateGame.setText(bundle.getString("logwindow.terminate_game")); // NOI18N
btnTerminateGame.setText(C.I18N.getString("logwindow.terminate_game")); // NOI18N
btnTerminateGame.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTerminateGameActionPerformed(evt);

View File

@@ -116,6 +116,7 @@ crash.advice.no=\u65e0\u5efa\u8bae\u3002
crash.user_fault=\u60a8\u7684\u7cfb\u7edf\u6216Java\u73af\u5883\u53ef\u80fd\u5b89\u88c5\u4e0d\u5f53\u5bfc\u81f4\u672c\u8f6f\u4ef6\u5d29\u6e83\uff0c\u8bf7\u68c0\u67e5\u60a8\u7684Java\u73af\u5883\u6216\u60a8\u7684\u7535\u8111\uff01\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u65b0\u5b89\u88c5Java\u3002
crash.headless=\u5982\u679c\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u662fLinux\uff0c\u8bf7\u6ce8\u610f\u4e0d\u8981\u4f7f\u7528OpenJDK\uff0c\u52a1\u5fc5\u4f7f\u7528Oracle JDK\uff0c\u6216\u5c1d\u8bd5\u6dfb\u52a0-Djava.awt.headless=false\u53c2\u6570\uff0c\u6216\u68c0\u67e5\u60a8\u7684Xserver\u662f\u5426\u6b63\u5e38
crash.NoClassDefFound=\u8bf7\u786e\u8ba4HMCL\u672c\u4f53\u662f\u5426\u5b8c\u6574
crash.error=\u60a8\u7684Minecraft\u5d29\u6e83\u4e86\u3002
crash.main_class_not_found=\u627e\u4e0d\u5230\u4e3b\u7c7b\uff0c\u53ef\u80fd\u662f\u60a8\u7684JSON\u6587\u4ef6\u586b\u5199\u9519\u8bef\u3002\u65e0\u6cd5\u542f\u52a8\u6e38\u620f\u3002\u53ef\u4ee5\u901a\u8fc7\u4e0b\u8f7d\u6574\u5408\u5305\u89e3\u51b3\u95ee\u9898\u3002

View File

@@ -116,6 +116,7 @@ crash.advice.no=No advice.
crash.user_fault=Your OS or Java environment may not be properly installed resulting in crashing of this software, please check your Java Environment or your computer!
crash.headless=If your OS is Linux, please use Oracle JDK instead of OpenJDK, or add "-Djava.awt.headless=false" JVM argument, or check if your Xserver works normally.
crash.NoClassDefFound=Please check "HMCL" software is complete.
crash.error=Minecraft has crashed.
crash.main_class_not_found=Main Class is not found, may be your mc has been broken.

View File

@@ -116,6 +116,7 @@ crash.advice.no=\u65e0\u5efa\u8bae\u3002
crash.user_fault=\u60a8\u7684\u7cfb\u7edf\u6216Java\u73af\u5883\u53ef\u80fd\u5b89\u88c5\u4e0d\u5f53\u5bfc\u81f4\u672c\u8f6f\u4ef6\u5d29\u6e83\uff0c\u8bf7\u68c0\u67e5\u60a8\u7684Java\u73af\u5883\u6216\u60a8\u7684\u7535\u8111\uff01\u53ef\u4ee5\u5c1d\u8bd5\u91cd\u65b0\u5b89\u88c5Java\u3002
crash.headless=\u5982\u679c\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u662fLinux\uff0c\u8bf7\u6ce8\u610f\u4e0d\u8981\u4f7f\u7528OpenJDK\uff0c\u52a1\u5fc5\u4f7f\u7528Oracle JDK\uff0c\u6216\u5c1d\u8bd5\u6dfb\u52a0-Djava.awt.headless=false\u53c2\u6570\uff0c\u6216\u68c0\u67e5\u60a8\u7684Xserver\u662f\u5426\u6b63\u5e38
crash.NoClassDefFound=\u8bf7\u786e\u8ba4HMCL\u672c\u4f53\u662f\u5426\u5b8c\u6574
crash.error=\u60a8\u7684Minecraft\u5d29\u6e83\u4e86\u3002
crash.main_class_not_found=\u627e\u4e0d\u5230\u4e3b\u7c7b\uff0c\u53ef\u80fd\u662f\u60a8\u7684JSON\u6587\u4ef6\u586b\u5199\u9519\u8bef\u3002\u65e0\u6cd5\u542f\u52a8\u6e38\u620f\u3002\u53ef\u4ee5\u901a\u8fc7\u4e0b\u8f7d\u6574\u5408\u5305\u89e3\u51b3\u95ee\u9898\u3002

View File

@@ -116,6 +116,7 @@ crash.advice.no=\u7121\u5efa\u8b70\u3002
crash.user_fault=\u60a8\u7684\u7cfb\u7d71\u6216Java\u74b0\u5883\u53ef\u80fd\u5b89\u88dd\u4e0d\u7576\u5c0e\u81f4\u672c\u8edf\u4ef6\u5d29\u6f70\uff0c\u8acb\u6aa2\u67e5\u60a8\u7684Java\u74b0\u5883\u6216\u60a8\u7684\u96fb\u8166\uff01\u53ef\u4ee5\u5617\u8a66\u91cd\u65b0\u5b89\u88ddJava\u3002
crash.headless=\u5982\u679c\u60a8\u7684\u64cd\u4f5c\u7cfb\u7d71\u662fLinux\uff0c\u8acb\u6ce8\u610f\u4e0d\u8981\u4f7f\u7528OpenJDK\uff0c\u52d9\u5fc5\u4f7f\u7528Oracle JDK\uff0c\u6216\u5617\u8a66\u6dfb\u52a0-Djava.awt.headless=false\u53c3\u6578\uff0c\u6216\u6aa2\u67e5\u60a8\u7684Xserver\u662f\u5426\u6b63\u5e38
crash.NoClassDefFound=\u8acb\u78ba\u8a8dHMCL\u672c\u9ad4\u662f\u5426\u5b8c\u6574
crash.error=\u60a8\u7684Minecraft\u5d29\u6f70\u4e86\u3002
crash.main_class_not_found=\u627e\u4e0d\u5230\u4e3b\u985e\uff0c\u53ef\u80fd\u662f\u60a8\u7684JSON\u6587\u4ef6\u586b\u5beb\u932f\u8aa4\u3002\u7121\u6cd5\u555f\u52d5\u904a\u6232\u3002\u53ef\u4ee5\u901a\u904e\u4e0b\u8f09\u6574\u5408\u5305\u89e3\u6c7a\u554f\u984c\u3002