Thanks to gonglinyuan

This commit is contained in:
huangyuhui
2016-02-18 14:24:00 +08:00
parent afecb87c6d
commit 61a179ba67
24 changed files with 177 additions and 70 deletions

View File

@@ -17,7 +17,7 @@
*/
package org.jackhuang.hellominecraft.util;
import java.util.HashSet;
import java.util.ArrayList;
import org.jackhuang.hellominecraft.util.func.Consumer;
/**
@@ -27,9 +27,7 @@ import org.jackhuang.hellominecraft.util.func.Consumer;
*/
public class EventHandler<T> {
HashSet<Event<T>> handlers = new HashSet<>();
HashSet<Consumer<T>> consumers = new HashSet<>();
HashSet<Runnable> runnables = new HashSet<>();
ArrayList<Object> events = new ArrayList<>();
Object sender;
public EventHandler(Object sender) {
@@ -37,38 +35,42 @@ public class EventHandler<T> {
}
public void register(Event<T> t) {
handlers.add(t);
if (!events.contains(t))
events.add(t);
}
public void register(Consumer<T> t) {
consumers.add(t);
if (!events.contains(t))
events.add(t);
}
public void register(Runnable t) {
runnables.add(t);
if (!events.contains(t))
events.add(t);
}
public void unregister(Event<T> t) {
handlers.remove(t);
events.remove(t);
}
public void unregister(Consumer<T> t) {
consumers.remove(t);
events.remove(t);
}
public void unregister(Runnable t) {
runnables.remove(t);
events.remove(t);
}
public boolean execute(T x) {
boolean flag = true;
for (Event<T> t : handlers)
if (!t.call(sender, x))
flag = false;
for (Consumer<T> t : consumers)
t.accept(x);
for (Runnable t : runnables)
t.run();
for (Object t : events)
if (t instanceof Event) {
if (!((Event) t).call(sender, x))
flag = false;
} else if (t instanceof Consumer)
((Consumer) t).accept(x);
else if (t instanceof Runnable)
((Runnable) t).run();
return flag;
}

View File

@@ -0,0 +1,29 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.util.func;
import java.io.IOException;
/**
*
* @author huangyuhui
*/
public interface CallbackIO<T> {
void call(T t) throws IOException;
}

View File

@@ -28,7 +28,7 @@ import org.jackhuang.hellominecraft.util.StrUtils;
*
* @author huangyuhui
*/
public final class JdkVersion {
public final class JdkVersion implements Cloneable {
private String ver;
@@ -69,6 +69,15 @@ public final class JdkVersion {
return location == null ? 0 : new File(location).hashCode();
}
@Override
protected Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException ex) {
throw new Error(ex);
}
}
public JdkVersion(String location) {
File f = new File(location);
if (f.exists() && f.isFile())
@@ -103,13 +112,13 @@ public final class JdkVersion {
*/
public static final int JAVA_19 = 6;
private static final String javaVersion;
private static final int majorJavaVersion;
private static final String JAVA_VER;
private static final int MAJOR_JAVA_VER;
static {
javaVersion = System.getProperty("java.version");
JAVA_VER = System.getProperty("java.version");
// version String should look like "1.4.2_10"
majorJavaVersion = parseVersion(javaVersion);
MAJOR_JAVA_VER = parseVersion(JAVA_VER);
}
private static int parseVersion(String javaVersion) {
@@ -136,7 +145,7 @@ public final class JdkVersion {
* @see System#getProperty(String)
*/
public static String getJavaVersion() {
return javaVersion;
return JAVA_VER;
}
/**
@@ -155,7 +164,7 @@ public final class JdkVersion {
* @see #JAVA_17
*/
public static int getMajorJavaVersion() {
return majorJavaVersion;
return MAJOR_JAVA_VER;
}
public static boolean isJava64Bit() {

View File

@@ -115,10 +115,11 @@ public class ZipEngine {
public void putStream(InputStream is, String pathName) throws IOException {
int length;
BufferedInputStream bis = new BufferedInputStream(is);
zos.putNextEntry(new ZipEntry(pathName));
while ((length = bis.read(buf)) > 0)
zos.write(buf, 0, length);
try (BufferedInputStream bis = new BufferedInputStream(is)) {
zos.putNextEntry(new ZipEntry(pathName));
while ((length = bis.read(buf)) > 0)
zos.write(buf, 0, length);
}
}
public void putTextFile(String text, String pathName) throws IOException {

View File

@@ -236,9 +236,9 @@ modpack.incorrect_format.no_json=整合包格式错误pack.json丢失
modpack.incorrect_format.no_jar=整合包格式错误pack.json丢失jar字段
modpack.cannot_read_version=读取游戏版本失败
modpack.not_a_valid_location=不是一个有效整合包位置
modpack.warning=<html>在制作整合包前,请您确认您选择的版本可以正常启动,<br/>并保证您的Minecraft是正式版而非快照版<br/>而且不应当将不允许非官方途径传播的Mod、材质包等纳入整合包。</html>
modpack.warning=<html>在制作整合包前,请您确认您选择的版本可以正常启动,<br/>并保证您的Minecraft是正式版而非快照版<br/>而且不应当将不允许非官方途径传播的Mod、材质包等纳入整合包。<br/>整合包会保存您目前的下载源设置</html>
modpack.name=整合包名称
modpack.not_a_valid_name=整合包名称不能为空
modpack.not_a_valid_name=不是一个有效的整合包名称
modpack.files.servers_dat=多人游戏服务器列表
modpack.files.saves=游戏存档
@@ -249,6 +249,9 @@ modpack.files.resourcepacks=资源包(材质包)
modpack.files.options_txt=游戏设定
modpack.files.optionsshaders_txt=光影设定
modpack.files.mods.voxelmods=VoxelMods配置如小地图
modpack.files.dumps=NEI调试输出
modpack.files.scripts=MineTweaker配置
modpack.files.blueprints=BuildCraft蓝图
mods=Mod管理
mods.choose_mod=选择模组

View File

@@ -236,9 +236,9 @@ modpack.incorrect_format.no_json=\u6574\u5408\u5305\u683c\u5f0f\u9519\u8bef\uff0
modpack.incorrect_format.no_jar=\u6574\u5408\u5305\u683c\u5f0f\u9519\u8bef\uff0cpack.json\u4e22\u5931jar\u5b57\u6bb5
modpack.cannot_read_version=\u8bfb\u53d6\u6e38\u620f\u7248\u672c\u5931\u8d25
modpack.not_a_valid_location=\u4e0d\u662f\u4e00\u4e2a\u6709\u6548\u6574\u5408\u5305\u4f4d\u7f6e
modpack.warning=<html>\u5728\u5236\u4f5c\u6574\u5408\u5305\u524d\uff0c\u8bf7\u60a8\u786e\u8ba4\u60a8\u9009\u62e9\u7684\u7248\u672c\u53ef\u4ee5\u6b63\u5e38\u542f\u52a8\uff0c<br/>\u5e76\u4fdd\u8bc1\u60a8\u7684Minecraft\u662f\u6b63\u5f0f\u7248\u800c\u975e\u5feb\u7167\u7248\uff0c<br/>\u800c\u4e14\u4e0d\u5e94\u5f53\u5c06\u4e0d\u5141\u8bb8\u975e\u5b98\u65b9\u9014\u5f84\u4f20\u64ad\u7684Mod\u3001\u6750\u8d28\u5305\u7b49\u7eb3\u5165\u6574\u5408\u5305\u3002</html>
modpack.warning=<html>\u5728\u5236\u4f5c\u6574\u5408\u5305\u524d\uff0c\u8bf7\u60a8\u786e\u8ba4\u60a8\u9009\u62e9\u7684\u7248\u672c\u53ef\u4ee5\u6b63\u5e38\u542f\u52a8\uff0c<br/>\u5e76\u4fdd\u8bc1\u60a8\u7684Minecraft\u662f\u6b63\u5f0f\u7248\u800c\u975e\u5feb\u7167\u7248\uff0c<br/>\u800c\u4e14\u4e0d\u5e94\u5f53\u5c06\u4e0d\u5141\u8bb8\u975e\u5b98\u65b9\u9014\u5f84\u4f20\u64ad\u7684Mod\u3001\u6750\u8d28\u5305\u7b49\u7eb3\u5165\u6574\u5408\u5305\u3002<br/>\u6574\u5408\u5305\u4f1a\u4fdd\u5b58\u60a8\u76ee\u524d\u7684\u4e0b\u8f7d\u6e90\u8bbe\u7f6e</html>
modpack.name=\u6574\u5408\u5305\u540d\u79f0
modpack.not_a_valid_name=\u6574\u5408\u5305\u540d\u79f0\u4e0d\u80fd\u4e3a\u7a7a
modpack.not_a_valid_name=\u4e0d\u662f\u4e00\u4e2a\u6709\u6548\u7684\u6574\u5408\u5305\u540d\u79f0
modpack.files.servers_dat=\u591a\u4eba\u6e38\u620f\u670d\u52a1\u5668\u5217\u8868
modpack.files.saves=\u6e38\u620f\u5b58\u6863
@@ -249,6 +249,9 @@ modpack.files.resourcepacks=\u8d44\u6e90\u5305(\u6750\u8d28\u5305)
modpack.files.options_txt=\u6e38\u620f\u8bbe\u5b9a
modpack.files.optionsshaders_txt=\u5149\u5f71\u8bbe\u5b9a
modpack.files.mods.voxelmods=VoxelMods\u914d\u7f6e\uff0c\u5982\u5c0f\u5730\u56fe
modpack.files.dumps=NEI\u8c03\u8bd5\u8f93\u51fa
modpack.files.scripts=MineTweaker\u914d\u7f6e
modpack.files.blueprints=BuildCraft\u84dd\u56fe
mods=Mod\u7ba1\u7406
mods.choose_mod=\u9009\u62e9\u6a21\u7ec4

View File

@@ -238,17 +238,20 @@ modpack.cannot_read_version=Failed to gather the game version
modpack.not_a_valid_location=Not a valid modpack location
modpack.warning=<html>Before making modpack, you should ensure that your game can launch successfully,<br/>and that your Minecraft is release, not snapshot.<br/>and that it is not allowed to add mods which is not allowed to distribute to the modpack.</html>
modpack.name=Modpack Name
modpack.not_a_valid_name=Modpack Name cannot be empty.
modpack.not_a_valid_name=Not a valid modpack name
modpack.files.servers_dat=Multiplayer servers list
modpack.files.saves=Saved games
modpack.files.mods=Mods
modpack.files.config=Mod configurations
modpack.files.config=Mod configs
modpack.files.liteconfig=Mod configurations
modpack.files.resourcepacks=Resource(Texutre) packs
modpack.files.options_txt=Game options
modpack.files.optionsshaders_txt=Shaders options
modpack.files.mods.voxelmods=VoxelMods(including VoxelMap) options
modpack.files.dumps=NEI debug output
modpack.files.scripts=MineTweaker configs
modpack.files.blueprints=BuildCraft blueprints
mods=Mods
mods.choose_mod=Choose your mods

View File

@@ -238,17 +238,20 @@ modpack.cannot_read_version=Failed to gather the game version
modpack.not_a_valid_location=Not a valid modpack location
modpack.warning=<html>Before making modpack, you should ensure that your game can launch successfully,<br/>and that your Minecraft is release, not snapshot.<br/>and that it is not allowed to add mods which is not allowed to distribute to the modpack.</html>
modpack.name=Modpack Name
modpack.not_a_valid_name=Modpack Name cannot be empty.
modpack.not_a_valid_name=Not a valid modpack name
modpack.files.servers_dat=Multiplayer servers list
modpack.files.saves=Saved games
modpack.files.mods=Mods
modpack.files.config=Mod configurations
modpack.files.config=Mod configs
modpack.files.liteconfig=Mod configurations
modpack.files.resourcepacks=Resource(Texutre) packs
modpack.files.options_txt=Game options
modpack.files.optionsshaders_txt=Shaders options
modpack.files.mods.voxelmods=VoxelMods(including VoxelMap) options
modpack.files.dumps=NEI debug output
modpack.files.scripts=MineTweaker configs
modpack.files.blueprints=BuildCraft blueprints
mods=Mods
mods.choose_mod=Choose your mods

View File

@@ -236,9 +236,9 @@ modpack.incorrect_format.no_json=懶人包格式錯誤pack.json丟失
modpack.incorrect_format.no_jar=懶人包格式錯誤pack.json丟失jar字段
modpack.cannot_read_version=讀取遊戲版本失敗
modpack.not_a_valid_location=不是一个有效懒人包位置
modpack.warning=<html>在製作懶人包前,請您確認您選擇的版本可以正常啟動,<br/>並保證您的Minecraft是正式版而非快照版,<br/>而且不應當將不允許非官方途徑傳播的Mod、材質包等納入整合包。 </html>
modpack.warning=<html>在製作懶人包前,請您確認您選擇的版本可以正常啟動,<br/>並保證您的Minecraft是正式版而非快照版,<br/>而且不應當將不允許非官方途徑傳播的Mod、材質包等納入整合包。<br/>懶人包會保存您目前的下載源設定</html>
modpack.name=懶人包名稱
modpack.not_a_valid_name=懶人包名稱不能為空
modpack.not_a_valid_name=不是一个有效的懶人包名稱
modpack.files.servers_dat=多人遊戲伺服器列表
modpack.files.saves=遊戲存檔
@@ -249,6 +249,9 @@ modpack.files.resourcepacks=資源包(材質包)
modpack.files.options_txt=遊戲設定
modpack.files.optionsshaders_txt=光影設定
modpack.files.mods.voxelmods=VoxelMods設定如小地圖
modpack.files.dumps=NEI調試輸出
modpack.files.scripts=MineTweaker配置
modpack.files.blueprints=BuildCraft藍圖
mods=Mod管理
mods.choose_mod=选择模组

View File

@@ -236,9 +236,9 @@ modpack.incorrect_format.no_json=\u61f6\u4eba\u5305\u683c\u5f0f\u932f\u8aa4\uff0
modpack.incorrect_format.no_jar=\u61f6\u4eba\u5305\u683c\u5f0f\u932f\u8aa4\uff0cpack.json\u4e1f\u5931jar\u5b57\u6bb5
modpack.cannot_read_version=\u8b80\u53d6\u904a\u6232\u7248\u672c\u5931\u6557
modpack.not_a_valid_location=\u4e0d\u662f\u4e00\u4e2a\u6709\u6548\u61d2\u4eba\u5305\u4f4d\u7f6e
modpack.warning=<html>\u5728\u88fd\u4f5c\u61f6\u4eba\u5305\u524d,\u8acb\u60a8\u78ba\u8a8d\u60a8\u9078\u64c7\u7684\u7248\u672c\u53ef\u4ee5\u6b63\u5e38\u555f\u52d5,\u200b\u200b<br/>\u4e26\u4fdd\u8b49\u60a8\u7684Minecraft\u662f\u6b63\u5f0f\u7248\u800c\u975e\u5feb\u7167\u7248,<br/>\u800c\u4e14\u4e0d\u61c9\u7576\u5c07\u4e0d\u5141\u8a31\u975e\u5b98\u65b9\u9014\u5f91\u50b3\u64ad\u7684Mod\u3001\u6750\u8cea\u5305\u7b49\u7d0d\u5165\u6574\u5408\u5305\u3002 </html>
modpack.warning=<html>\u5728\u88fd\u4f5c\u61f6\u4eba\u5305\u524d,\u8acb\u60a8\u78ba\u8a8d\u60a8\u9078\u64c7\u7684\u7248\u672c\u53ef\u4ee5\u6b63\u5e38\u555f\u52d5,<br/>\u4e26\u4fdd\u8b49\u60a8\u7684Minecraft\u662f\u6b63\u5f0f\u7248\u800c\u975e\u5feb\u7167\u7248,<br/>\u800c\u4e14\u4e0d\u61c9\u7576\u5c07\u4e0d\u5141\u8a31\u975e\u5b98\u65b9\u9014\u5f91\u50b3\u64ad\u7684Mod\u3001\u6750\u8cea\u5305\u7b49\u7d0d\u5165\u6574\u5408\u5305\u3002<br/>\u61f6\u4eba\u5305\u6703\u4fdd\u5b58\u60a8\u76ee\u524d\u7684\u4e0b\u8f09\u6e90\u8a2d\u5b9a</html>
modpack.name=\u61f6\u4eba\u5305\u540d\u7a31
modpack.not_a_valid_name=\u61f6\u4eba\u5305\u540d\u7a31\u4e0d\u80fd\u70ba\u7a7a
modpack.not_a_valid_name=\u4e0d\u662f\u4e00\u4e2a\u6709\u6548\u7684\u61f6\u4eba\u5305\u540d\u7a31
modpack.files.servers_dat=\u591a\u4eba\u904a\u6232\u4f3a\u670d\u5668\u5217\u8868
modpack.files.saves=\u904a\u6232\u5b58\u6a94
@@ -249,6 +249,9 @@ modpack.files.resourcepacks=\u8cc7\u6e90\u5305(\u6750\u8cea\u5305)
modpack.files.options_txt=\u904a\u6232\u8a2d\u5b9a
modpack.files.optionsshaders_txt=\u5149\u5f71\u8a2d\u5b9a
modpack.files.mods.voxelmods=VoxelMods\u8a2d\u5b9a\uff0c\u5982\u5c0f\u5730\u5716
modpack.files.dumps=NEI\u8abf\u8a66\u8f38\u51fa
modpack.files.scripts=MineTweaker\u914d\u7f6e
modpack.files.blueprints=BuildCraft\u85cd\u5716
mods=Mod\u7ba1\u7406
mods.choose_mod=\u9009\u62e9\u6a21\u7ec4