Fixed Issue #1 & Added proxy support

This commit is contained in:
huanghongxun
2015-06-24 13:45:00 +08:00
parent 7bfe7c3432
commit e5621d1a58
30 changed files with 623 additions and 578 deletions

View File

@@ -34,6 +34,7 @@ public final class C {
public static final String URL_PUBLISH = "http://www.mcbbs.net/thread-142335-1-1.html";
public static final String URL_TIEBA = "http://tieba.baidu.com/f?kw=hellominecraftlauncher";
public static final String URL_GITHUB = "https://github.com/huanghongxun/HMCL/issues";
public static final String URL_MINECRAFTFORUM = "http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-tools/1265720-hello-minecraft-launcher-1-9-3-mc-1-7-4-auto";
public static final String FILE_MINECRAFT_VERSIONS = "versions";

View File

@@ -41,8 +41,9 @@ public class Compressor {
/**
* 功能:把 sourceDir 目录下的所有文件进行 zip 格式的压缩,保存为指定 zip 文件
*
* @param sourceDir
* @param zipFile
* @param sourceDir 源文件夹
* @param zipFile 压缩生成的zip文件路径。
* @throws java.io.IOException 压缩失败或无法读取
*/
public static void zip(File sourceDir, File zipFile) throws IOException {
FileOutputStream os;
@@ -65,7 +66,7 @@ public class Compressor {
*
* @param source zip文件路径
* @param basePath 待压缩文件根目录
* @param zos
* @param zos zip文件的os
*/
private static void zipFile(File source, String basePath,
ZipOutputStream zos) throws IOException {
@@ -115,6 +116,7 @@ public class Compressor {
* @param zipFileName zip文件路径
* @param extPlace 待压缩文件根目录
* @param without 带前缀的不解压
* @throws java.io.IOException 解压失败或无法写入
*/
public static void unzip(File zipFileName, File extPlace, String[] without) throws IOException {
extPlace.mkdirs();
@@ -164,6 +166,7 @@ public class Compressor {
*
* @param destFile zip1
* @param srcFile zip2
* @throws java.io.IOException 无法写入或读取
*/
public static void merge(File destFile, File srcFile) throws IOException {
try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(destFile))) {

View File

@@ -42,12 +42,16 @@ public class Stream<T> {
protected Stream() {
}
protected static <T> Stream<T> of(List<T> a) {
protected static <T> Stream<T> noneCopyOf(List<T> a) {
Stream<T> b = new Stream<>();
b.internal = a;
return b;
}
protected static <T> Stream<T> of(Collection<T> a) {
return new Stream<>(a);
}
public Stream<T> forEach(Consumer<? super T> p) {
for (T t : internal) p.accept(t);
return this;
@@ -88,15 +92,25 @@ public class Stream<T> {
}
public boolean anyMatch(Predicate<? super T> p) {
return map(t -> p.apply(t)).reduce(false, (accumulator, _item) -> accumulator | _item);
return map(t -> p.apply(t)).<Boolean>reduce(false, (a, b) -> a | b);
}
public boolean allMatch(Predicate<? super T> p) {
return map(t -> p.apply(t)).reduce(true, (accumulator, _item) -> accumulator & _item);
return map(t -> p.apply(t)).<Boolean>reduce(true, (a, b) -> a & b);
}
public T findFirst() {
return internal.isEmpty() ? null : internal.get(0);
}
public Stream<T> skip(int c) {
internal = internal.subList(c+1, internal.size());
return this;
}
public Stream<T> limit(int c) {
internal = internal.subList(0, c);
return this;
}
}

View File

@@ -37,6 +37,8 @@
<Component id="btnMCBBS" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnMCF" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnGitHub" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="btnTerminateGame" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@@ -46,7 +48,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="btnClose" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lblCrash" alignment="0" pref="639" max="32767" attributes="0"/>
<Component id="lblCrash" alignment="0" pref="674" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -68,6 +70,7 @@
<Component id="btnTieBa" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnMCF" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnTerminateGame" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnGitHub" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -164,5 +167,13 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnTerminateGameActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnGitHub">
<Properties>
<Property name="text" type="java.lang.String" value="GitHub"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnGitHubActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -73,6 +73,7 @@ public class LogWindow extends javax.swing.JFrame {
btnTieBa = new javax.swing.JButton();
btnMCF = new javax.swing.JButton();
btnTerminateGame = new javax.swing.JButton();
btnGitHub = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Log");
@@ -139,6 +140,13 @@ public class LogWindow extends javax.swing.JFrame {
}
});
btnGitHub.setText("GitHub");
btnGitHub.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnGitHubActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
@@ -153,6 +161,8 @@ public class LogWindow extends javax.swing.JFrame {
.addComponent(btnMCBBS)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnMCF)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnGitHub)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnTerminateGame)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -161,7 +171,7 @@ public class LogWindow extends javax.swing.JFrame {
.addComponent(btnClear)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnClose))
.addComponent(lblCrash, javax.swing.GroupLayout.DEFAULT_SIZE, 639, Short.MAX_VALUE))
.addComponent(lblCrash, javax.swing.GroupLayout.DEFAULT_SIZE, 674, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
@@ -179,7 +189,8 @@ public class LogWindow extends javax.swing.JFrame {
.addComponent(btnMCBBS)
.addComponent(btnTieBa)
.addComponent(btnMCF)
.addComponent(btnTerminateGame))
.addComponent(btnTerminateGame)
.addComponent(btnGitHub))
.addContainerGap())
);
@@ -219,6 +230,10 @@ public class LogWindow extends javax.swing.JFrame {
terminateGameListener.onDone();
}//GEN-LAST:event_btnTerminateGameActionPerformed
private void btnGitHubActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGitHubActionPerformed
Utils.openLink(C.URL_GITHUB);
}//GEN-LAST:event_btnGitHubActionPerformed
public void log(String status) {
String text = txtLog.getText();
text += status + System.getProperty("line.separator");
@@ -286,6 +301,7 @@ public class LogWindow extends javax.swing.JFrame {
private javax.swing.JButton btnClear;
private javax.swing.JButton btnClose;
private javax.swing.JButton btnCopy;
private javax.swing.JButton btnGitHub;
private javax.swing.JButton btnMCBBS;
private javax.swing.JButton btnMCF;
private javax.swing.JButton btnTerminateGame;

View File

@@ -73,6 +73,11 @@ login.type=\u767b\u5f55
login.username=\u540d\u5b57
login.account=\u90ae\u7bb1
proxy.username=\u8d26\u6237
proxy.password=\u5bc6\u7801
proxy.host=\u4e3b\u673a
proxy.port=\u7aef\u53e3
login.failed.connect_authentication_server=\u65e0\u6cd5\u8fde\u63a5\u8ba4\u8bc1\u670d\u52a1\u5668,\u53ef\u80fd\u662f\u7f51\u7edc\u95ee\u9898
login.profile.not_logged_in=\u65e0\u6cd5\u4fee\u6539\u6e38\u620f\u8d44\u6599\u540c\u65f6\u672a\u767b\u5f55
@@ -144,7 +149,7 @@ ui.message.making=\u751f\u6210\u4e2d
ui.message.sure_remove=\u771f\u7684\u8981\u5220\u9664\u914d\u7f6e%s\u5417\uff1f
ui.label.settings=\u9009\u9879
ui.label.crashing=<html>Hello Minecraft! Launcher\u9047\u5230\u4e86\u65e0\u6cd5\u5904\u7406\u7684\u9519\u8bef\uff0c\u8bf7\u590d\u5236\u4e0b\u5217\u5185\u5bb9\u5e76\u901a\u8fc7mcbbs\u3001\u8d34\u5427\u6216Minecraft Forum\u53cd\u9988bug\u3002</html>
ui.label.crashing=<html>Hello Minecraft! Launcher\u9047\u5230\u4e86\u65e0\u6cd5\u5904\u7406\u7684\u9519\u8bef\uff0c\u8bf7\u590d\u5236\u4e0b\u5217\u5185\u5bb9\u5e76\u901a\u8fc7mcbbs\u3001\u8d34\u5427\u3001Github\u6216Minecraft Forum\u53cd\u9988bug\u3002</html>
ui.label.crashing_out_dated=<html>Hello Minecraft! Launcher\u9047\u5230\u4e86\u65e0\u6cd5\u5904\u7406\u7684\u9519\u8bef\uff0c\u5df2\u68c0\u6d4b\u5230\u60a8\u7684\u542f\u52a8\u5668\u4e0d\u662f\u6700\u65b0\u7248\u672c\uff0c\u8bf7\u66f4\u65b0\u540e\u518d\u8bd5\uff01</html>
ui.label.failed_set=\u8bbe\u7f6e\u5931\u8d25\uff1a
@@ -221,6 +226,7 @@ launcher.background_tooltip=<html>\n<body>\n\u542f\u52a8\u5668\u9ed8\u8ba4\u4f7f
launcher.update_launcher=\u68c0\u67e5\u66f4\u65b0
launcher.enable_shadow=\u542f\u7528\u7a97\u53e3\u9634\u5f71(\u91cd\u542f\u542f\u52a8\u5668\u751f\u6548,\u53ef\u52a0\u5feb\u6e32\u67d3\u901f\u5ea6)
launcher.theme=\u4e3b\u9898
launcher.proxy=\u4ee3\u7406
launcher.title.game=\u6e38\u620f\u8bbe\u7f6e
launcher.title.main=\u4e3b\u9875