Added Gaussion Blur
This commit is contained in:
@@ -19,14 +19,10 @@ buildscript {
|
||||
repositories {
|
||||
mavenCentral();
|
||||
|
||||
maven {
|
||||
url "https://libraries.minecraft.net"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'net.sf.proguard:proguard-gradle:4.10'
|
||||
classpath 'edu.sc.seis.gradle:launch4j:1.0.6'
|
||||
classpath 'me.tatarka:gradle-retrolambda:3.1.0'
|
||||
classpath 'me.tatarka:gradle-retrolambda:3.4.0'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,11 +46,11 @@ def buildnumber = System.getenv("TRAVIS_BUILD_NUMBER")
|
||||
if (buildnumber == null)
|
||||
buildnumber = System.getenv("BUILD_NUMBER")
|
||||
if (buildnumber == null)
|
||||
buildnumber = "233"
|
||||
buildnumber = "0"
|
||||
|
||||
def versionroot = System.getenv("VERSION_ROOT")
|
||||
if (versionroot == null)
|
||||
versionroot = "2.4.1"
|
||||
versionroot = "2.6.0"
|
||||
|
||||
String mavenGroupId = 'HMCL'
|
||||
String mavenVersion = versionroot + '.' + buildnumber
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PluginManager {
|
||||
try {
|
||||
IPlugin p = (IPlugin) cls.newInstance();
|
||||
NOW_PLUGIN = p;
|
||||
} catch (Exception e) {
|
||||
} catch (IllegalAccessException | InstantiationException e) {
|
||||
HMCLog.err("Failed to new instance");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService;
|
||||
@@ -32,7 +33,6 @@ import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.core.download.IDownloadProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||
import org.jackhuang.hellominecraft.util.Utils;
|
||||
import org.jackhuang.hellominecraft.util.VersionNumber;
|
||||
import org.jackhuang.hellominecraft.util.tasks.TaskInfo;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
||||
|
||||
@Override
|
||||
public Task getList(final MinecraftVersion mv, final IMinecraftAssetService mp) {
|
||||
Utils.requireNonNull(mv);
|
||||
Objects.requireNonNull(mv);
|
||||
String assetsId = mv.getAssetsIndex().getId();
|
||||
File assets = mp.getAssets();
|
||||
HMCLog.log("Gathering asset index: " + assetsId);
|
||||
@@ -63,7 +63,7 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Throwable {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Throwable {
|
||||
if (!areDependTasksSucceeded)
|
||||
throw new IllegalStateException("Failed to get asset index");
|
||||
String result = FileUtils.read(f);
|
||||
@@ -72,7 +72,6 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
||||
AssetsIndex o = C.GSON.fromJson(result, AssetsIndex.class);
|
||||
assetsDownloadURLs = new ArrayList<>();
|
||||
assetsLocalNames = new ArrayList<>();
|
||||
ArrayList<String> al = new ArrayList<>();
|
||||
contents = new ArrayList<>();
|
||||
HashSet<String> loadedHashes = new HashSet<>();
|
||||
int pgs = 0;
|
||||
@@ -88,7 +87,6 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
||||
contents.add(c);
|
||||
assetsDownloadURLs.add(c.key);
|
||||
assetsLocalNames.add(new File(assets, "objects" + File.separator + c.key.replace("/", File.separator)));
|
||||
al.add(e.getKey());
|
||||
if (ppl != null)
|
||||
ppl.setProgress(this, ++pgs, o.getFileMap().size());
|
||||
}
|
||||
|
||||
@@ -32,8 +32,6 @@ import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.util.tasks.download.FileDownloadTask;
|
||||
import org.jackhuang.hellominecraft.util.code.DigestUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
import org.jackhuang.hellominecraft.util.OverridableSwingWorker;
|
||||
import org.jackhuang.hellominecraft.util.tasks.TaskInfo;
|
||||
|
||||
/**
|
||||
@@ -72,7 +70,7 @@ public abstract class IAssetsHandler {
|
||||
*
|
||||
* @param mv The version that needs assets
|
||||
* @param mp Asset Service
|
||||
* @param x finished event
|
||||
* @return just run it!
|
||||
*/
|
||||
public abstract Task getList(MinecraftVersion mv, IMinecraftAssetService mp);
|
||||
|
||||
@@ -98,7 +96,7 @@ public abstract class IAssetsHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() {
|
||||
public void executeTask(boolean areDependTasksSucceeded) {
|
||||
if (assetsDownloadURLs == null || assetsLocalNames == null || contents == null)
|
||||
throw new IllegalStateException(C.i18n("assets.not_refreshed"));
|
||||
int max = assetsDownloadURLs.size();
|
||||
@@ -116,7 +114,7 @@ public abstract class IAssetsHandler {
|
||||
try {
|
||||
if (location.exists()) {
|
||||
FileInputStream fis = new FileInputStream(location);
|
||||
String sha = DigestUtils.sha1Hex(NetUtils.getBytesFromStream(fis));
|
||||
String sha = DigestUtils.sha1Hex(IOUtils.getBytesFromStream(fis));
|
||||
IOUtils.closeQuietly(fis);
|
||||
if (contents.get(i).geteTag().equals(sha)) {
|
||||
++hasDownloaded;
|
||||
|
||||
@@ -68,14 +68,14 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task downloadMinecraftAssetsIndex(AssetIndexDownloadInfo assets) {
|
||||
public Task downloadMinecraftAssetsIndex(AssetIndexDownloadInfo assetIndex) {
|
||||
File assetsLocation = getAssets();
|
||||
if (!assetsLocation.exists() && !assetsLocation.mkdirs())
|
||||
HMCLog.warn("Failed to make directories: " + assetsLocation);
|
||||
File assetsIndex = new File(assetsLocation, "indexes/" + assets.getId() + ".json");
|
||||
File assetsIndex = getIndexFile(assetIndex.getId());
|
||||
File renamed = null;
|
||||
if (assetsIndex.exists()) {
|
||||
renamed = new File(assetsLocation, "indexes/" + assets.getId() + "-renamed.json");
|
||||
renamed = new File(assetsLocation, "indexes/" + assetIndex.getId() + "-renamed.json");
|
||||
if (assetsIndex.renameTo(renamed))
|
||||
HMCLog.warn("Failed to rename " + assetsIndex + " to " + renamed);
|
||||
}
|
||||
@@ -83,11 +83,11 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
return new TaskInfo("Download Asset Index") {
|
||||
@Override
|
||||
public Collection<Task> getDependTasks() {
|
||||
return Arrays.asList(new FileDownloadTask(assets.getUrl(service.getDownloadType()), IOUtils.tryGetCanonicalFile(assetsIndex), assets.sha1).setTag(assets.getId() + ".json"));
|
||||
return Arrays.asList(new FileDownloadTask(assetIndex.getUrl(service.getDownloadType()), IOUtils.tryGetCanonicalFile(assetsIndex), assetIndex.sha1).setTag(assetIndex.getId() + ".json"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Throwable {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Throwable {
|
||||
if (areDependTasksSucceeded) {
|
||||
if (renamedFinal != null && !renamedFinal.delete())
|
||||
HMCLog.warn("Failed to delete " + renamedFinal + ", maybe you should do it.");
|
||||
@@ -98,20 +98,20 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean downloadMinecraftAssetsIndexAsync(AssetIndexDownloadInfo assets) {
|
||||
File assetsLocation = getAssets();
|
||||
if (!assetsLocation.exists() && !assetsLocation.mkdirs())
|
||||
HMCLog.warn("Failed to make directories: " + assetsLocation);
|
||||
File assetsIndex = new File(assetsLocation, "indexes/" + assets.getId() + ".json");
|
||||
public boolean downloadMinecraftAssetsIndexAsync(AssetIndexDownloadInfo assetIndex) {
|
||||
File assetsDir = getAssets();
|
||||
if (!assetsDir.mkdirs() && !assetsDir.isDirectory())
|
||||
HMCLog.warn("Failed to make directories: " + assetsDir);
|
||||
File assetsIndex = getIndexFile(assetIndex.getId());
|
||||
File renamed = null;
|
||||
if (assetsIndex.exists()) {
|
||||
renamed = new File(assetsLocation, "indexes/" + assets.getId() + "-renamed.json");
|
||||
renamed = new File(assetsDir, "indexes/" + assetIndex.getId() + "-renamed.json");
|
||||
if (assetsIndex.renameTo(renamed))
|
||||
HMCLog.warn("Failed to rename " + assetsIndex + " to " + renamed);
|
||||
}
|
||||
if (TaskWindow.factory()
|
||||
.append(new FileDownloadTask(assets.getUrl(service.getDownloadType()), IOUtils.tryGetCanonicalFile(assetsIndex), assets.sha1).setTag(assets.getId() + ".json"))
|
||||
.create()) {
|
||||
.append(new FileDownloadTask(assetIndex.getUrl(service.getDownloadType()), IOUtils.tryGetCanonicalFile(assetsIndex), assetIndex.sha1).setTag(assetIndex.getId() + ".json"))
|
||||
.execute()) {
|
||||
if (renamed != null && !renamed.delete())
|
||||
HMCLog.warn("Failed to delete " + renamed + ", maybe you should do it.");
|
||||
return true;
|
||||
@@ -125,30 +125,27 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
public File getAssets() {
|
||||
return new File(service.baseDirectory(), "assets");
|
||||
}
|
||||
|
||||
private File getIndexFile(String assetVersion) {
|
||||
return new File(getAssets(), "indexes/" + assetVersion + ".json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getAssetObject(String assetVersion, String name) throws IOException {
|
||||
File assetsDir = getAssets();
|
||||
File indexDir = new File(assetsDir, "indexes");
|
||||
File objectsDir = new File(assetsDir, "objects");
|
||||
File indexFile = new File(indexDir, assetVersion + ".json");
|
||||
try {
|
||||
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.read(indexFile, "UTF-8"), AssetsIndex.class);
|
||||
AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.read(getIndexFile(assetVersion), "UTF-8"), AssetsIndex.class);
|
||||
|
||||
String hash = ((AssetsObject) index.getFileMap().get(name)).getHash();
|
||||
return new File(objectsDir, hash.substring(0, 2) + "/" + hash);
|
||||
return new File(getAssets(), "objects/" + hash.substring(0, 2) + "/" + hash);
|
||||
} catch (JsonSyntaxException e) {
|
||||
throw new IOException("Assets file format malformed.", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkAssetsExistance(AssetIndexDownloadInfo assetIndex) {
|
||||
File assetsDir = getAssets();
|
||||
File indexDir = new File(assetsDir, "indexes");
|
||||
File objectDir = new File(assetsDir, "objects");
|
||||
File indexFile = new File(indexDir, assetIndex.getId() + ".json");
|
||||
File indexFile = getIndexFile(assetIndex.getId());
|
||||
|
||||
if (!assetsDir.exists() || !indexFile.isFile())
|
||||
if (!getAssets().exists() || !indexFile.isFile())
|
||||
return false;
|
||||
|
||||
try {
|
||||
@@ -158,7 +155,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
if (index == null)
|
||||
return false;
|
||||
for (Map.Entry entry : index.getFileMap().entrySet())
|
||||
if (!new File(new File(objectDir, ((AssetsObject) entry.getValue()).getHash().substring(0, 2)), ((AssetsObject) entry.getValue()).getHash()).exists())
|
||||
if (!new File(getAssets(), "objects/" + ((AssetsObject) entry.getValue()).getHash().substring(0, 2) + "/" + ((AssetsObject) entry.getValue()).getHash()).exists())
|
||||
return false;
|
||||
return true;
|
||||
} catch (IOException | JsonSyntaxException e) {
|
||||
@@ -168,10 +165,8 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
|
||||
private File reconstructAssets(AssetIndexDownloadInfo assetIndex) {
|
||||
File assetsDir = getAssets();
|
||||
File indexDir = new File(assetsDir, "indexes");
|
||||
File objectDir = new File(assetsDir, "objects");
|
||||
String assetVersion = assetIndex.getId();
|
||||
File indexFile = new File(indexDir, assetVersion + ".json");
|
||||
File indexFile = getIndexFile(assetVersion);
|
||||
File virtualRoot = new File(new File(assetsDir, "virtual"), assetVersion);
|
||||
|
||||
if (!indexFile.isFile()) {
|
||||
@@ -191,7 +186,7 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
int tot = index.getFileMap().entrySet().size();
|
||||
for (Map.Entry entry : index.getFileMap().entrySet()) {
|
||||
File target = new File(virtualRoot, (String) entry.getKey());
|
||||
File original = new File(new File(objectDir, ((AssetsObject) entry.getValue()).getHash().substring(0, 2)), ((AssetsObject) entry.getValue()).getHash());
|
||||
File original = new File(assetsDir, "objects/" + ((AssetsObject) entry.getValue()).getHash().substring(0, 2) + "/" + ((AssetsObject) entry.getValue()).getHash());
|
||||
if (original.exists()) {
|
||||
cnt++;
|
||||
if (!target.isFile())
|
||||
@@ -211,8 +206,8 @@ public class MinecraftAssetService extends IMinecraftAssetService {
|
||||
|
||||
public final BiFunction<MinecraftVersion, Boolean, String> ASSET_PROVIDER_IMPL = (t, allow) -> {
|
||||
if (allow && !checkAssetsExistance(t.getAssetsIndex()))
|
||||
if (MessageBox.Show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
TaskWindow.execute(downloadAssets(t));
|
||||
if (MessageBox.show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
TaskWindow.factory().execute(downloadAssets(t));
|
||||
return reconstructAssets(t.getAssetsIndex()).getAbsolutePath();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* 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.launcher.core.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.Charset;
|
||||
import org.jackhuang.hellominecraft.util.code.DigestUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class BestLogin extends IAuthenticator {
|
||||
|
||||
public BestLogin(String clientToken) {
|
||||
super(clientToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProfileProvider login(LoginInfo info) throws AuthenticationException {
|
||||
try {
|
||||
String request = "bl:l:" + info.username + ":" + DigestUtils.sha1Hex(info.password);
|
||||
|
||||
Socket socket = new Socket("auth.zhh0000zhh.com", 8);
|
||||
OutputStream os = socket.getOutputStream();
|
||||
os.write(request.length());
|
||||
os.write(request.getBytes(Charset.forName("UTF-8")));
|
||||
|
||||
UserProfileProvider lr = new UserProfileProvider();
|
||||
|
||||
InputStream is = socket.getInputStream();
|
||||
int code = is.read();
|
||||
switch (code) {
|
||||
case -1:
|
||||
throw new AuthenticationException("internet error.");
|
||||
case 200:
|
||||
throw new AuthenticationException("server restarting.");
|
||||
case 255:
|
||||
throw new AuthenticationException("unknown error");
|
||||
case 3:
|
||||
throw new AuthenticationException("unregistered.");
|
||||
case 50:
|
||||
throw new AuthenticationException("please update your launcher and act your account.");
|
||||
case 2:
|
||||
throw new AuthenticationException("wrong password.");
|
||||
case 100:
|
||||
throw new AuthenticationException("server reloading.");
|
||||
case 0:
|
||||
byte[] b = new byte[64];
|
||||
int x = is.read(b, 0, b.length);
|
||||
if (x != -1)
|
||||
throw new AuthenticationException("server response does not follow the protocol.");
|
||||
String[] ss = new String(b, Charset.forName("UTF-8")).split(":");
|
||||
lr.setUserName(info.username);
|
||||
lr.setUserId(ss[1]);
|
||||
lr.setSession(ss[0]);
|
||||
lr.setAccessToken(ss[0]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
lr.setUserType("Legacy");
|
||||
return lr;
|
||||
} catch (IOException t) {
|
||||
throw new AuthenticationException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String id() {
|
||||
return "best";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "BestLogin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProfileProvider loginBySettings() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logOut() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,8 +56,6 @@ public final class OfflineAuthenticator extends IAuthenticator {
|
||||
public UserProfileProvider login(LoginInfo info) throws AuthenticationException {
|
||||
if (StrUtils.isBlank(info.username))
|
||||
throw new AuthenticationException(C.i18n("login.no_Player007"));
|
||||
UserProfileProvider result = new UserProfileProvider();
|
||||
result.setUserName(info.username);
|
||||
String uuid = getUUIDFromUserName(info.username);
|
||||
if (uuidMap != null && uuidMap.containsKey(uuid))
|
||||
uuid = uuidMap.get(info.username);
|
||||
@@ -66,11 +64,12 @@ public final class OfflineAuthenticator extends IAuthenticator {
|
||||
uuidMap = new HashMap<>();
|
||||
uuidMap.put(info.username, uuid);
|
||||
}
|
||||
result.setSession(uuid);
|
||||
result.setUserId(uuid);
|
||||
result.setAccessToken(uuid);
|
||||
result.setUserType("Legacy");
|
||||
return result;
|
||||
return new UserProfileProvider()
|
||||
.setUserName(info.username)
|
||||
.setSession(uuid)
|
||||
.setUserId(uuid)
|
||||
.setAccessToken(uuid)
|
||||
.setUserType("Legacy");
|
||||
}
|
||||
|
||||
public static String getUUIDFromUserName(String str) {
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* 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.launcher.core.auth;
|
||||
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.code.DigestUtils;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
import org.jackhuang.hellominecraft.util.lang.SupportedLocales;
|
||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class SkinmeAuthenticator extends IAuthenticator {
|
||||
|
||||
public SkinmeAuthenticator(String clientToken) {
|
||||
super(clientToken);
|
||||
}
|
||||
|
||||
public String[] parseType1(String s) {
|
||||
return s.split(",");
|
||||
}
|
||||
|
||||
public String getCharacter(String user, String hash, String $char) throws Exception {
|
||||
return NetUtils.get(
|
||||
"http://www.skinme.cc/api/login.php?user=" + user + "&hash=" + hash + (($char == null) ? "" : ("&char=" + $char)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProfileProvider login(LoginInfo info) throws AuthenticationException {
|
||||
UserProfileProvider req = new UserProfileProvider();
|
||||
if (info.username == null || !info.username.contains("@"))
|
||||
throw new AuthenticationException(C.i18n("login.not_email"));
|
||||
try {
|
||||
String usr = info.username.toLowerCase(SupportedLocales.NOW_LOCALE.self);
|
||||
String pwd = info.password;
|
||||
|
||||
String str = DigestUtils.sha1Hex(usr);
|
||||
String hashCode = DigestUtils.sha1Hex(DigestUtils.md5Hex(DigestUtils.sha1Hex(pwd) + pwd) + str);
|
||||
String data = getCharacter(usr, hashCode, null);
|
||||
String[] sl = data.split(":");
|
||||
if (null != sl[0])
|
||||
switch (sl[0]) {
|
||||
case "0":
|
||||
if (sl[1].contains("No Valid Character"))
|
||||
sl[1] = C.i18n("login.no_valid_character");
|
||||
throw new AuthenticationException(sl[1]);
|
||||
case "1":
|
||||
String[] s = parseType1(sl[1]);
|
||||
req.setUserName(s[0]);
|
||||
req.setSession(s[1]);
|
||||
req.setUserId(s[1]);
|
||||
req.setAccessToken(s[1]);
|
||||
break;
|
||||
case "2":
|
||||
String[] charators = sl[1].split(";");
|
||||
int len = charators.length;
|
||||
String[] $char = new String[len];
|
||||
String[] user = new String[len];
|
||||
System.out.println(sl[1]);
|
||||
for (int i = 0; i < len; i++) {
|
||||
String[] charator = charators[i].split(",");
|
||||
$char[i] = charator[0];
|
||||
user[i] = charator[1];
|
||||
}
|
||||
int index = SwingUtils.select(user, C.i18n("login.choose_charactor"));
|
||||
if (index == -1)
|
||||
throw new AuthenticationException(C.i18n("message.cancelled"));
|
||||
else {
|
||||
String character = $char[index];
|
||||
sl = getCharacter(usr, hashCode, character).split(":");
|
||||
String[] s2 = parseType1(sl[1]);
|
||||
req.setUserName(s2[0]);
|
||||
req.setSession(s2[1]);
|
||||
req.setUserId(s2[1]);
|
||||
req.setAccessToken(s2[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
req.setUserType("Legacy");
|
||||
return req;
|
||||
} catch (Exception e) {
|
||||
throw new AuthenticationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String id() {
|
||||
return "skinme";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Skinme";
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProfileProvider loginBySettings() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logOut() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -27,74 +27,83 @@ public final class UserProfileProvider {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUserName(String username) {
|
||||
public UserProfileProvider setUserName(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
public UserProfileProvider setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
public void setSession(String session) {
|
||||
public UserProfileProvider setSession(String session) {
|
||||
this.session = session;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public void setAccessToken(String accessToken) {
|
||||
public UserProfileProvider setAccessToken(String accessToken) {
|
||||
if (accessToken == null)
|
||||
accessToken = "0";
|
||||
this.accessToken = accessToken;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserProperties() {
|
||||
return userProperties;
|
||||
}
|
||||
|
||||
public void setUserProperties(String userProperties) {
|
||||
public UserProfileProvider setUserProperties(String userProperties) {
|
||||
this.userProperties = userProperties;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserPropertyMap() {
|
||||
return userPropertyMap;
|
||||
}
|
||||
|
||||
public void setUserPropertyMap(String userPropertyMap) {
|
||||
public UserProfileProvider setUserPropertyMap(String userPropertyMap) {
|
||||
this.userPropertyMap = userPropertyMap;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOtherInfo() {
|
||||
return otherInfo;
|
||||
}
|
||||
|
||||
public void setOtherInfo(String otherInfo) {
|
||||
public UserProfileProvider setOtherInfo(String otherInfo) {
|
||||
this.otherInfo = otherInfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getClientIdentifier() {
|
||||
return clientIdentifier;
|
||||
}
|
||||
|
||||
public void setClientIdentifier(String clientIdentifier) {
|
||||
public UserProfileProvider setClientIdentifier(String clientIdentifier) {
|
||||
this.clientIdentifier = clientIdentifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(String userType) {
|
||||
public UserProfileProvider setUserType(String userType) {
|
||||
this.userType = userType;
|
||||
return this;
|
||||
}
|
||||
|
||||
private String username = "";
|
||||
|
||||
@@ -45,10 +45,9 @@ public final class YggdrasilAuthenticator extends IAuthenticator {
|
||||
@Override
|
||||
public UserProfileProvider login(LoginInfo info) throws AuthenticationException {
|
||||
UserProfileProvider result = new UserProfileProvider();
|
||||
result.setUserType("mojang");
|
||||
if (ua.canPlayOnline()) {
|
||||
result.setUserName(info.username);
|
||||
result.setUserId(UUIDTypeAdapter.fromUUID(ua.getSelectedProfile().id));
|
||||
result.setUserName(info.username)
|
||||
.setUserId(UUIDTypeAdapter.fromUUID(ua.getSelectedProfile().id));
|
||||
} else {
|
||||
String usr = info.username;
|
||||
if (info.username == null || !info.username.contains("@"))
|
||||
@@ -80,14 +79,14 @@ public final class YggdrasilAuthenticator extends IAuthenticator {
|
||||
username = selectedProfile.name;
|
||||
if (username == null)
|
||||
throw new AuthenticationException("No player");
|
||||
result.setUserName(username);
|
||||
result.setUserId(selectedProfile == null ? OfflineAuthenticator.getUUIDFromUserName(username) : UUIDTypeAdapter.fromUUID(selectedProfile.id));
|
||||
result.setUserName(username)
|
||||
.setUserId(selectedProfile == null ? OfflineAuthenticator.getUUIDFromUserName(username) : UUIDTypeAdapter.fromUUID(selectedProfile.id));
|
||||
}
|
||||
result.setUserProperties(new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.LegacySerializer()).create().toJson(ua.getUserProperties()));
|
||||
result.setUserPropertyMap(new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(ua.getUserProperties()));
|
||||
result.setAccessToken(ua.getAuthenticatedToken());
|
||||
result.setSession(ua.getAuthenticatedToken());
|
||||
return result;
|
||||
return result.setUserType("mojang")
|
||||
.setUserProperties(new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.LegacySerializer()).create().toJson(ua.getUserProperties()))
|
||||
.setUserPropertyMap(new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(ua.getUserProperties()))
|
||||
.setAccessToken(ua.getAuthenticatedToken())
|
||||
.setSession(ua.getAuthenticatedToken());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jackhuang.hellominecraft.launcher.core.download;
|
||||
|
||||
import java.io.File;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.IMinecraftLibrary;
|
||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -34,6 +33,21 @@ public class DownloadLibraryJob {
|
||||
public DownloadLibraryJob(IMinecraftLibrary n, String u, File p) {
|
||||
url = u;
|
||||
lib = n;
|
||||
path = IOUtils.tryGetCanonicalFile(p);
|
||||
path = p;
|
||||
}
|
||||
|
||||
public DownloadLibraryJob parse() {
|
||||
String name = lib.name;
|
||||
if (name.startsWith("net.minecraftforge:forge:")) {
|
||||
String[] s = name.split(":");
|
||||
if (s.length == 3)
|
||||
url = "http://files.minecraftforge.net/maven/net/minecraftforge/forge/" + s[2] + "/forge-" + s[2] + "-universal.jar";
|
||||
}
|
||||
if (name.startsWith("com.mumfrey:liteloader:")) {
|
||||
String[] s = name.split(":");
|
||||
if (s.length == 3 && s[2].length() > 3)
|
||||
url = "http://dl.liteloader.com/versions/com/mumfrey/liteloader/" + s[2].substring(0, s[2].length() - 3) + "/liteloader-" + s[2] + ".jar";
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ public enum DownloadType {
|
||||
|
||||
Mojang("download.mojang", new MojangDownloadProvider()),
|
||||
BMCL("download.BMCL", new BMCLAPIDownloadProvider()),
|
||||
//RapidData("download.rapid_data", new RapidDataDownloadProvider()),
|
||||
Curse("Curse CDN", new CurseDownloadProvider());
|
||||
|
||||
private final String name;
|
||||
|
||||
@@ -75,7 +75,7 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Throwable {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Throwable {
|
||||
File vpath = new File(service.baseDirectory(), "versions/" + id);
|
||||
if (!areDependTasksSucceeded) {
|
||||
FileUtils.deleteDirectory(vpath);
|
||||
@@ -131,7 +131,7 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
public Task downloadMinecraftVersionJson(String id) {
|
||||
return new TaskInfo("Download Minecraft Json") {
|
||||
@Override
|
||||
public void executeTask() throws Throwable {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Throwable {
|
||||
List<MinecraftRemoteVersion> versions = MinecraftRemoteVersions.getRemoteVersions(service.getDownloadType()).justDo();
|
||||
MinecraftRemoteVersion currentVersion = null;
|
||||
for (MinecraftRemoteVersion v : versions)
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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.launcher.core.download;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class RapidDataDownloadProvider extends MojangDownloadProvider {
|
||||
|
||||
@Override
|
||||
public String getAssetsDownloadURL() {
|
||||
return "http://mirrors.rapiddata.org/resources.download.minecraft.net/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLibraryDownloadURL() {
|
||||
return "http://mirrors.rapiddata.org/libraries.minecraft.net";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexesDownloadURL() {
|
||||
return "http://mirrors.rapiddata.org/Minecraft.Download/indexes/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionsDownloadURL() {
|
||||
return "http://mirrors.rapiddata.org/Minecraft.Download/versions/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionsListDownloadURL() {
|
||||
return "http://mirrors.rapiddata.org/Minecraft.Download/versions/versions.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParsedDownloadURL(String str) {
|
||||
return str == null ? null : str.replace("http://files.minecraftforge.net/maven", "http://mirrors.rapiddata.org/forge/maven");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -79,6 +79,8 @@ public final class MinecraftInstallerService extends IMinecraftInstallerService
|
||||
|
||||
@Override
|
||||
public Task downloadLiteLoader(String installId, InstallerVersion v) {
|
||||
if (!(v instanceof LiteLoaderVersionList.LiteLoaderInstallerVersion))
|
||||
throw new Error("Download lite loader but the version is not ll's.");
|
||||
File filepath = IOUtils.tryGetCanonicalFile("liteloader-universal.jar");
|
||||
FileDownloadTask task = (FileDownloadTask) new FileDownloadTask(v.universal, filepath).setTag("LiteLoader");
|
||||
return task.after(new LiteLoaderInstaller(service, installId, (LiteLoaderVersionList.LiteLoaderInstallerVersion) v).registerPreviousResult(task))
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.system.Compressor;
|
||||
import org.jackhuang.hellominecraft.util.system.CompressingUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
|
||||
/**
|
||||
@@ -43,8 +43,8 @@ public class PackMinecraftInstaller {
|
||||
if (!file.exists() && !file.mkdirs())
|
||||
HMCLog.warn("Failed to make directories: " + file);
|
||||
for (String src1 : src)
|
||||
Compressor.unzip(new File(src1), file);
|
||||
Compressor.zip(file.getAbsolutePath(), dest.getAbsolutePath());
|
||||
CompressingUtils.unzip(new File(src1), file);
|
||||
CompressingUtils.zip(file.getAbsolutePath(), dest.getAbsolutePath());
|
||||
FileUtils.deleteDirectory(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,16 +50,16 @@ public class ForgeInstaller extends Task {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Exception {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Exception {
|
||||
HMCLog.log("Extracting install profiles...");
|
||||
|
||||
try (ZipFile zipFile = new ZipFile(forgeInstaller)) {
|
||||
ZipEntry entry = zipFile.getEntry("install_profile.json");
|
||||
String content = NetUtils.getStreamContent(zipFile.getInputStream(entry));
|
||||
String content = IOUtils.getStreamContent(zipFile.getInputStream(entry));
|
||||
InstallProfile profile = C.GSON.fromJson(content, InstallProfile.class);
|
||||
File from = new File(gameDir, "versions" + File.separator + profile.install.getMinecraft());
|
||||
if (!from.exists())
|
||||
if (MessageBox.Show(C.i18n("install.no_version_if_intall")) == MessageBox.YES_OPTION) {
|
||||
if (MessageBox.show(C.i18n("install.no_version_if_intall")) == MessageBox.YES_OPTION) {
|
||||
if (!mp.version().install(profile.install.getMinecraft(), null))
|
||||
throw new IllegalStateException(C.i18n("install.no_version"));
|
||||
} else
|
||||
@@ -67,11 +67,14 @@ public class ForgeInstaller extends Task {
|
||||
File to = new File(gameDir, "versions" + File.separator + profile.install.getTarget());
|
||||
if (!to.exists() && !to.mkdirs())
|
||||
HMCLog.warn("Failed to make new version folder " + to);
|
||||
|
||||
HMCLog.log("Copying jar..." + profile.install.getMinecraft() + ".jar to " + profile.install.getTarget() + ".jar");
|
||||
FileUtils.copyFile(new File(from, profile.install.getMinecraft() + ".jar"),
|
||||
new File(to, profile.install.getTarget() + ".jar"));
|
||||
|
||||
HMCLog.log("Creating new version profile..." + profile.install.getTarget() + ".json");
|
||||
FileUtils.write(new File(to, profile.install.getTarget() + ".json"), C.GSON.toJson(profile.versionInfo));
|
||||
|
||||
HMCLog.log("Extracting universal forge pack..." + profile.install.getFilePath());
|
||||
entry = zipFile.getEntry(profile.install.getFilePath());
|
||||
InputStream is = zipFile.getInputStream(entry);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class MinecraftForgeVersionList extends InstallerVersionList {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Throwable {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Throwable {
|
||||
if (!areDependTasksSucceeded)
|
||||
return;
|
||||
String s = task.getResult();
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.util.tasks.communication.PreviousResult;
|
||||
import org.jackhuang.hellominecraft.util.tasks.communication.PreviousResultRegistrar;
|
||||
import org.jackhuang.hellominecraft.util.tasks.comm.PreviousResult;
|
||||
import org.jackhuang.hellominecraft.util.tasks.comm.PreviousResultRegistrar;
|
||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||
@@ -53,7 +53,7 @@ public class LiteLoaderInstaller extends Task implements PreviousResultRegistrar
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Exception {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Exception {
|
||||
if (installId == null)
|
||||
throw new IllegalStateException(C.i18n("install.no_version"));
|
||||
if (pre.size() != 1 && installer == null)
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
|
||||
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionList;
|
||||
@@ -65,7 +66,7 @@ public class LiteLoaderVersionList extends InstallerVersionList {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Throwable {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Throwable {
|
||||
if (!areDependTasksSucceeded)
|
||||
return;
|
||||
String s = task.getResult();
|
||||
@@ -128,6 +129,28 @@ public class LiteLoaderVersionList extends InstallerVersionList {
|
||||
super(selfVersion, mcVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 13 * hash + Arrays.deepHashCode(this.libraries);
|
||||
hash = 13 * hash + Objects.hashCode(this.tweakClass);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof LiteLoaderVersionList))
|
||||
return false;
|
||||
if (this == obj)
|
||||
return true;
|
||||
final LiteLoaderInstallerVersion other = (LiteLoaderInstallerVersion) obj;
|
||||
if (!Objects.equals(this.tweakClass, other.tweakClass))
|
||||
return false;
|
||||
return Arrays.deepEquals(this.libraries, other.libraries);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.launcher.core.install.InstallerVersionList;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.util.tasks.communication.PreviousResult;
|
||||
import org.jackhuang.hellominecraft.util.tasks.communication.PreviousResultRegistrar;
|
||||
import org.jackhuang.hellominecraft.util.tasks.comm.PreviousResult;
|
||||
import org.jackhuang.hellominecraft.util.tasks.comm.PreviousResultRegistrar;
|
||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||
@@ -54,7 +54,7 @@ public class OptiFineInstaller extends Task implements PreviousResultRegistrar<F
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Exception {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Exception {
|
||||
if (installId == null)
|
||||
throw new Exception(C.i18n("install.no_version"));
|
||||
String selfId = version.selfVersion;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class OptiFineBMCLVersionList extends InstallerVersionList {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Throwable {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Throwable {
|
||||
String s = task.getResult();
|
||||
|
||||
versionMap = new HashMap<>();
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.util.tasks.communication.PreviousResult;
|
||||
import org.jackhuang.hellominecraft.util.tasks.comm.PreviousResult;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ public class OptiFineDownloadFormatter extends Task implements PreviousResult<St
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Exception {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Exception {
|
||||
String content = NetUtils.get(url);
|
||||
Pattern p = Pattern.compile("\"downloadx\\?f=OptiFine(.*)\"");
|
||||
Matcher m = p.matcher(content);
|
||||
|
||||
@@ -76,7 +76,7 @@ public class OptiFineVersionList extends InstallerVersionList {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Throwable {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Throwable {
|
||||
if (!areDependTasksSucceeded)
|
||||
return;
|
||||
String content = task.getResult();
|
||||
|
||||
@@ -104,17 +104,17 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
||||
HMCLog.log("System Platform: " + Platform.getPlatform().getBit());
|
||||
|
||||
if (jv != null && jv.getPlatform() == Platform.BIT_32 && Platform.getPlatform() == Platform.BIT_64)
|
||||
MessageBox.Show(C.i18n("advice.os64butjdk32"));
|
||||
MessageBox.show(C.i18n("advice.os64butjdk32"));
|
||||
|
||||
if (!StrUtils.isBlank(options.getMaxMemory())) {
|
||||
int mem = MathUtils.parseMemory(options.getMaxMemory(), 2147483647);
|
||||
if (jv != null && jv.getPlatform() == Platform.BIT_32 && mem > 1024)
|
||||
MessageBox.Show(C.i18n("launch.too_big_memory_alloc_64bit"));
|
||||
MessageBox.show(C.i18n("launch.too_big_memory_alloc_64bit"));
|
||||
else {
|
||||
long a = OS.getTotalPhysicalMemory() / 1024 / 1024;
|
||||
HMCLog.log("System Physical Memory: " + a);
|
||||
if (a > 0 && a < mem)
|
||||
MessageBox.Show(C.i18n("launch.too_big_memory_alloc_free_space_too_low", a));
|
||||
MessageBox.show(C.i18n("launch.too_big_memory_alloc_free_space_too_low", a));
|
||||
}
|
||||
String a = "-Xmx" + options.getMaxMemory();
|
||||
if (MathUtils.canParseInt(options.getMaxMemory()))
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.util.tasks.ParallelTask;
|
||||
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
||||
import org.jackhuang.hellominecraft.util.system.Compressor;
|
||||
import org.jackhuang.hellominecraft.util.system.CompressingUtils;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
|
||||
public class DefaultGameLauncher extends GameLauncher {
|
||||
@@ -51,8 +51,8 @@ public class DefaultGameLauncher extends GameLauncher {
|
||||
dw.append(parallelTask);
|
||||
boolean flag = true;
|
||||
if (t.size() > 0)
|
||||
flag = dw.create();
|
||||
if (!flag && MessageBox.Show(C.i18n("launch.not_finished_downloading_libraries"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
flag = dw.execute();
|
||||
if (!flag && MessageBox.show(C.i18n("launch.not_finished_downloading_libraries"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
flag = true;
|
||||
return flag;
|
||||
});
|
||||
@@ -61,7 +61,7 @@ public class DefaultGameLauncher extends GameLauncher {
|
||||
return false;
|
||||
for (int i = 0; i < value.decompressFiles.length; i++)
|
||||
try {
|
||||
Compressor.unzip(value.decompressFiles[i], value.getDecompressTo(), value.extractRules[i]::allow, false);
|
||||
CompressingUtils.unzip(value.decompressFiles[i], value.getDecompressTo(), value.extractRules[i]::allow, false);
|
||||
} catch (IOException ex) {
|
||||
HMCLog.err("Unable to decompress library: " + value.decompressFiles[i] + " to " + value.getDecompressTo(), ex);
|
||||
}
|
||||
|
||||
@@ -17,32 +17,32 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.core.launch;
|
||||
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftLoader;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.api.PluginManager;
|
||||
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.AuthenticationException;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.LoginInfo;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.AuthenticationException;
|
||||
import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftLoader;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.DecompressLibraryJob;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.EventHandler;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.JavaProcess;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.system.OS;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.EventHandler;
|
||||
import org.jackhuang.hellominecraft.util.system.ProcessManager;
|
||||
|
||||
public class GameLauncher {
|
||||
@@ -117,7 +117,6 @@ public class GameLauncher {
|
||||
* Launch the game "as soon as possible".
|
||||
*
|
||||
* @param str launch command
|
||||
*
|
||||
* @throws IOException failed creating process
|
||||
*/
|
||||
public void launch(List<String> str) throws IOException {
|
||||
@@ -138,7 +137,7 @@ public class GameLauncher {
|
||||
if (options.getLaunchVersion() == null || service.baseDirectory() == null)
|
||||
throw new Error("Fucking bug!");
|
||||
builder.redirectErrorStream(true).directory(service.version().getRunDirectory(options.getLaunchVersion()))
|
||||
.environment().put("APPDATA", service.baseDirectory().getAbsolutePath());
|
||||
.environment().put("APPDATA", service.baseDirectory().getAbsolutePath());
|
||||
JavaProcess jp = new JavaProcess(str, builder.start(), PROCESS_MANAGER);
|
||||
HMCLog.log("Have started the process");
|
||||
launchEvent.execute(jp);
|
||||
@@ -148,7 +147,7 @@ public class GameLauncher {
|
||||
* According to the name...
|
||||
*
|
||||
* @param launcherName the name of launch bat/sh
|
||||
* @param str launch command
|
||||
* @param str launch command
|
||||
*
|
||||
* @return launcher location
|
||||
*
|
||||
@@ -162,33 +161,33 @@ public class GameLauncher {
|
||||
if (!f.exists() && !f.createNewFile())
|
||||
HMCLog.warn("Failed to create " + f);
|
||||
BufferedWriter writer;
|
||||
try {
|
||||
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), System.getProperty("sun.jnu.encoding", "UTF-8")));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
HMCLog.warn("Failed to create writer, will try again.", ex);
|
||||
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f)));
|
||||
}
|
||||
if (isWin) {
|
||||
writer.write("@echo off");
|
||||
writer.newLine();
|
||||
String appdata = IOUtils.tryGetCanonicalFilePath(service.baseDirectory());
|
||||
if (appdata != null) {
|
||||
writer.write("set appdata=" + appdata);
|
||||
try (FileOutputStream fos = new FileOutputStream(f)) {
|
||||
try {
|
||||
writer = new BufferedWriter(new OutputStreamWriter(fos, System.getProperty("sun.jnu.encoding", "UTF-8")));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
HMCLog.warn("Failed to create writer, will try again.", ex);
|
||||
writer = new BufferedWriter(new OutputStreamWriter(fos, Charset.defaultCharset()));
|
||||
}
|
||||
if (isWin) {
|
||||
writer.write("@echo off");
|
||||
writer.newLine();
|
||||
writer.write("cd /D %appdata%");
|
||||
String appdata = IOUtils.tryGetCanonicalFilePath(service.baseDirectory());
|
||||
if (appdata != null) {
|
||||
writer.write("set appdata=" + appdata);
|
||||
writer.newLine();
|
||||
writer.write("cd /D %appdata%");
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
if (StrUtils.isNotBlank(options.getPrecalledCommand())) {
|
||||
writer.write(options.getPrecalledCommand());
|
||||
writer.newLine();
|
||||
}
|
||||
writer.write(StrUtils.makeCommand(str));
|
||||
writer.close();
|
||||
}
|
||||
if (StrUtils.isNotBlank(options.getPrecalledCommand())) {
|
||||
writer.write(options.getPrecalledCommand());
|
||||
writer.newLine();
|
||||
}
|
||||
writer.write(StrUtils.makeCommand(str));
|
||||
writer.close();
|
||||
if (!f.setExecutable(true)) {
|
||||
HMCLog.warn("Failed to give launcher permission.");
|
||||
MessageBox.Show(C.i18n("launch.failed_sh_permission"));
|
||||
}
|
||||
if (!f.setExecutable(true))
|
||||
throw new IOException(C.i18n("launch.failed_sh_permission"));
|
||||
|
||||
HMCLog.log("Command: " + StrUtils.parseParams("", str, " "));
|
||||
return f;
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.core.launch;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob;
|
||||
import org.jackhuang.hellominecraft.util.tasks.download.FileDownloadTask;
|
||||
@@ -32,32 +30,10 @@ public class LibraryDownloadTask extends FileDownloadTask {
|
||||
DownloadLibraryJob job;
|
||||
|
||||
public LibraryDownloadTask(DownloadLibraryJob job) {
|
||||
super();
|
||||
super(job.parse().url, job.path);
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Throwable {
|
||||
String name = job.lib.name;
|
||||
if (name.startsWith("net.minecraftforge:forge:")) {
|
||||
String[] s = name.split(":");
|
||||
if (s.length == 3)
|
||||
job.url = "http://files.minecraftforge.net/maven/net/minecraftforge/forge/" + s[2] + "/forge-" + s[2] + "-universal.jar";
|
||||
}
|
||||
if (name.startsWith("com.mumfrey:liteloader:")) {
|
||||
String[] s = name.split(":");
|
||||
if (s.length == 3 && s[2].length() > 3)
|
||||
job.url = "http://dl.liteloader.com/versions/com/mumfrey/liteloader/" + s[2].substring(0, s[2].length() - 3) + "/liteloader-" + s[2] + ".jar";
|
||||
}
|
||||
download(new URL(job.url), job.path);
|
||||
}
|
||||
|
||||
void download(URL url, File filePath) throws Throwable {
|
||||
this.url = url;
|
||||
this.filePath = filePath;
|
||||
super.executeTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfo() {
|
||||
return C.i18n("download") + ": " + job.lib.name;
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
@@ -48,7 +49,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
ArrayList<MinecraftLibrary> opt = new ArrayList<>();
|
||||
for (MinecraftLibrary l : version.libraries)
|
||||
if (l.allow() && !l.isRequiredToUnzip()) {
|
||||
if (l.name.toLowerCase().contains("optifine")) {
|
||||
if (l.name.toLowerCase(Locale.US).contains("optifine")) {
|
||||
opt.add(l);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,15 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.core.mod;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
@@ -60,6 +62,8 @@ public class ModInfo implements Comparable<ModInfo> {
|
||||
public String credits;
|
||||
@SerializedName("authorList")
|
||||
public String[] authorList;
|
||||
@SerializedName("authors")
|
||||
public String[] authors;
|
||||
|
||||
public boolean isActive() {
|
||||
return !location.getName().endsWith(".disabled");
|
||||
@@ -87,6 +91,8 @@ public class ModInfo implements Comparable<ModInfo> {
|
||||
public String getAuthor() {
|
||||
if (authorList != null && authorList.length > 0)
|
||||
return StrUtils.parseParams("", authorList, ", ");
|
||||
else if (authors != null && authors.length > 0)
|
||||
return StrUtils.parseParams("", authors, ", ");
|
||||
else if (StrUtils.isNotBlank(author))
|
||||
return author;
|
||||
else
|
||||
@@ -123,17 +129,30 @@ public class ModInfo implements Comparable<ModInfo> {
|
||||
return name.endsWith(".zip") || name.endsWith(".jar") || name.endsWith("litemod");
|
||||
}
|
||||
|
||||
private static final Type TYPE = new TypeToken<List<ModInfo>>() {
|
||||
}.getType();
|
||||
|
||||
private static ModInfo getForgeModInfo(File f, ZipFile jar, ZipEntry entry) throws IOException {
|
||||
private static ModInfo getForgeModInfo(File f, ZipFile jar, ZipEntry entry) throws IOException, JsonSyntaxException {
|
||||
ModInfo i = new ModInfo();
|
||||
i.location = f;
|
||||
List<ModInfo> m = C.GSON.fromJson(new InputStreamReader(jar.getInputStream(entry), "UTF-8"), TYPE);
|
||||
|
||||
InputStreamReader streamReader = new InputStreamReader(jar.getInputStream(entry), "UTF-8");
|
||||
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonElement element = parser.parse(streamReader);
|
||||
List<ModInfo> m = null;
|
||||
if (element.isJsonArray())
|
||||
m = C.GSON.fromJson(element, new TypeToken<List<ModInfo>>() {
|
||||
}.getType());
|
||||
else if (element.isJsonObject()) {
|
||||
JsonObject modInfo = element.getAsJsonObject();
|
||||
if (modInfo.has("modList") && modInfo.get("modList").isJsonArray())
|
||||
m = C.GSON.fromJson(modInfo.get("modList"), new TypeToken<List<ModInfo>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
if (m != null && m.size() > 0) {
|
||||
i = m.get(0);
|
||||
i.location = f;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||
import org.jackhuang.hellominecraft.util.func.BiFunction;
|
||||
import org.jackhuang.hellominecraft.util.func.CallbackIO;
|
||||
import org.jackhuang.hellominecraft.util.system.Compressor;
|
||||
import org.jackhuang.hellominecraft.util.system.CompressingUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.ZipEngine;
|
||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||
@@ -86,7 +86,7 @@ public final class ModpackManager {
|
||||
Collection<Task> c = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Throwable {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Throwable {
|
||||
String id = idFUCK;
|
||||
String description = C.i18n("modpack.task.install.will");
|
||||
|
||||
@@ -150,7 +150,7 @@ public final class ModpackManager {
|
||||
try {
|
||||
final AtomicInteger b = new AtomicInteger(0);
|
||||
HMCLog.log("Decompressing modpack");
|
||||
Compressor.unzip(input, versions, t -> {
|
||||
CompressingUtils.unzip(input, versions, t -> {
|
||||
if (t.equals("minecraft/pack.json"))
|
||||
b.incrementAndGet();
|
||||
return true;
|
||||
@@ -186,8 +186,8 @@ public final class ModpackManager {
|
||||
}
|
||||
} finally {
|
||||
FileUtils.deleteDirectoryQuietly(oldFile);
|
||||
if (newFile != null)
|
||||
newFile.renameTo(oldFile);
|
||||
if (newFile != null && !newFile.renameTo(oldFile))
|
||||
HMCLog.warn("Failed to restore version minecraft");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,12 +79,12 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
|
||||
private String getNative() {
|
||||
switch (OS.os()) {
|
||||
case WINDOWS:
|
||||
return formatArch(natives.windows);
|
||||
case OSX:
|
||||
return formatArch(natives.osx);
|
||||
default:
|
||||
return formatArch(natives.linux);
|
||||
case WINDOWS:
|
||||
return formatArch(natives.windows);
|
||||
case OSX:
|
||||
return formatArch(natives.osx);
|
||||
default:
|
||||
return formatArch(natives.linux);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
return extract == null ? new Extract() : extract;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibraryDownloadInfo getDownloadInfo() {
|
||||
if (downloads == null)
|
||||
downloads = new LibrariesDownloadInfo();
|
||||
@@ -125,12 +126,15 @@ public class MinecraftLibrary extends IMinecraftLibrary {
|
||||
downloads.classifiers = new HashMap<>();
|
||||
if (!downloads.classifiers.containsKey(getNative()))
|
||||
downloads.classifiers.put(getNative(), info = new LibraryDownloadInfo());
|
||||
else
|
||||
else {
|
||||
info = downloads.classifiers.get(getNative());
|
||||
} else if (downloads.artifact == null)
|
||||
downloads.artifact = info = new LibraryDownloadInfo();
|
||||
else
|
||||
if (info == null) info = new LibraryDownloadInfo();
|
||||
}
|
||||
} else {
|
||||
if (downloads.artifact == null)
|
||||
downloads.artifact = new LibraryDownloadInfo();
|
||||
info = downloads.artifact;
|
||||
}
|
||||
if (StrUtils.isBlank(info.path)) {
|
||||
info.path = formatName();
|
||||
if (info.path == null)
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.launcher.core.GameException;
|
||||
@@ -176,9 +177,27 @@ public class MinecraftVersion implements Cloneable, Comparable<MinecraftVersion>
|
||||
return id.compareTo(o.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 53 * hash + Objects.hashCode(this.id);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
return Objects.equals(this.id, ((MinecraftVersion) obj).id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public AssetIndexDownloadInfo getAssetsIndex() {
|
||||
if (assetIndex == null)
|
||||
assetIndex = new AssetIndexDownloadInfo((String) Utils.firstNonNull(assets, AssetsIndex.DEFAULT_ASSET_NAME));
|
||||
assetIndex = new AssetIndexDownloadInfo(assets == null ? AssetsIndex.DEFAULT_ASSET_NAME : assets);
|
||||
return assetIndex;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,12 +100,12 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
}
|
||||
if (ask) {
|
||||
HMCLog.warn("Found not matched filenames version: " + id + ", json: " + jsons[0].getName());
|
||||
if (MessageBox.Show(String.format(C.i18n("launcher.versions_json_not_matched"), id, jsons[0].getName()), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
if (MessageBox.show(String.format(C.i18n("launcher.versions_json_not_matched"), id, jsons[0].getName()), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
if (!jsons[0].renameTo(new File(jsons[0].getParent(), id + ".json")))
|
||||
HMCLog.warn("Failed to rename version json " + jsons[0]);
|
||||
}
|
||||
if (!jsonFile.exists()) {
|
||||
if (MessageBox.Show(C.i18n("launcher.versions_json_not_matched_cannot_auto_completion", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
if (MessageBox.show(C.i18n("launcher.versions_json_not_matched_cannot_auto_completion", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
FileUtils.deleteDirectoryQuietly(dir);
|
||||
continue;
|
||||
}
|
||||
@@ -114,9 +114,9 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
mcVersion = C.GSON.fromJson(FileUtils.read(jsonFile), MinecraftVersion.class);
|
||||
if (mcVersion == null)
|
||||
throw new GameException("Wrong json format, got null.");
|
||||
} catch (Exception e) {
|
||||
} catch (JsonSyntaxException | IOException | GameException e) {
|
||||
HMCLog.warn("Found wrong format json, try to fix it.", e);
|
||||
if (MessageBox.Show(C.i18n("launcher.versions_json_not_formatted", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||
if (MessageBox.show(C.i18n("launcher.versions_json_not_formatted", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||
service.download().downloadMinecraftVersionJson(id);
|
||||
try {
|
||||
mcVersion = C.GSON.fromJson(FileUtils.read(jsonFile), MinecraftVersion.class);
|
||||
@@ -194,7 +194,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public boolean install(String id, Consumer<MinecraftVersion> callback) {
|
||||
if (!TaskWindow.factory().append(service.download().downloadMinecraft(id)).create())
|
||||
if (!TaskWindow.factory().append(service.download().downloadMinecraft(id)).execute())
|
||||
return false;
|
||||
if (callback != null) {
|
||||
File mvt = new File(versionRoot(id), id + ".json");
|
||||
@@ -278,6 +278,5 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public void initializeMiencraft() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Rules {
|
||||
}
|
||||
|
||||
public String action() {
|
||||
return os == null || os != null && os.isCurrentOS() ? action : null;
|
||||
return os == null || os.isCurrentOS() ? action : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.RepaintManager;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
@@ -46,6 +47,7 @@ import org.jackhuang.hellominecraft.util.ui.LogWindow;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||
import org.jackhuang.hellominecraft.launcher.util.upgrade.IUpgrader;
|
||||
import org.jackhuang.hellominecraft.launcher.ui.MainFrame;
|
||||
import org.jackhuang.hellominecraft.launcher.ui.MyRepaintManager;
|
||||
import org.jackhuang.hellominecraft.launcher.util.DefaultPlugin;
|
||||
import org.jackhuang.hellominecraft.lookandfeel.HelloMinecraftLookAndFeel;
|
||||
import org.jackhuang.hellominecraft.util.MathUtils;
|
||||
@@ -153,6 +155,7 @@ public final class Main implements Runnable {
|
||||
try {
|
||||
LOOK_AND_FEEL = new HelloMinecraftLookAndFeel(Settings.getInstance().getTheme().settings);
|
||||
UIManager.setLookAndFeel(LOOK_AND_FEEL);
|
||||
RepaintManager.setCurrentManager(new MyRepaintManager());
|
||||
} catch (ParseException | UnsupportedLookAndFeelException ex) {
|
||||
HMCLog.warn("Failed to set look and feel...", ex);
|
||||
}
|
||||
|
||||
@@ -55,8 +55,6 @@ public final class Config implements Cloneable {
|
||||
private boolean enableShadow;
|
||||
@SerializedName("decorated")
|
||||
private boolean decorated;
|
||||
@SerializedName("enableAnimation")
|
||||
private boolean enableAnimation;
|
||||
@SerializedName("theme")
|
||||
private int theme;
|
||||
@SerializedName("java")
|
||||
@@ -131,15 +129,6 @@ public final class Config implements Cloneable {
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public boolean isEnableAnimation() {
|
||||
return enableAnimation;
|
||||
}
|
||||
|
||||
public void setEnableAnimation(boolean enableAnimation) {
|
||||
this.enableAnimation = enableAnimation;
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
public String getClientToken() {
|
||||
return clientToken;
|
||||
}
|
||||
@@ -195,7 +184,6 @@ public final class Config implements Cloneable {
|
||||
clientToken = UUID.randomUUID().toString();
|
||||
logintype = downloadtype = 0;
|
||||
enableShadow = false;
|
||||
enableAnimation = true;
|
||||
theme = 4;
|
||||
decorated = OS.os() == OS.LINUX;
|
||||
auth = new HashMap<>();
|
||||
|
||||
@@ -151,7 +151,7 @@ public final class Settings {
|
||||
|
||||
public static boolean delProfile(String ver) {
|
||||
if (DEFAULT_PROFILE.equals(ver)) {
|
||||
MessageBox.Show(C.i18n("settings.cannot_remove_default_config"));
|
||||
MessageBox.show(C.i18n("settings.cannot_remove_default_config"));
|
||||
return false;
|
||||
}
|
||||
boolean notify = false;
|
||||
|
||||
@@ -27,10 +27,10 @@ import org.jackhuang.hellominecraft.launcher.core.version.GameDirType;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.EventHandler;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.Utils;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.system.Java;
|
||||
import org.jackhuang.hellominecraft.util.system.JdkVersion;
|
||||
import org.jackhuang.hellominecraft.util.system.OS;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -179,7 +179,7 @@ public class VersionSetting {
|
||||
|
||||
public String getMaxMemory() {
|
||||
if (StrUtils.isBlank(maxMemory))
|
||||
return String.valueOf(Utils.getSuggestedMemorySize());
|
||||
return String.valueOf(OS.getSuggestedMemorySize());
|
||||
return maxMemory;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* 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.launcher.ui;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class AnimatedPanel extends JPanel implements Selectable {
|
||||
|
||||
private static final int ANIMATION_LENGTH = 10;
|
||||
|
||||
public AnimatedPanel() {
|
||||
timer = new Timer(1, (e) -> {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
AnimatedPanel.this.repaint();
|
||||
offsetX += 0.15;
|
||||
if (offsetX >= ANIMATION_LENGTH) {
|
||||
timer.stop();
|
||||
AnimatedPanel.this.repaint();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
double offsetX = ANIMATION_LENGTH;
|
||||
|
||||
Timer timer;
|
||||
|
||||
boolean animationEnabled = true;
|
||||
|
||||
public void animate() {
|
||||
if (Settings.getInstance().isEnableAnimation() && animationEnabled) {
|
||||
offsetX = 0;
|
||||
timer.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
if (!(g instanceof Graphics2D)) {
|
||||
super.paint(g);
|
||||
return;
|
||||
}
|
||||
double pgs = 1 - Math.sin(Math.PI / 2 / ANIMATION_LENGTH * offsetX);
|
||||
if (Math.abs(ANIMATION_LENGTH - offsetX) < 0.1) {
|
||||
super.paint(g);
|
||||
return;
|
||||
}
|
||||
if (pgs > 1)
|
||||
pgs = 1;
|
||||
if (pgs < 0)
|
||||
pgs = 0;
|
||||
Graphics2D gg = (Graphics2D) g;
|
||||
int width = this.getWidth();
|
||||
int height = this.getHeight();
|
||||
if (isOpaque()) {
|
||||
g.setColor(getBackground());
|
||||
g.fillRect(0, 0, width, height);
|
||||
}
|
||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = image.createGraphics();
|
||||
g2d.translate((int) (pgs * 50), 0);
|
||||
super.paint(g2d);
|
||||
g2d.dispose();
|
||||
gg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) (1 - pgs)));
|
||||
g.drawImage(image, 0, 0, this);
|
||||
}
|
||||
|
||||
boolean selected = false;
|
||||
|
||||
@Override
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelect() {
|
||||
if (!selected)
|
||||
animate();
|
||||
selected = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeave() {
|
||||
selected = false;
|
||||
}
|
||||
|
||||
boolean created = false;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
created = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.jackhuang.hellominecraft.launcher.ui;
|
||||
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
||||
import org.jackhuang.hellominecraft.launcher.core.download.MinecraftRemoteVersions;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
@@ -31,7 +30,7 @@ import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class GameDownloadPanel extends AnimatedPanel {
|
||||
public class GameDownloadPanel extends Page {
|
||||
|
||||
GameSettingsPanel gsp;
|
||||
|
||||
@@ -116,11 +115,11 @@ public class GameDownloadPanel extends AnimatedPanel {
|
||||
|
||||
void downloadMinecraft() {
|
||||
if (lstDownloads.getSelectedRow() < 0) {
|
||||
MessageBox.Show(C.i18n("gamedownload.not_refreshed"));
|
||||
MessageBox.show(C.i18n("gamedownload.not_refreshed"));
|
||||
return;
|
||||
}
|
||||
String id = (String) lstDownloads.getModel().getValueAt(lstDownloads.getSelectedRow(), 0);
|
||||
TaskWindow.execute(Settings.getLastProfile().service().download().downloadMinecraft(id));
|
||||
TaskWindow.factory().execute(Settings.getLastProfile().service().download().downloadMinecraft(id));
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
||||
@@ -85,9 +85,6 @@
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="pnlSettings">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new AnimatedPanel()"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="<settings>">
|
||||
@@ -372,9 +369,6 @@
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="pnlAdvancedSettings">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new AnimatedPanel()"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="<advancedsettings>">
|
||||
@@ -566,9 +560,6 @@
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="pnlModManagement">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new AnimatedPanel()"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="<mods>">
|
||||
@@ -694,9 +685,6 @@
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="pnlAutoInstall">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new AnimatedPanel()"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
|
||||
<JTabbedPaneConstraints tabName="<settings.tabs.installers>">
|
||||
@@ -788,7 +776,7 @@
|
||||
<Component id="cboVersions" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Component id="lblVersions" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<EmptySpace pref="11" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.dnd.DropTarget;
|
||||
import java.awt.dnd.DropTargetDragEvent;
|
||||
@@ -34,7 +34,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
@@ -64,13 +63,15 @@ import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.Java;
|
||||
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
||||
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.JSystemFileChooser;
|
||||
import org.jackhuang.hellominecraft.util.ui.LogWindow;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class GameSettingsPanel extends AnimatedPanel implements DropTargetListener {
|
||||
public final class GameSettingsPanel extends RepaintPage implements DropTargetListener {
|
||||
|
||||
boolean isLoading = false;
|
||||
public MinecraftVersionRequest minecraftVersion;
|
||||
@@ -78,19 +79,18 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
|
||||
final InstallerPanel installerPanels[] = new InstallerPanel[InstallerType.values().length];
|
||||
|
||||
/**
|
||||
* Creates new form GameSettingsPanel
|
||||
*/
|
||||
public GameSettingsPanel(MainFrame mf) {
|
||||
mf.actions.put("showGameDownloads", () -> {
|
||||
MainFrame.INSTANCE.selectTab("game");
|
||||
showGameDownloads();
|
||||
});
|
||||
MainFrame.INSTANCE.selectTab("game");
|
||||
showGameDownloads();
|
||||
});
|
||||
|
||||
setRepainter(this);
|
||||
}
|
||||
|
||||
void initGui() {
|
||||
initComponents();
|
||||
setBackground(Color.white);
|
||||
setBackground(GraphicsUtils.getWebColorWithAlpha("FFFFFF7F"));
|
||||
setOpaque(true);
|
||||
|
||||
for (int i = 0; i < InstallerType.values().length; i++)
|
||||
@@ -111,6 +111,13 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
Settings.profileChangedEvent.register(onSelectedProfilesChanged);
|
||||
|
||||
dropTarget = new DropTarget(lstExternalMods, DnDConstants.ACTION_COPY_OR_MOVE, this);
|
||||
|
||||
/*AeroPage pnlAero = new AeroPage();
|
||||
pnlAero.setBounds(0, 0, 800, 480);
|
||||
pnlAero.setLayout(null);
|
||||
pnlAero.addAeroObject(jPanel1);
|
||||
pnlAero.setBackgroundImage(MainFrame.INSTANCE.background.getImage());
|
||||
add(jPanel1);*/
|
||||
}
|
||||
|
||||
void initExplorationMenu() {
|
||||
@@ -163,7 +170,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
ppmManage.add(itm);
|
||||
itm = new JMenuItem(C.i18n("versions.manage.remove"));
|
||||
itm.addActionListener((e) -> {
|
||||
if (mcVersion != null && MessageBox.Show(C.i18n("versions.manage.remove.confirm") + mcVersion, MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
if (mcVersion != null && MessageBox.show(C.i18n("versions.manage.remove.confirm") + mcVersion, MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
if (Settings.getLastProfile().service().version().removeVersionFromDisk(mcVersion))
|
||||
refreshVersions();
|
||||
});
|
||||
@@ -231,7 +238,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
if (tabVersionEdit.getSelectedComponent() == pnlAutoInstall && !b) {
|
||||
b = true;
|
||||
installerPanels[0].refreshVersions();
|
||||
TaskWindow.factory().execute(installerPanels[0].refreshVersionsTask());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -255,7 +262,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
|
||||
tabVersionEdit = new NewTabPane();
|
||||
((NewTabPane)tabVersionEdit).initializing = true;
|
||||
pnlSettings = new AnimatedPanel();
|
||||
pnlSettings = new javax.swing.JPanel();
|
||||
lblGameDir = new javax.swing.JLabel();
|
||||
txtGameDir = new javax.swing.JTextField();
|
||||
lblDimension = new javax.swing.JLabel();
|
||||
@@ -277,7 +284,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
cboJava = new javax.swing.JComboBox();
|
||||
btnChoosingGameDir = new javax.swing.JButton();
|
||||
btnCleanGame = new javax.swing.JButton();
|
||||
pnlAdvancedSettings = new AnimatedPanel();
|
||||
pnlAdvancedSettings = new javax.swing.JPanel();
|
||||
lblJavaArgs = new javax.swing.JLabel();
|
||||
txtJavaArgs = new javax.swing.JTextField();
|
||||
txtMinecraftArgs = new javax.swing.JTextField();
|
||||
@@ -292,14 +299,14 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
lblPrecalledCommand1 = new javax.swing.JLabel();
|
||||
txtWrapperLauncher = new javax.swing.JTextField();
|
||||
chkDontCheckGame = new javax.swing.JCheckBox();
|
||||
pnlModManagement = new AnimatedPanel();
|
||||
pnlModManagement = new javax.swing.JPanel();
|
||||
pnlModManagementContent = new javax.swing.JPanel();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
lstExternalMods = new javax.swing.JTable();
|
||||
btnAddMod = new javax.swing.JButton();
|
||||
btnRemoveMod = new javax.swing.JButton();
|
||||
lblModInfo = new javax.swing.JLabel();
|
||||
pnlAutoInstall = new AnimatedPanel();
|
||||
pnlAutoInstall = new javax.swing.JPanel();
|
||||
tabInstallers = new NewTabPane();
|
||||
pnlTop = new javax.swing.JPanel();
|
||||
pnlSelection = new javax.swing.JPanel();
|
||||
@@ -599,9 +606,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtWrapperLauncher)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addComponent(lblPrecalledCommand1)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(chkNoJVMArgs)
|
||||
@@ -609,6 +613,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
.addComponent(chkDontCheckGame))
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblPrecalledCommand1)
|
||||
.addComponent(lblPrecalledCommand)
|
||||
.addComponent(lblServerIP))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
@@ -780,7 +785,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
.addGroup(pnlSelectionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(cboVersions, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblVersions))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap(11, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
btnModify.setText(C.i18n("settings.manage")); // NOI18N
|
||||
@@ -946,22 +951,58 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
|
||||
((NewTabPane)tabVersionEdit).initializing = false;
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// <editor-fold defaultstate="collapsed" desc="UI Events">
|
||||
private void cboProfilesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboProfilesItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getInstance().setLast((String) cboProfiles.getSelectedItem());
|
||||
}//GEN-LAST:event_cboProfilesItemStateChanged
|
||||
|
||||
private void btnIncludeMinecraftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIncludeMinecraftActionPerformed
|
||||
JSystemFileChooser fc = new JSystemFileChooser(new File("."));
|
||||
fc.setFileSelectionMode(JSystemFileChooser.DIRECTORIES_ONLY);
|
||||
if (fc.showOpenDialog(this) == JSystemFileChooser.APPROVE_OPTION) {
|
||||
File newGameDir = fc.getSelectedFile();
|
||||
String name = JOptionPane.showInputDialog(C.i18n("setupwindow.give_a_name"));
|
||||
if (StrUtils.isBlank(name)) {
|
||||
MessageBox.show(C.i18n("setupwindow.no_empty_name"));
|
||||
return;
|
||||
}
|
||||
Settings.putProfile(new Profile(name).setGameDir(newGameDir.getAbsolutePath()));
|
||||
MessageBox.show(C.i18n("setupwindow.find_in_configurations"));
|
||||
loadProfiles();
|
||||
}
|
||||
}//GEN-LAST:event_btnIncludeMinecraftActionPerformed
|
||||
|
||||
private void btnMakeLaunchScriptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMakeLaunchScriptActionPerformed
|
||||
MainFrame.INSTANCE.daemon.makeLaunchScript(Settings.getLastProfile());
|
||||
}//GEN-LAST:event_btnMakeLaunchScriptActionPerformed
|
||||
|
||||
private void btnShowLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnShowLogActionPerformed
|
||||
LogWindow.INSTANCE.setVisible(true);
|
||||
}//GEN-LAST:event_btnShowLogActionPerformed
|
||||
|
||||
private void btnTestGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTestGameActionPerformed
|
||||
LogWindow.INSTANCE.setVisible(true);
|
||||
MainFrame.INSTANCE.daemon.runGame(Settings.getLastProfile());
|
||||
}//GEN-LAST:event_btnTestGameActionPerformed
|
||||
|
||||
private void btnExploreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnExploreMouseClicked
|
||||
ppmExplore.show(evt.getComponent(), evt.getPoint().x, evt.getPoint().y);
|
||||
}//GEN-LAST:event_btnExploreMouseClicked
|
||||
|
||||
private void btnRemoveProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveProfileActionPerformed
|
||||
if (MessageBox.show(C.i18n("ui.message.sure_remove", Settings.getLastProfile().getName()), MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION)
|
||||
return;
|
||||
Settings.delProfile(Settings.getLastProfile());
|
||||
}//GEN-LAST:event_btnRemoveProfileActionPerformed
|
||||
|
||||
private void btnNewProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewProfileActionPerformed
|
||||
new NewProfileWindow(null).setVisible(true);
|
||||
loadProfiles();
|
||||
}//GEN-LAST:event_btnNewProfileActionPerformed
|
||||
|
||||
private void btnRemoveProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveProfileActionPerformed
|
||||
if (MessageBox.Show(C.i18n("ui.message.sure_remove", Settings.getLastProfile().getName()), MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION)
|
||||
return;
|
||||
Settings.delProfile(Settings.getLastProfile());
|
||||
}//GEN-LAST:event_btnRemoveProfileActionPerformed
|
||||
private void btnRefreshVersionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshVersionsActionPerformed
|
||||
refreshVersions();
|
||||
}//GEN-LAST:event_btnRefreshVersionsActionPerformed
|
||||
|
||||
private void btnModifyMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnModifyMouseClicked
|
||||
ppmManage.show(evt.getComponent(), evt.getPoint().x, evt.getPoint().y);
|
||||
}//GEN-LAST:event_btnModifyMouseClicked
|
||||
|
||||
private void cboVersionsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboVersionsItemStateChanged
|
||||
if (isLoading || evt.getStateChange() != ItemEvent.SELECTED || cboVersions.getSelectedIndex() < 0 || StrUtils.isBlank((String) cboVersions.getSelectedItem()))
|
||||
@@ -969,50 +1010,98 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
Settings.getLastProfile().setSelectedMinecraftVersion((String) cboVersions.getSelectedItem());
|
||||
}//GEN-LAST:event_cboVersionsItemStateChanged
|
||||
|
||||
private void btnRefreshVersionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshVersionsActionPerformed
|
||||
refreshVersions();
|
||||
}//GEN-LAST:event_btnRefreshVersionsActionPerformed
|
||||
// <editor-fold defaultstate="collapsed" desc="UI Events">
|
||||
private void cboProfilesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboProfilesItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getInstance().setLast((String) cboProfiles.getSelectedItem());
|
||||
}//GEN-LAST:event_cboProfilesItemStateChanged
|
||||
|
||||
private void btnExploreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnExploreMouseClicked
|
||||
ppmExplore.show(evt.getComponent(), evt.getPoint().x, evt.getPoint().y);
|
||||
}//GEN-LAST:event_btnExploreMouseClicked
|
||||
private void lblModInfoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblModInfoMouseClicked
|
||||
int idx = lstExternalMods.getSelectedRow();
|
||||
if (idx > 0 && idx < Settings.getLastProfile().service().mod().getMods(Settings.getLastProfile().getSelectedVersion()).size())
|
||||
SwingUtils.openLink(Settings.getLastProfile().service().mod().getMods(Settings.getLastProfile().getSelectedVersion()).get(idx).url);
|
||||
}//GEN-LAST:event_lblModInfoMouseClicked
|
||||
|
||||
private void btnModifyMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnModifyMouseClicked
|
||||
ppmManage.show(evt.getComponent(), evt.getPoint().x, evt.getPoint().y);
|
||||
}//GEN-LAST:event_btnModifyMouseClicked
|
||||
private void btnRemoveModActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveModActionPerformed
|
||||
Settings.getLastProfile().service().mod().removeMod(Settings.getLastProfile().getSelectedVersion(), SwingUtils.getValueBySelectedRow(lstExternalMods, lstExternalMods.getSelectedRows(), 1));
|
||||
reloadMods();
|
||||
}//GEN-LAST:event_btnRemoveModActionPerformed
|
||||
|
||||
private void btnDownloadAllAssetsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadAllAssetsActionPerformed
|
||||
if (mcVersion != null)
|
||||
TaskWindow.execute(Settings.getLastProfile().service().asset().downloadAssets(mcVersion));
|
||||
}//GEN-LAST:event_btnDownloadAllAssetsActionPerformed
|
||||
|
||||
private void txtGameDirFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtGameDirFocusLost
|
||||
Settings.getLastProfile().setGameDir(txtGameDir.getText());
|
||||
loadVersions();
|
||||
}//GEN-LAST:event_txtGameDirFocusLost
|
||||
|
||||
private void btnChoosingJavaDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChoosingJavaDirActionPerformed
|
||||
if (cboJava.getSelectedIndex() != 1)
|
||||
private void btnAddModActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddModActionPerformed
|
||||
JSystemFileChooser fc = new JSystemFileChooser();
|
||||
fc.setFileSelectionMode(JSystemFileChooser.FILES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("mods.choose_mod"));
|
||||
fc.setMultiSelectionEnabled(true);
|
||||
if (fc.showOpenDialog(this) != JSystemFileChooser.APPROVE_OPTION)
|
||||
return;
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("settings.choose_javapath"));
|
||||
boolean flag = true;
|
||||
for (File f : fc.getSelectedFiles())
|
||||
flag &= Settings.getLastProfile().service().mod().addMod(Settings.getLastProfile().getSelectedVersion(), f);
|
||||
reloadMods();
|
||||
if (!flag)
|
||||
MessageBox.show(C.i18n("mods.failed"));
|
||||
}//GEN-LAST:event_btnAddModActionPerformed
|
||||
|
||||
private void lstExternalModsKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lstExternalModsKeyPressed
|
||||
if (evt.getKeyCode() == KeyEvent.VK_DELETE)
|
||||
btnRemoveModActionPerformed(null);
|
||||
}//GEN-LAST:event_lstExternalModsKeyPressed
|
||||
|
||||
private void chkDontCheckGameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkDontCheckGameItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setNotCheckGame(chkDontCheckGame.isSelected());
|
||||
}//GEN-LAST:event_chkDontCheckGameItemStateChanged
|
||||
|
||||
private void txtWrapperLauncherFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtWrapperLauncherFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setWrapper(txtWrapperLauncher.getText());
|
||||
}//GEN-LAST:event_txtWrapperLauncherFocusLost
|
||||
|
||||
private void txtServerIPFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtServerIPFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setServerIp(txtServerIP.getText());
|
||||
}//GEN-LAST:event_txtServerIPFocusLost
|
||||
|
||||
private void txtPrecalledCommandFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPrecalledCommandFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setPrecalledCommand(txtPrecalledCommand.getText());
|
||||
}//GEN-LAST:event_txtPrecalledCommandFocusLost
|
||||
|
||||
private void chkNoJVMArgsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkNoJVMArgsItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setNoJVMArgs(chkNoJVMArgs.isSelected());
|
||||
}//GEN-LAST:event_chkNoJVMArgsItemStateChanged
|
||||
|
||||
private void txtPermSizeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPermSizeFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setPermSize(txtPermSize.getText());
|
||||
}//GEN-LAST:event_txtPermSizeFocusLost
|
||||
|
||||
private void txtMinecraftArgsFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtMinecraftArgsFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setMinecraftArgs(txtMinecraftArgs.getText());
|
||||
}//GEN-LAST:event_txtMinecraftArgsFocusLost
|
||||
|
||||
private void txtJavaArgsFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtJavaArgsFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setJavaArgs(txtJavaArgs.getText());
|
||||
}//GEN-LAST:event_txtJavaArgsFocusLost
|
||||
|
||||
private void btnCleanGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCleanGameActionPerformed
|
||||
Settings.getLastProfile().service().version().cleanFolder();
|
||||
}//GEN-LAST:event_btnCleanGameActionPerformed
|
||||
|
||||
private void btnChoosingGameDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChoosingGameDirActionPerformed
|
||||
JSystemFileChooser fc = new JSystemFileChooser();
|
||||
fc.setFileSelectionMode(JSystemFileChooser.DIRECTORIES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("settings.choose_gamedir"));
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.setFileFilter(new FileNameFilter("javaw.exe"));
|
||||
fc.addChoosableFileFilter(new FileNameFilter("java.exe"));
|
||||
fc.addChoosableFileFilter(new FileNameFilter("java"));
|
||||
fc.showOpenDialog(this);
|
||||
if (fc.getSelectedFile() == null)
|
||||
return;
|
||||
try {
|
||||
String path = fc.getSelectedFile().getCanonicalPath();
|
||||
txtJavaDir.setText(path);
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setJavaDir(txtJavaDir.getText());
|
||||
txtGameDir.setText(path);
|
||||
Settings.getLastProfile().setGameDir(path);
|
||||
} catch (IOException e) {
|
||||
HMCLog.warn("Failed to set java path.", e);
|
||||
MessageBox.Show(C.i18n("ui.label.failed_set") + e.getMessage());
|
||||
HMCLog.warn("Failed to set game dir.", e);
|
||||
MessageBox.show(C.i18n("ui.label.failed_set") + e.getMessage());
|
||||
}
|
||||
}//GEN-LAST:event_btnChoosingJavaDirActionPerformed
|
||||
}//GEN-LAST:event_btnChoosingGameDirActionPerformed
|
||||
|
||||
private void cboJavaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboJavaItemStateChanged
|
||||
if (evt.getStateChange() != ItemEvent.SELECTED || cboJava.getSelectedIndex() < 0 || StrUtils.isBlank((String) cboJava.getSelectedItem()))
|
||||
@@ -1027,87 +1116,28 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
}
|
||||
}//GEN-LAST:event_cboJavaItemStateChanged
|
||||
|
||||
private void btnAddModActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddModActionPerformed
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("mods.choose_mod"));
|
||||
fc.setMultiSelectionEnabled(true);
|
||||
if (fc.showOpenDialog(this) != JFileChooser.APPROVE_OPTION)
|
||||
private void btnChoosingJavaDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChoosingJavaDirActionPerformed
|
||||
if (cboJava.getSelectedIndex() != 1)
|
||||
return;
|
||||
boolean flag = true;
|
||||
for (File f : fc.getSelectedFiles())
|
||||
flag &= Settings.getLastProfile().service().mod().addMod(Settings.getLastProfile().getSelectedVersion(), f);
|
||||
reloadMods();
|
||||
if (!flag)
|
||||
MessageBox.Show(C.i18n("mods.failed"));
|
||||
}//GEN-LAST:event_btnAddModActionPerformed
|
||||
|
||||
private void btnRemoveModActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveModActionPerformed
|
||||
Settings.getLastProfile().service().mod().removeMod(Settings.getLastProfile().getSelectedVersion(), SwingUtils.getValueBySelectedRow(lstExternalMods, lstExternalMods.getSelectedRows(), 1));
|
||||
reloadMods();
|
||||
}//GEN-LAST:event_btnRemoveModActionPerformed
|
||||
|
||||
private void lstExternalModsKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lstExternalModsKeyPressed
|
||||
if (evt.getKeyCode() == KeyEvent.VK_DELETE)
|
||||
btnRemoveModActionPerformed(null);
|
||||
}//GEN-LAST:event_lstExternalModsKeyPressed
|
||||
|
||||
private void lblModInfoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblModInfoMouseClicked
|
||||
int idx = lstExternalMods.getSelectedRow();
|
||||
if (idx > 0 && idx < Settings.getLastProfile().service().mod().getMods(Settings.getLastProfile().getSelectedVersion()).size())
|
||||
SwingUtils.openLink(Settings.getLastProfile().service().mod().getMods(Settings.getLastProfile().getSelectedVersion()).get(idx).url);
|
||||
}//GEN-LAST:event_lblModInfoMouseClicked
|
||||
|
||||
private void btnChoosingGameDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChoosingGameDirActionPerformed
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("settings.choose_gamedir"));
|
||||
JSystemFileChooser fc = new JSystemFileChooser();
|
||||
fc.setFileSelectionMode(JSystemFileChooser.FILES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("settings.choose_javapath"));
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.setFileFilter(new FileNameFilter("javaw.exe"));
|
||||
fc.addChoosableFileFilter(new FileNameFilter("java.exe"));
|
||||
fc.addChoosableFileFilter(new FileNameFilter("java"));
|
||||
fc.showOpenDialog(this);
|
||||
if (fc.getSelectedFile() == null)
|
||||
return;
|
||||
try {
|
||||
String path = fc.getSelectedFile().getCanonicalPath();
|
||||
txtGameDir.setText(path);
|
||||
Settings.getLastProfile().setGameDir(path);
|
||||
txtJavaDir.setText(path);
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setJavaDir(txtJavaDir.getText());
|
||||
} catch (IOException e) {
|
||||
HMCLog.warn("Failed to set game dir.", e);
|
||||
MessageBox.Show(C.i18n("ui.label.failed_set") + e.getMessage());
|
||||
HMCLog.warn("Failed to set java path.", e);
|
||||
MessageBox.show(C.i18n("ui.label.failed_set") + e.getMessage());
|
||||
}
|
||||
}//GEN-LAST:event_btnChoosingGameDirActionPerformed
|
||||
|
||||
private void btnCleanGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCleanGameActionPerformed
|
||||
Settings.getLastProfile().service().version().cleanFolder();
|
||||
}//GEN-LAST:event_btnCleanGameActionPerformed
|
||||
|
||||
private void btnTestGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTestGameActionPerformed
|
||||
LogWindow.INSTANCE.setVisible(true);
|
||||
MainFrame.INSTANCE.daemon.runGame(Settings.getLastProfile());
|
||||
}//GEN-LAST:event_btnTestGameActionPerformed
|
||||
|
||||
private void btnShowLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnShowLogActionPerformed
|
||||
LogWindow.INSTANCE.setVisible(true);
|
||||
}//GEN-LAST:event_btnShowLogActionPerformed
|
||||
|
||||
private void btnMakeLaunchScriptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMakeLaunchScriptActionPerformed
|
||||
MainFrame.INSTANCE.daemon.makeLaunchScript(Settings.getLastProfile());
|
||||
}//GEN-LAST:event_btnMakeLaunchScriptActionPerformed
|
||||
|
||||
private void btnIncludeMinecraftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIncludeMinecraftActionPerformed
|
||||
JFileChooser fc = new JFileChooser(new File("."));
|
||||
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
|
||||
File newGameDir = fc.getSelectedFile();
|
||||
String name = JOptionPane.showInputDialog(C.i18n("setupwindow.give_a_name"));
|
||||
if (StrUtils.isBlank(name)) {
|
||||
MessageBox.Show(C.i18n("setupwindow.no_empty_name"));
|
||||
return;
|
||||
}
|
||||
Settings.putProfile(new Profile(name).setGameDir(newGameDir.getAbsolutePath()));
|
||||
MessageBox.Show(C.i18n("setupwindow.find_in_configurations"));
|
||||
loadProfiles();
|
||||
}
|
||||
}//GEN-LAST:event_btnIncludeMinecraftActionPerformed
|
||||
}//GEN-LAST:event_btnChoosingJavaDirActionPerformed
|
||||
|
||||
private void cboRunDirectoryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboRunDirectoryItemStateChanged
|
||||
if (!isLoading && cboRunDirectory.getSelectedIndex() >= 0)
|
||||
@@ -1119,60 +1149,36 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setLauncherVisibility(LauncherVisibility.values()[cboLauncherVisibility.getSelectedIndex()]);
|
||||
}//GEN-LAST:event_cboLauncherVisibilityItemStateChanged
|
||||
|
||||
private void chkFullscreenItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkFullscreenItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setFullscreen(chkFullscreen.isSelected());
|
||||
}//GEN-LAST:event_chkFullscreenItemStateChanged
|
||||
|
||||
private void chkNoJVMArgsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkNoJVMArgsItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setNoJVMArgs(chkNoJVMArgs.isSelected());
|
||||
}//GEN-LAST:event_chkNoJVMArgsItemStateChanged
|
||||
private void btnDownloadAllAssetsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadAllAssetsActionPerformed
|
||||
if (mcVersion != null)
|
||||
TaskWindow.factory().execute(Settings.getLastProfile().service().asset().downloadAssets(mcVersion));
|
||||
}//GEN-LAST:event_btnDownloadAllAssetsActionPerformed
|
||||
|
||||
private void txtMaxMemoryFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtMaxMemoryFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setMaxMemory(txtMaxMemory.getText());
|
||||
}//GEN-LAST:event_txtMaxMemoryFocusLost
|
||||
|
||||
private void txtWidthFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtWidthFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setWidth(txtWidth.getText());
|
||||
}//GEN-LAST:event_txtWidthFocusLost
|
||||
private void txtJavaDirFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtJavaDirFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setJavaDir(txtJavaDir.getText());
|
||||
}//GEN-LAST:event_txtJavaDirFocusLost
|
||||
|
||||
private void chkFullscreenItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkFullscreenItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setFullscreen(chkFullscreen.isSelected());
|
||||
}//GEN-LAST:event_chkFullscreenItemStateChanged
|
||||
|
||||
private void txtHeightFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtHeightFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setHeight(txtHeight.getText());
|
||||
}//GEN-LAST:event_txtHeightFocusLost
|
||||
|
||||
private void txtJavaDirFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtJavaDirFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setJavaDir(txtJavaDir.getText());
|
||||
}//GEN-LAST:event_txtJavaDirFocusLost
|
||||
private void txtWidthFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtWidthFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setWidth(txtWidth.getText());
|
||||
}//GEN-LAST:event_txtWidthFocusLost
|
||||
|
||||
private void txtJavaArgsFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtJavaArgsFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setJavaArgs(txtJavaArgs.getText());
|
||||
}//GEN-LAST:event_txtJavaArgsFocusLost
|
||||
|
||||
private void txtMinecraftArgsFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtMinecraftArgsFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setMinecraftArgs(txtMinecraftArgs.getText());
|
||||
}//GEN-LAST:event_txtMinecraftArgsFocusLost
|
||||
|
||||
private void txtPermSizeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPermSizeFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setPermSize(txtPermSize.getText());
|
||||
}//GEN-LAST:event_txtPermSizeFocusLost
|
||||
|
||||
private void txtPrecalledCommandFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPrecalledCommandFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setPrecalledCommand(txtPrecalledCommand.getText());
|
||||
}//GEN-LAST:event_txtPrecalledCommandFocusLost
|
||||
|
||||
private void txtServerIPFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtServerIPFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setServerIp(txtServerIP.getText());
|
||||
}//GEN-LAST:event_txtServerIPFocusLost
|
||||
|
||||
private void txtWrapperLauncherFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtWrapperLauncherFocusLost
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setWrapper(txtWrapperLauncher.getText());
|
||||
}//GEN-LAST:event_txtWrapperLauncherFocusLost
|
||||
|
||||
private void chkDontCheckGameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkDontCheckGameItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().getSelectedVersionSetting().setNotCheckGame(chkDontCheckGame.isSelected());
|
||||
}//GEN-LAST:event_chkDontCheckGameItemStateChanged
|
||||
private void txtGameDirFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtGameDirFocusLost
|
||||
Settings.getLastProfile().setGameDir(txtGameDir.getText());
|
||||
loadVersions();
|
||||
}//GEN-LAST:event_txtGameDirFocusLost
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold defaultstate="collapsed" desc="Load">
|
||||
@@ -1224,7 +1230,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
List<File> files = (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
for (File file : files)
|
||||
Settings.getLastProfile().service().mod().addMod(Settings.getLastProfile().getSelectedVersion(), file);
|
||||
} catch (Exception ex) {
|
||||
} catch (UnsupportedFlavorException | IOException ex) {
|
||||
HMCLog.warn("Failed to drop file.", ex);
|
||||
}
|
||||
}
|
||||
@@ -1260,21 +1266,24 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
return;
|
||||
reloadingMods = true;
|
||||
DefaultTableModel model = SwingUtils.clearDefaultTable(lstExternalMods);
|
||||
new OverridableSwingWorker<List<ModInfo>>() {
|
||||
@Override
|
||||
protected void work() throws Exception {
|
||||
publish(Settings.getLastProfile().service().mod().recacheMods(Settings.getLastProfile().getSelectedVersion()));
|
||||
}
|
||||
}.reg(t -> {
|
||||
new OverridableSwingWorkerImpl().reg(t -> {
|
||||
synchronized (modLock) {
|
||||
for (ModInfo x : t)
|
||||
model.addRow(new Object[] { x.isActive(), x, x.version });
|
||||
model.addRow(new Object[]{x.isActive(), x, x.version});
|
||||
reloadingMods = false;
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
}
|
||||
|
||||
private static class OverridableSwingWorkerImpl extends OverridableSwingWorker<List<ModInfo>> {
|
||||
|
||||
@Override
|
||||
protected void work() throws Exception {
|
||||
publish(Settings.getLastProfile().service().mod().recacheMods(Settings.getLastProfile().getSelectedVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
void save() {
|
||||
VersionSetting vs = Settings.getLastProfile().getSelectedVersionSetting();
|
||||
@@ -1306,6 +1315,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
||||
Settings.onProfileLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeave() {
|
||||
super.onLeave();
|
||||
save();
|
||||
|
||||
@@ -28,13 +28,14 @@ import org.jackhuang.hellominecraft.util.tasks.TaskRunnable;
|
||||
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class InstallerPanel extends AnimatedPanel {
|
||||
public class InstallerPanel extends Page {
|
||||
|
||||
GameSettingsPanel gsp;
|
||||
|
||||
@@ -113,16 +114,15 @@ public class InstallerPanel extends AnimatedPanel {
|
||||
}//GEN-LAST:event_btnInstallActionPerformed
|
||||
|
||||
private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshActionPerformed
|
||||
refreshVersions();
|
||||
TaskWindow.factory().execute(refreshVersionsTask());
|
||||
}//GEN-LAST:event_btnRefreshActionPerformed
|
||||
|
||||
transient List<InstallerVersionList.InstallerVersion> versions;
|
||||
transient InstallerVersionList list;
|
||||
InstallerVersionList list;
|
||||
InstallerType id;
|
||||
|
||||
void refreshVersions() {
|
||||
if (TaskWindow.execute(list.refresh(new String[] { gsp.getMinecraftVersionFormatted() })))
|
||||
loadVersions();
|
||||
Task refreshVersionsTask() {
|
||||
return list.refresh(new String[] { gsp.getMinecraftVersionFormatted() }).after(new TaskRunnable(this::loadVersions));
|
||||
}
|
||||
|
||||
public synchronized InstallerVersionList.InstallerVersion getVersion(int idx) {
|
||||
@@ -132,11 +132,13 @@ public class InstallerPanel extends AnimatedPanel {
|
||||
synchronized void downloadSelectedRow() {
|
||||
int idx = lstInstallers.getSelectedRow();
|
||||
if (versions == null || idx < 0 || idx >= versions.size()) {
|
||||
MessageBox.Show(C.i18n("install.not_refreshed"));
|
||||
MessageBox.show(C.i18n("install.not_refreshed"));
|
||||
return;
|
||||
}
|
||||
TaskWindow.execute(Settings.getLastProfile().service().install().download(Settings.getLastProfile().getSelectedVersion(), getVersion(idx), id),
|
||||
new TaskRunnable(this::refreshVersions));
|
||||
TaskWindow.factory()
|
||||
.append(Settings.getLastProfile().service().install().download(Settings.getLastProfile().getSelectedVersion(), getVersion(idx), id))
|
||||
.append(refreshVersionsTask())
|
||||
.execute();
|
||||
}
|
||||
|
||||
public void loadVersions() {
|
||||
@@ -159,7 +161,7 @@ public class InstallerPanel extends AnimatedPanel {
|
||||
@Override
|
||||
public void onSelect() {
|
||||
if (!refreshed) {
|
||||
refreshVersions();
|
||||
TaskWindow.factory().execute(refreshVersionsTask());
|
||||
refreshed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,18 +19,6 @@
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="chkEnableAnimation" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="btnCheckUpdate" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnMCBBS" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="chkDecorated" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="lblProxy" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
@@ -71,12 +59,22 @@
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="btnCheckUpdate" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnMCBBS" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="lblAbout" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblModpack" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblRestart" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="chkEnableShadow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="chkDecorated" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@@ -121,20 +119,19 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="chkEnableShadow" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkEnableAnimation" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkDecorated" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="btnCheckUpdate" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<Component id="chkDecorated" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnMCBBS" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnMCBBS" alignment="3" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblRestart" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="65" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblModpack" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblAbout" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblAbout" min="-2" pref="173" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
@@ -157,12 +154,9 @@
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/lang/I18N.properties" key="launcher.about" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="手型光标"/>
|
||||
<Color id="默认光标"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblAboutMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnSelBackgroundPath">
|
||||
<Properties>
|
||||
@@ -291,16 +285,6 @@
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="chkEnableAnimation">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/lang/I18N.properties" key="launcher.enable_animation" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkEnableAnimationItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="chkDecorated">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
|
||||
@@ -17,10 +17,8 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
@@ -29,22 +27,27 @@ import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
|
||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.lang.SupportedLocales;
|
||||
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.JSystemFileChooser;
|
||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
public class LauncherSettingsPanel extends RepaintPage {
|
||||
|
||||
/**
|
||||
* Creates new form LancherSettingsPanel
|
||||
*/
|
||||
public LauncherSettingsPanel() {
|
||||
setRepainter(this);
|
||||
}
|
||||
|
||||
void initGui() {
|
||||
initComponents();
|
||||
setBackground(GraphicsUtils.getWebColorWithAlpha("FFFFFF7F"));
|
||||
setOpaque(true);
|
||||
|
||||
DefaultComboBoxModel d = new DefaultComboBoxModel();
|
||||
for (DownloadType type : DownloadType.values())
|
||||
@@ -69,11 +72,7 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
cboDownloadSource.setSelectedIndex(Settings.getInstance().getDownloadType());
|
||||
cboTheme.setSelectedIndex(Settings.getInstance().getTheme().ordinal());
|
||||
chkEnableShadow.setSelected(Settings.getInstance().isEnableShadow());
|
||||
chkEnableAnimation.setSelected(Settings.getInstance().isEnableAnimation());
|
||||
chkDecorated.setSelected(Settings.getInstance().isDecorated());
|
||||
|
||||
setBackground(Color.white);
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,7 +109,6 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
txtProxyUsername = new javax.swing.JTextField();
|
||||
txtProxyPassword = new javax.swing.JTextField();
|
||||
lblProxyPassword = new javax.swing.JLabel();
|
||||
chkEnableAnimation = new javax.swing.JCheckBox();
|
||||
chkDecorated = new javax.swing.JCheckBox();
|
||||
lblModpack = new javax.swing.JLabel();
|
||||
cboLang = new javax.swing.JComboBox();
|
||||
@@ -125,12 +123,7 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
});
|
||||
|
||||
lblAbout.setText(C.i18n("launcher.about")); // NOI18N
|
||||
lblAbout.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
|
||||
lblAbout.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
lblAboutMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
lblAbout.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
|
||||
|
||||
btnSelBackgroundPath.setText(C.i18n("ui.button.explore")); // NOI18N
|
||||
btnSelBackgroundPath.addActionListener(new java.awt.event.ActionListener() {
|
||||
@@ -208,13 +201,6 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
|
||||
lblProxyPassword.setText(C.i18n("proxy.password")); // NOI18N
|
||||
|
||||
chkEnableAnimation.setText(C.i18n("launcher.enable_animation")); // NOI18N
|
||||
chkEnableAnimation.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
chkEnableAnimationItemStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
chkDecorated.setText(C.i18n("launcher.decorated")); // NOI18N
|
||||
chkDecorated.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
@@ -256,16 +242,6 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(chkEnableShadow)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(chkEnableAnimation))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(btnCheckUpdate)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnMCBBS)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(chkDecorated))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lblProxy)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
@@ -301,10 +277,18 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
.addComponent(cboTheme, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(btnCheckUpdate)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnMCBBS))
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblRestart))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(chkEnableShadow)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(chkDecorated)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
@@ -341,18 +325,17 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(chkEnableShadow)
|
||||
.addComponent(chkEnableAnimation))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkDecorated))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(chkDecorated)
|
||||
.addComponent(btnMCBBS))
|
||||
.addComponent(btnMCBBS, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblRestart)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
@@ -362,8 +345,8 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
}//GEN-LAST:event_cboDownloadSourceItemStateChanged
|
||||
|
||||
private void btnSelBackgroundPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelBackgroundPathActionPerformed
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
JSystemFileChooser fc = new JSystemFileChooser();
|
||||
fc.setFileSelectionMode(JSystemFileChooser.FILES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("launcher.choose_bgpath"));
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.setFileFilter(new FileNameExtensionFilter("*.png", "png"));
|
||||
@@ -379,7 +362,7 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
MainFrame.INSTANCE.loadBackground();
|
||||
} catch (IOException e) {
|
||||
HMCLog.warn("Failed to set background path.", e);
|
||||
MessageBox.Show(C.i18n("ui.label.failed_set") + e.getMessage());
|
||||
MessageBox.show(C.i18n("ui.label.failed_set") + e.getMessage());
|
||||
}
|
||||
}//GEN-LAST:event_btnSelBackgroundPathActionPerformed
|
||||
|
||||
@@ -413,10 +396,6 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
Settings.getInstance().setDecorated(chkDecorated.isSelected());
|
||||
}//GEN-LAST:event_chkDecoratedItemStateChanged
|
||||
|
||||
private void chkEnableAnimationItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkEnableAnimationItemStateChanged
|
||||
Settings.getInstance().setEnableAnimation(chkEnableAnimation.isSelected());
|
||||
}//GEN-LAST:event_chkEnableAnimationItemStateChanged
|
||||
|
||||
private void txtProxyHostFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyHostFocusLost
|
||||
Settings.getInstance().setProxyHost(txtProxyHost.getText());
|
||||
}//GEN-LAST:event_txtProxyHostFocusLost
|
||||
@@ -433,10 +412,6 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
Settings.getInstance().setProxyPassword(txtProxyPassword.getText());
|
||||
}//GEN-LAST:event_txtProxyPasswordFocusLost
|
||||
|
||||
private void lblAboutMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblAboutMouseClicked
|
||||
SwingUtils.openLink("http://huangyuhui.duapp.com/link.php?type=sponsor");
|
||||
}//GEN-LAST:event_lblAboutMouseClicked
|
||||
|
||||
private void btnMCBBSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMCBBSActionPerformed
|
||||
SwingUtils.openLink(C.URL_PUBLISH);
|
||||
}//GEN-LAST:event_btnMCBBSActionPerformed
|
||||
@@ -449,7 +424,6 @@ public class LauncherSettingsPanel extends AnimatedPanel {
|
||||
private javax.swing.JComboBox cboLang;
|
||||
private javax.swing.JComboBox cboTheme;
|
||||
private javax.swing.JCheckBox chkDecorated;
|
||||
private javax.swing.JCheckBox chkEnableAnimation;
|
||||
private javax.swing.JCheckBox chkEnableShadow;
|
||||
private javax.swing.JLabel lblAbout;
|
||||
private javax.swing.JLabel lblBackground;
|
||||
|
||||
@@ -110,19 +110,17 @@ public class LaunchingUIDaemon {
|
||||
String msg = C.i18n("launch.exited_abnormally") + " exit code: " + t;
|
||||
if (errorText != null)
|
||||
msg += ", advice: " + MinecraftCrashAdvicer.getAdvice(FileUtils.readQuietly(new File(errorText)));
|
||||
MessageBox.Show(msg);
|
||||
WebFrame f = new WebFrame(logs);
|
||||
f.setModal(true);
|
||||
f.setTitle("Game output");
|
||||
f.setTitle(msg);
|
||||
f.setVisible(true);
|
||||
checkExit((LauncherVisibility) obj.getTag());
|
||||
});
|
||||
jpm.jvmLaunchFailedEvent.register(t -> {
|
||||
HMCLog.err("Cannot create jvm, exit code: " + t);
|
||||
MessageBox.Show(C.i18n("launch.cannot_create_jvm") + " exit code: " + t);
|
||||
WebFrame f = new WebFrame(jpm.getJavaProcess().getStdOutLines().toArray(new String[0]));
|
||||
f.setModal(true);
|
||||
f.setTitle("Game output");
|
||||
f.setTitle(C.i18n("launch.cannot_create_jvm") + " exit code: " + t);
|
||||
f.setVisible(true);
|
||||
checkExit((LauncherVisibility) obj.getTag());
|
||||
});
|
||||
@@ -138,10 +136,6 @@ public class LaunchingUIDaemon {
|
||||
return true;
|
||||
};
|
||||
|
||||
private static void getCrashReport() {
|
||||
|
||||
}
|
||||
|
||||
private static void checkExit(LauncherVisibility v) {
|
||||
if (v != LauncherVisibility.KEEP && !LogWindow.INSTANCE.isVisible()) {
|
||||
HMCLog.log("Launcher will exit now.");
|
||||
@@ -154,10 +148,10 @@ public class LaunchingUIDaemon {
|
||||
try {
|
||||
String s = JOptionPane.showInputDialog(C.i18n("mainwindow.enter_script_name"));
|
||||
if (s != null)
|
||||
MessageBox.Show(C.i18n("mainwindow.make_launch_succeed") + " " + ((GameLauncher) sender).makeLauncher(s, str).getAbsolutePath());
|
||||
MessageBox.show(C.i18n("mainwindow.make_launch_succeed") + " " + ((GameLauncher) sender).makeLauncher(s, str).getAbsolutePath());
|
||||
flag = true;
|
||||
} catch (IOException ex) {
|
||||
MessageBox.Show(C.i18n("mainwindow.make_launch_script_failed"));
|
||||
MessageBox.show(C.i18n("mainwindow.make_launch_script_failed"));
|
||||
HMCLog.err("Failed to create script file.", ex);
|
||||
}
|
||||
MainFrame.INSTANCE.closeMessage();
|
||||
|
||||
@@ -25,7 +25,9 @@ import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
@@ -33,6 +35,8 @@ import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import javax.swing.BorderFactory;
|
||||
@@ -40,35 +44,38 @@ import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.Main;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
||||
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Settings;
|
||||
import org.jackhuang.hellominecraft.lookandfeel.Theme;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.DropShadowBorder;
|
||||
import org.jackhuang.hellominecraft.util.ui.TintablePanel;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.ui.BasicColors;
|
||||
import org.jackhuang.hellominecraft.util.ui.DropShadowBorder;
|
||||
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.TintablePanel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class MainFrame extends DraggableFrame {
|
||||
public final class MainFrame extends DraggableFrame implements IRepaint {
|
||||
|
||||
public static final MainFrame INSTANCE = new MainFrame();
|
||||
|
||||
TintablePanel centralPanel;
|
||||
JPanel header, infoSwap, realPanel;
|
||||
CardLayout infoLayout;
|
||||
JLabel backgroundLabel, windowTitle;
|
||||
JLabel windowTitle;
|
||||
GaussionPage backgroundLabel;
|
||||
DropShadowBorder border;
|
||||
boolean enableShadow;
|
||||
String defaultTitle;
|
||||
@@ -89,7 +96,7 @@ public final class MainFrame extends DraggableFrame {
|
||||
setContentSize(834, 542);
|
||||
else
|
||||
setContentSize(802, 511);
|
||||
setDefaultCloseOperation(3);
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
setTitle(Main.makeTitle());
|
||||
initComponents();
|
||||
loadBackground();
|
||||
@@ -152,6 +159,7 @@ public final class MainFrame extends DraggableFrame {
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
setLayout(null);
|
||||
initBorderColor(Settings.getInstance().getTheme());
|
||||
|
||||
realPanel = new JPanel();
|
||||
@@ -242,14 +250,13 @@ public final class MainFrame extends DraggableFrame {
|
||||
truePanel.setBounds(0, 0, 800, 480);
|
||||
centralPanel.setBounds(0, 30, 800, 480);
|
||||
|
||||
setLayout(null);
|
||||
realPanel.setBounds(1, 0, 800, 511);
|
||||
add(realPanel);
|
||||
}
|
||||
|
||||
private final ActionListener tabListener = e -> MainFrame.this.selectTab(e.getActionCommand());
|
||||
private transient final ActionListener tabListener = e -> MainFrame.this.selectTab(e.getActionCommand());
|
||||
|
||||
private void initializeTab(AnimatedPanel inst, String cmd) {
|
||||
private void initializeTab(Page inst, String cmd) {
|
||||
HeaderTab tab = new HeaderTab(C.i18n("launcher.title." + cmd));
|
||||
tab.setActionCommand(cmd);
|
||||
tab.setForeground(BasicColors.COLOR_WHITE_TEXT);
|
||||
@@ -263,11 +270,11 @@ public final class MainFrame extends DraggableFrame {
|
||||
|
||||
private final List<HeaderTab> tabHeader = new ArrayList<>();
|
||||
private JPanel tabWrapper[];
|
||||
private final List<AnimatedPanel> tabContent = new ArrayList<>();
|
||||
private final List<Page> tabContent = new ArrayList<>();
|
||||
|
||||
public void selectTab(String tabName) {
|
||||
int chosen = -1;
|
||||
AnimatedPanel onCreate = null, onSelect = null;
|
||||
Page onCreate = null, onSelect = null;
|
||||
for (int i = 0; i < tabHeader.size(); i++)
|
||||
if (tabName.equalsIgnoreCase(tabHeader.get(i).getActionCommand())) {
|
||||
if (!tabContent.get(i).isCreated()) {
|
||||
@@ -318,14 +325,15 @@ public final class MainFrame extends DraggableFrame {
|
||||
|
||||
public void loadBackground() {
|
||||
background = SwingUtils.searchBackgroundImage(Main.getIcon(Settings.getInstance().getTheme().settings.get("Customized.MainFrame.background_image")), Settings.getInstance().getBgpath(), 800, 480);
|
||||
if (background != null)
|
||||
if (background != null) {
|
||||
if (backgroundLabel == null) {
|
||||
backgroundLabel = new JLabel(background);
|
||||
backgroundLabel = new GaussionPage();
|
||||
backgroundLabel.addAeroObject(backgroundLabel);
|
||||
backgroundLabel.setBounds(0, 0, 800, 480);
|
||||
centralPanel.add(backgroundLabel, -1);
|
||||
} else
|
||||
backgroundLabel.setIcon(background);
|
||||
else
|
||||
}
|
||||
backgroundLabel.setBackgroundImage(background.getImage());
|
||||
} else
|
||||
HMCLog.warn("No background image here! The background will be empty!");
|
||||
}
|
||||
|
||||
@@ -407,7 +415,7 @@ public final class MainFrame extends DraggableFrame {
|
||||
int contentWidth = width - off - off;
|
||||
int contentHeight = height - off - off;
|
||||
BufferedImage contentImage = new BufferedImage(contentWidth,
|
||||
contentHeight, Transparency.OPAQUE);
|
||||
contentHeight, Transparency.OPAQUE);
|
||||
Graphics2D contentG2d = contentImage.createGraphics();
|
||||
contentG2d.translate(-off, -off);
|
||||
paintImpl(g);
|
||||
@@ -426,6 +434,25 @@ public final class MainFrame extends DraggableFrame {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getRepaintComponent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Window getRepaintWindow() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Rectangle> getRepaintRects() {
|
||||
int off = MainFrame.INSTANCE.enableShadow ? 16 : 0, yoff = MainFrame.INSTANCE.getInsets().top + off, xoff = MainFrame.INSTANCE.getInsets().left + off;
|
||||
int width = 800, height = MainFrame.INSTANCE.header.getHeight() + 480 - 1;
|
||||
return Arrays.asList(new Rectangle(xoff, yoff, xoff, height + yoff + 1),
|
||||
new Rectangle(xoff + width + 1, yoff, xoff + width + 1, height + yoff + 1),
|
||||
new Rectangle(xoff, height + yoff + 1, xoff + width + 1, height + yoff + 1));
|
||||
}
|
||||
|
||||
private static class MouseListenerImpl implements MouseListener {
|
||||
|
||||
public static final MouseListenerImpl INSTANCE = new MouseListenerImpl();
|
||||
@@ -454,14 +481,12 @@ public final class MainFrame extends DraggableFrame {
|
||||
|
||||
public void failed(String s) {
|
||||
if (s != null)
|
||||
MessageBox.Show(s);
|
||||
MessageBox.show(s);
|
||||
closeMessage();
|
||||
}
|
||||
|
||||
LaunchingUIDaemon daemon = new LaunchingUIDaemon();
|
||||
|
||||
final HashMap<String, Runnable> actions = new HashMap<>();
|
||||
|
||||
transient LaunchingUIDaemon daemon = new LaunchingUIDaemon();
|
||||
transient final HashMap<String, Runnable> actions = new HashMap<>();
|
||||
void invokeAction(String name) {
|
||||
if (actions.containsKey(name))
|
||||
actions.get(name).run();
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new org.jackhuang.hellominecraft.launcher.ui.RepaintPage()"/>
|
||||
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="MainPagePanel_pnlMore"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="0" y="0" width="190" height="480"/>
|
||||
@@ -40,19 +44,19 @@
|
||||
<Component id="pnlPassword" alignment="1" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel10" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblProfile" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblVersion" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="cboProfiles" alignment="0" pref="128" max="32767" attributes="0"/>
|
||||
<Component id="cboProfiles" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="cboVersions" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="lblUserName" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblLogin" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
@@ -72,7 +76,7 @@
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblProfile" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cboProfiles" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
@@ -82,7 +86,7 @@
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblLogin" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cboLoginMode" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
@@ -109,7 +113,7 @@
|
||||
<EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtPlayerNameKeyPressed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel7">
|
||||
<Component class="javax.swing.JLabel" name="lblLogin">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/lang/I18N.properties" key="login.type" replaceFormat="C.i18n("{key}")"/>
|
||||
@@ -133,7 +137,7 @@
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel10">
|
||||
<Component class="javax.swing.JLabel" name="lblProfile">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/lang/I18N.properties" key="ui.label.profile" replaceFormat="C.i18n("{key}")"/>
|
||||
@@ -169,12 +173,15 @@
|
||||
<Events>
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="cboVersionsItemStateChanged"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new WideComboBox()"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="pnlPassword">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Container class="javax.swing.JPanel" name="pnlLogIn">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
|
||||
<CardConstraints cardName="card2"/>
|
||||
@@ -185,7 +192,7 @@
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblPassword" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtPassword" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
@@ -196,7 +203,7 @@
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel9" alignment="3" min="-2" pref="22" max="-2" attributes="0"/>
|
||||
<Component id="lblPassword" alignment="3" min="-2" pref="22" max="-2" attributes="0"/>
|
||||
<Component id="txtPassword" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
@@ -204,7 +211,7 @@
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel9">
|
||||
<Component class="javax.swing.JLabel" name="lblPassword">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hellominecraft/lang/I18N.properties" key="ui.label.password" replaceFormat="C.i18n("{key}")"/>
|
||||
@@ -221,7 +228,7 @@
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel3">
|
||||
<Container class="javax.swing.JPanel" name="pnlLogOut">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
|
||||
<CardConstraints cardName="card3"/>
|
||||
@@ -278,4 +285,4 @@
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
</Form>
|
||||
@@ -23,7 +23,6 @@ import java.awt.Font;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
@@ -38,12 +37,13 @@ import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.ui.modpack.ModpackWizard;
|
||||
import org.jackhuang.hellominecraft.launcher.util.HMCLMinecraftService;
|
||||
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
|
||||
import org.jackhuang.hellominecraft.util.Event;
|
||||
import org.jackhuang.hellominecraft.lookandfeel.comp.ConstomButton;
|
||||
import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
||||
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.JSystemFileChooser;
|
||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
import org.jackhuang.hellominecraft.util.ui.wizard.api.WizardDisplayer;
|
||||
|
||||
@@ -51,11 +51,8 @@ import org.jackhuang.hellominecraft.util.ui.wizard.api.WizardDisplayer;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class MainPagePanel extends AnimatedPanel {
|
||||
public class MainPagePanel extends GaussionPage {
|
||||
|
||||
/**
|
||||
* Creates new form MainPagePanel
|
||||
*/
|
||||
public MainPagePanel() {
|
||||
}
|
||||
|
||||
@@ -76,7 +73,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
btnRun.setFont(newFont);
|
||||
btnRun.addActionListener(e -> MainFrame.INSTANCE.daemon.runGame(Settings.getLastProfile()));
|
||||
|
||||
this.add(pnlButtons);
|
||||
add(pnlButtons);
|
||||
pnlButtons.setBounds(0, 0, w, h);
|
||||
|
||||
this.setSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));
|
||||
@@ -93,7 +90,10 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
|
||||
prepareAuths();
|
||||
|
||||
animationEnabled = false;
|
||||
addAeroObject(pnlMore);
|
||||
setBackgroundImage(MainFrame.INSTANCE.background.getImage());
|
||||
|
||||
((RepaintPage) pnlMore).setRepainter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,20 +105,20 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
pnlMore = new javax.swing.JPanel();
|
||||
pnlMore = new RepaintPage();
|
||||
txtPlayerName = new javax.swing.JTextField();
|
||||
jLabel7 = new javax.swing.JLabel();
|
||||
lblLogin = new javax.swing.JLabel();
|
||||
cboLoginMode = new javax.swing.JComboBox();
|
||||
lblUserName = new javax.swing.JLabel();
|
||||
jLabel10 = new javax.swing.JLabel();
|
||||
lblProfile = new javax.swing.JLabel();
|
||||
cboProfiles = new javax.swing.JComboBox();
|
||||
lblVersion = new javax.swing.JLabel();
|
||||
cboVersions = new javax.swing.JComboBox();
|
||||
cboVersions = new WideComboBox();
|
||||
pnlPassword = new javax.swing.JPanel();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jLabel9 = new javax.swing.JLabel();
|
||||
pnlLogIn = new javax.swing.JPanel();
|
||||
lblPassword = new javax.swing.JLabel();
|
||||
txtPassword = new javax.swing.JPasswordField();
|
||||
jPanel3 = new javax.swing.JPanel();
|
||||
pnlLogOut = new javax.swing.JPanel();
|
||||
btnLogout = new javax.swing.JButton();
|
||||
btnImportModpack = new javax.swing.JButton();
|
||||
btnExportModpack = new javax.swing.JButton();
|
||||
@@ -142,7 +142,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
}
|
||||
});
|
||||
|
||||
jLabel7.setText(C.i18n("login.type")); // NOI18N
|
||||
lblLogin.setText(C.i18n("login.type")); // NOI18N
|
||||
|
||||
cboLoginMode.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
@@ -152,7 +152,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
|
||||
lblUserName.setText(C.i18n("login.username")); // NOI18N
|
||||
|
||||
jLabel10.setText(C.i18n("ui.label.profile")); // NOI18N
|
||||
lblProfile.setText(C.i18n("ui.label.profile")); // NOI18N
|
||||
|
||||
cboProfiles.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
@@ -171,7 +171,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
|
||||
pnlPassword.setLayout(new java.awt.CardLayout());
|
||||
|
||||
jLabel9.setText(C.i18n("ui.label.password")); // NOI18N
|
||||
lblPassword.setText(C.i18n("ui.label.password")); // NOI18N
|
||||
|
||||
txtPassword.addCaretListener(new javax.swing.event.CaretListener() {
|
||||
public void caretUpdate(javax.swing.event.CaretEvent evt) {
|
||||
@@ -194,25 +194,25 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(jLabel9)
|
||||
javax.swing.GroupLayout pnlLogInLayout = new javax.swing.GroupLayout(pnlLogIn);
|
||||
pnlLogIn.setLayout(pnlLogInLayout);
|
||||
pnlLogInLayout.setHorizontalGroup(
|
||||
pnlLogInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(pnlLogInLayout.createSequentialGroup()
|
||||
.addComponent(lblPassword)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtPassword))
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
|
||||
pnlLogInLayout.setVerticalGroup(
|
||||
pnlLogInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlLogInLayout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(pnlLogInLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
);
|
||||
|
||||
pnlPassword.add(jPanel1, "card2");
|
||||
pnlPassword.add(pnlLogIn, "card2");
|
||||
|
||||
btnLogout.setText(C.i18n("ui.button.logout")); // NOI18N
|
||||
btnLogout.addActionListener(new java.awt.event.ActionListener() {
|
||||
@@ -221,18 +221,18 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
|
||||
jPanel3.setLayout(jPanel3Layout);
|
||||
jPanel3Layout.setHorizontalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
javax.swing.GroupLayout pnlLogOutLayout = new javax.swing.GroupLayout(pnlLogOut);
|
||||
pnlLogOut.setLayout(pnlLogOutLayout);
|
||||
pnlLogOutLayout.setHorizontalGroup(
|
||||
pnlLogOutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(btnLogout, javax.swing.GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE)
|
||||
);
|
||||
jPanel3Layout.setVerticalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
pnlLogOutLayout.setVerticalGroup(
|
||||
pnlLogOutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(btnLogout, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
pnlPassword.add(jPanel3, "card3");
|
||||
pnlPassword.add(pnlLogOut, "card3");
|
||||
|
||||
btnImportModpack.setText(C.i18n("modpack.task.install")); // NOI18N
|
||||
btnImportModpack.addActionListener(new java.awt.event.ActionListener() {
|
||||
@@ -258,16 +258,16 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
.addComponent(pnlPassword, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(pnlMoreLayout.createSequentialGroup()
|
||||
.addGroup(pnlMoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(lblProfile, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(lblVersion, javax.swing.GroupLayout.Alignment.TRAILING))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(pnlMoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(cboProfiles, 0, 128, Short.MAX_VALUE)
|
||||
.addComponent(cboProfiles, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(cboVersions, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addGroup(pnlMoreLayout.createSequentialGroup()
|
||||
.addGroup(pnlMoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblUserName)
|
||||
.addComponent(jLabel7))
|
||||
.addComponent(lblLogin))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(pnlMoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(cboLoginMode, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
@@ -281,7 +281,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlMoreLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(pnlMoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel10)
|
||||
.addComponent(lblProfile)
|
||||
.addComponent(cboProfiles, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(pnlMoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
@@ -289,7 +289,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
.addComponent(lblVersion))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(pnlMoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel7)
|
||||
.addComponent(lblLogin)
|
||||
.addComponent(cboLoginMode, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(pnlMoreLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
@@ -374,8 +374,8 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
}//GEN-LAST:event_txtPasswordKeyPressed
|
||||
|
||||
private void btnImportModpackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportModpackActionPerformed
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
JSystemFileChooser fc = new JSystemFileChooser();
|
||||
fc.setFileSelectionMode(JSystemFileChooser.FILES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("modpack.choose"));
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("modpack"), "zip"));
|
||||
@@ -383,7 +383,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
if (fc.getSelectedFile() == null)
|
||||
return;
|
||||
String suggestedModpackId = JOptionPane.showInputDialog("Please enter your favourite game name", FileUtils.getBaseName(fc.getSelectedFile().getName()));
|
||||
TaskWindow.factory().append(ModpackManager.install(MainFrame.INSTANCE, fc.getSelectedFile(), Settings.getLastProfile().service(), suggestedModpackId)).create();
|
||||
TaskWindow.factory().append(ModpackManager.install(MainFrame.INSTANCE, fc.getSelectedFile(), Settings.getLastProfile().service(), suggestedModpackId)).execute();
|
||||
Settings.getLastProfile().service().version().refreshVersions();
|
||||
}//GEN-LAST:event_btnImportModpackActionPerformed
|
||||
|
||||
@@ -434,13 +434,13 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
private javax.swing.JComboBox cboLoginMode;
|
||||
private javax.swing.JComboBox cboProfiles;
|
||||
private javax.swing.JComboBox cboVersions;
|
||||
private javax.swing.JLabel jLabel10;
|
||||
private javax.swing.JLabel jLabel7;
|
||||
private javax.swing.JLabel jLabel9;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel3;
|
||||
private javax.swing.JLabel lblLogin;
|
||||
private javax.swing.JLabel lblPassword;
|
||||
private javax.swing.JLabel lblProfile;
|
||||
private javax.swing.JLabel lblUserName;
|
||||
private javax.swing.JLabel lblVersion;
|
||||
private javax.swing.JPanel pnlLogIn;
|
||||
private javax.swing.JPanel pnlLogOut;
|
||||
private javax.swing.JPanel pnlMore;
|
||||
private javax.swing.JPanel pnlPassword;
|
||||
private javax.swing.JPasswordField txtPassword;
|
||||
@@ -469,16 +469,14 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
return true;
|
||||
};
|
||||
|
||||
final Runnable onLoadingProfiles = this::loadProfiles;
|
||||
|
||||
private void loadProfiles() {
|
||||
final Runnable onLoadingProfiles = () -> {
|
||||
isLoading = true;
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||
for (Profile s : Settings.getProfilesFiltered())
|
||||
model.addElement(s.getName());
|
||||
cboProfiles.setModel(model);
|
||||
isLoading = false;
|
||||
}
|
||||
};
|
||||
|
||||
final Consumer<IMinecraftService> onRefreshedVersions = t -> {
|
||||
if (Settings.getLastProfile().service() == t)
|
||||
@@ -495,7 +493,7 @@ public class MainPagePanel extends AnimatedPanel {
|
||||
if (!showedNoVersion && ((HMCLMinecraftService) Settings.getLastProfile().service()).checkedModpack) {
|
||||
showedNoVersion = true;
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (MessageBox.Show(C.i18n("mainwindow.no_version"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
if (MessageBox.show(C.i18n("mainwindow.no_version"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
MainFrame.INSTANCE.invokeAction("showGameDownloads");
|
||||
});
|
||||
}
|
||||
|
||||
56
HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/Page.java
Executable file
56
HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/Page.java
Executable file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.launcher.ui;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Page extends JPanel implements Selectable {
|
||||
|
||||
boolean selected = false;
|
||||
|
||||
@Override
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelect() {
|
||||
selected = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeave() {
|
||||
selected = false;
|
||||
}
|
||||
|
||||
boolean created = false;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
created = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCreated() {
|
||||
return created;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@
|
||||
package org.jackhuang.hellominecraft.launcher.ui.modpack;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.HeadlessException;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import javax.swing.JOptionPane;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
@@ -113,8 +115,8 @@ public class ModpackDescriptionPanel extends javax.swing.JPanel {
|
||||
msgs[1] = new WebPage(new Markdown4jProcessor().process(txtDescription.getText()));
|
||||
((WebPage) msgs[1]).setPreferredSize(new Dimension(800, 350));
|
||||
JOptionPane.showOptionDialog(null, msgs, (String) msgs[0], JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
|
||||
} catch (Exception e) {
|
||||
MessageBox.Show(StrUtils.getStackTrace(e), C.i18n("message.error"), MessageBox.WARNING_MESSAGE);
|
||||
} catch (HeadlessException | IOException e) {
|
||||
MessageBox.show(StrUtils.getStackTrace(e), C.i18n("message.error"), MessageBox.WARNING_MESSAGE);
|
||||
}
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.util.Map;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.ui.JSystemFileChooser;
|
||||
import org.jackhuang.hellominecraft.util.ui.wizard.spi.WizardController;
|
||||
|
||||
/**
|
||||
@@ -172,8 +172,8 @@ public class ModpackInitializationPanel extends javax.swing.JPanel {
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void cboModpackLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboModpackLocationActionPerformed
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
JSystemFileChooser fc = new JSystemFileChooser();
|
||||
fc.setFileSelectionMode(JSystemFileChooser.FILES_ONLY);
|
||||
fc.setDialogTitle(C.i18n("modpack.wizard.step.initialization.save"));
|
||||
fc.setMultiSelectionEnabled(false);
|
||||
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("modpack") + "(*.zip)", "zip"));
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jackhuang.hellominecraft.launcher.ui.modpack;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
@@ -95,7 +96,7 @@ public class ModpackWizard extends WizardBranchController {
|
||||
if (settings.containsKey(ModpackDescriptionPanel.KEY_MODPACK_DESCRITION))
|
||||
try {
|
||||
map.put("description", new org.markdown4j.Markdown4jProcessor().process((String) settings.get(ModpackDescriptionPanel.KEY_MODPACK_DESCRITION)));
|
||||
} catch (Exception ex) {
|
||||
} catch (IOException ex) {
|
||||
progress.failed(C.i18n("modpack.export_error") + ": " + StrUtils.getStackTrace(ex), true);
|
||||
}
|
||||
try {
|
||||
@@ -134,7 +135,7 @@ public class ModpackWizard extends WizardBranchController {
|
||||
File f = new File(u.toURI());
|
||||
if (f.getName().endsWith(".exe") || f.getName().endsWith(".jar"))
|
||||
engine.putFile(f, f.getName());
|
||||
} catch (Exception e) {
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
HMCLog.err("Failed to add launcher files.", e);
|
||||
flag = false;
|
||||
break;
|
||||
|
||||
@@ -48,6 +48,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
put("MessageBox", "");
|
||||
put("AWTError", "");
|
||||
put("JFileChooser", "Has your operating system been installed completely or is a ghost system?");
|
||||
put("JSystemFileChooser", "Has your operating system been installed completely or is a ghost system?");
|
||||
put("Jce", "Has your operating system been installed completely or is a ghost system?");
|
||||
put("couldn't create component peer", "Fucking computer!");
|
||||
put("sun.awt.shell.Win32ShellFolder2", "crash.user_fault");
|
||||
@@ -122,7 +123,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
|
||||
void showMessage(String s) {
|
||||
try {
|
||||
MessageBox.Show(s, "ERROR", MessageBox.ERROR_MESSAGE);
|
||||
MessageBox.show(s, "ERROR", MessageBox.ERROR_MESSAGE);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.log(Level.SEVERE, "ERROR", e);
|
||||
}
|
||||
@@ -131,7 +132,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
private static final HashSet<String> THROWABLE_SET = new HashSet<>();
|
||||
|
||||
void reportToServer(final String text, String stacktrace) {
|
||||
if (THROWABLE_SET.contains(stacktrace))
|
||||
if (THROWABLE_SET.contains(stacktrace) || stacktrace.contains("Font"))
|
||||
return;
|
||||
THROWABLE_SET.add(stacktrace);
|
||||
Thread t = new Thread(() -> {
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.api.IPlugin;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.OfflineAuthenticator;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.SkinmeAuthenticator;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.YggdrasilAuthenticator;
|
||||
import org.jackhuang.hellominecraft.launcher.core.launch.LaunchOptions;
|
||||
@@ -37,9 +37,7 @@ import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||
*/
|
||||
public class DefaultPlugin implements IPlugin {
|
||||
|
||||
YggdrasilAuthenticator YGGDRASIL_LOGIN = null;
|
||||
OfflineAuthenticator OFFLINE_LOGIN = null;
|
||||
SkinmeAuthenticator SKINME_LOGIN = null;
|
||||
ArrayList<IAuthenticator> auths = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public IMinecraftService provideMinecraftService(Object profile) {
|
||||
@@ -49,20 +47,17 @@ public class DefaultPlugin implements IPlugin {
|
||||
@Override
|
||||
public void onRegisterAuthenticators(Consumer<IAuthenticator> apply) {
|
||||
String clientToken = Settings.getInstance().getClientToken();
|
||||
OFFLINE_LOGIN = new OfflineAuthenticator(clientToken);
|
||||
OFFLINE_LOGIN.onLoadSettings(Settings.getInstance().getAuthenticatorConfig(OFFLINE_LOGIN.id()));
|
||||
YGGDRASIL_LOGIN = new YggdrasilAuthenticator(clientToken);
|
||||
YGGDRASIL_LOGIN.onLoadSettings(Settings.getInstance().getAuthenticatorConfig(YGGDRASIL_LOGIN.id()));
|
||||
auths.add(new OfflineAuthenticator(clientToken));
|
||||
auths.add(new YggdrasilAuthenticator(clientToken));
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
Settings.getInstance().setAuthenticatorConfig(OFFLINE_LOGIN.id(), OFFLINE_LOGIN.onSaveSettings());
|
||||
Settings.getInstance().setAuthenticatorConfig(YGGDRASIL_LOGIN.id(), YGGDRASIL_LOGIN.onSaveSettings());
|
||||
}
|
||||
});
|
||||
apply.accept(OFFLINE_LOGIN);
|
||||
apply.accept(YGGDRASIL_LOGIN);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
for (IAuthenticator i : auths)
|
||||
Settings.getInstance().setAuthenticatorConfig(i.id(), i.onSaveSettings());
|
||||
}));
|
||||
for (IAuthenticator i : auths) {
|
||||
i.onLoadSettings(Settings.getInstance().getAuthenticatorConfig(i.id()));
|
||||
apply.accept(i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,13 +29,7 @@ import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.core.download.MinecraftDownloadService;
|
||||
import org.jackhuang.hellominecraft.launcher.core.launch.LaunchOptions;
|
||||
import org.jackhuang.hellominecraft.launcher.core.launch.MinecraftLoader;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftDownloadService;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftInstallerService;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftLoader;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftModService;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.*;
|
||||
import org.jackhuang.hellominecraft.launcher.core.mod.MinecraftModService;
|
||||
import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.Profile;
|
||||
@@ -60,7 +54,20 @@ public class HMCLMinecraftService extends IMinecraftService {
|
||||
this.provider = new HMCLGameProvider(this);
|
||||
provider.initializeMiencraft();
|
||||
provider.onRefreshingVersions.register(versionSettings::clear);
|
||||
provider.onRefreshedVersions.register(this::checkModpack);
|
||||
provider.onRefreshedVersions.register(() -> {
|
||||
if (!checkingModpack) {
|
||||
checkingModpack = true;
|
||||
if (version().getVersionCount() == 0) {
|
||||
File modpack = new File("modpack.zip");
|
||||
if (modpack.exists())
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (TaskWindow.factory().execute(ModpackManager.install(MainFrame.INSTANCE, modpack, this, null)))
|
||||
version().refreshVersions();
|
||||
checkedModpack = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
provider.onLoadedVersion.register(this::loadVersionSetting);
|
||||
this.mms = new MinecraftModService(this);
|
||||
this.mds = new MinecraftDownloadService(this);
|
||||
@@ -70,21 +77,6 @@ public class HMCLMinecraftService extends IMinecraftService {
|
||||
|
||||
public boolean checkedModpack = false, checkingModpack = false;
|
||||
|
||||
private void checkModpack() {
|
||||
if (!checkingModpack) {
|
||||
checkingModpack = true;
|
||||
if (version().getVersionCount() == 0) {
|
||||
File modpack = new File("modpack.zip");
|
||||
if (modpack.exists())
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (TaskWindow.execute(ModpackManager.install(MainFrame.INSTANCE, modpack, this, null)))
|
||||
version().refreshVersions();
|
||||
checkedModpack = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadVersionSetting(String id) {
|
||||
if (provider.getVersionById(id) == null)
|
||||
return;
|
||||
|
||||
@@ -101,7 +101,7 @@ public class AppDataUpgrader extends IUpgrader {
|
||||
@Override
|
||||
public boolean call(Object sender, final VersionNumber number) {
|
||||
((UpdateChecker) sender).requestDownloadLink().reg(map -> {
|
||||
if (MessageBox.Show(C.i18n("update.newest_version") + number.firstVer + "." + number.secondVer + "." + number.thirdVer + "\n"
|
||||
if (MessageBox.show(C.i18n("update.newest_version") + number.firstVer + "." + number.secondVer + "." + number.thirdVer + "\n"
|
||||
+ C.i18n("update.should_open_link"),
|
||||
MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
|
||||
if (map != null && map.containsKey("pack"))
|
||||
@@ -109,7 +109,7 @@ public class AppDataUpgrader extends IUpgrader {
|
||||
String hash = null;
|
||||
if (map.containsKey("packsha1"))
|
||||
hash = map.get("packsha1");
|
||||
if (TaskWindow.factory().append(new AppDataUpgraderTask(map.get("pack"), number.version, hash)).create()) {
|
||||
if (TaskWindow.factory().append(new AppDataUpgraderTask(map.get("pack"), number.version, hash)).execute()) {
|
||||
new ProcessBuilder(new String[] { IOUtils.getJavaDir(), "-jar", AppDataUpgraderTask.getSelf(number.version).getAbsolutePath() }).directory(new File(".")).start();
|
||||
System.exit(0);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class AppDataUpgrader extends IUpgrader {
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
HMCLog.warn("Failed to browse uri: " + url, e);
|
||||
Utils.setClipborad(url);
|
||||
MessageBox.Show(C.i18n("update.no_browser"));
|
||||
MessageBox.show(C.i18n("update.no_browser"));
|
||||
}
|
||||
}
|
||||
}).execute();
|
||||
@@ -162,7 +162,7 @@ public class AppDataUpgrader extends IUpgrader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() throws Exception {
|
||||
public void executeTask(boolean areDependTasksSucceeded) throws Exception {
|
||||
HashMap<String, String> json = new HashMap<>();
|
||||
File f = getSelf(newestVersion);
|
||||
if (!f.getParentFile().exists() && !f.getParentFile().mkdirs())
|
||||
|
||||
@@ -48,7 +48,7 @@ public class NewFileUpgrader extends IUpgrader {
|
||||
public boolean call(Object sender, VersionNumber number) {
|
||||
String str = requestDownloadLink();
|
||||
File newf = new File(FileUtils.getName(str));
|
||||
if (TaskWindow.factory().append(new FileDownloadTask(str, newf)).create()) {
|
||||
if (TaskWindow.factory().append(new FileDownloadTask(str, newf)).execute()) {
|
||||
try {
|
||||
new ProcessBuilder(new String[] { IOUtils.tryGetCanonicalFilePath(newf), "--removeOldLauncher", IOUtils.getRealPath() }).directory(new File(".")).start();
|
||||
} catch (IOException ex) {
|
||||
|
||||
@@ -18,12 +18,13 @@ package org.jackhuang.hellominecraft.lookandfeel;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.util.Map;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.plaf.synth.SynthLookAndFeel;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -37,7 +38,7 @@ public class HelloMinecraftLookAndFeel extends SynthLookAndFeel {
|
||||
* Creates a new instance of NimbusLookAndFeel
|
||||
*
|
||||
* @throws java.text.ParseException error parsing the xml, it must not
|
||||
* happen.
|
||||
* happen.
|
||||
*/
|
||||
public HelloMinecraftLookAndFeel() throws ParseException {
|
||||
this(DEFAULT_SETTINGS);
|
||||
@@ -45,14 +46,18 @@ public class HelloMinecraftLookAndFeel extends SynthLookAndFeel {
|
||||
|
||||
public HelloMinecraftLookAndFeel(Map<String, String> settings) throws ParseException {
|
||||
try {
|
||||
String s = NetUtils.getStreamContent(HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth.xml"), "UTF-8");
|
||||
for (String ss : settings.keySet())
|
||||
s = s.replace("${" + ss + "}", settings.get(ss));
|
||||
load(new ByteArrayInputStream(s.getBytes("UTF-8")), HelloMinecraftLookAndFeel.class);
|
||||
try (InputStream is = HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth.xml")) {
|
||||
String s = IOUtils.getStreamContent(is, "UTF-8");
|
||||
for (Map.Entry<String, String> ss : settings.entrySet())
|
||||
s = s.replace("${" + ss.getKey() + "}", ss.getValue());
|
||||
load(new ByteArrayInputStream(s.getBytes("UTF-8")), HelloMinecraftLookAndFeel.class);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
HMCLog.err("This fucking exception should not happen. Retry backup solution.", ex);
|
||||
try {
|
||||
load(HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth_backup.xml"), HelloMinecraftLookAndFeel.class);
|
||||
try (InputStream is = HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth_backup.xml")) {
|
||||
load(is, HelloMinecraftLookAndFeel.class);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
HMCLog.err("User fault", e);
|
||||
}
|
||||
|
||||
@@ -42,22 +42,22 @@ import org.jackhuang.hellominecraft.lookandfeel.comp.ConstomButton;
|
||||
public class ButtonPainter extends SynthPainter {
|
||||
|
||||
private static final String DEFAULT_NORMAL = "D5D5D5";
|
||||
private static final Color[] DEFAULT_NORMAL_FG = new Color[] {
|
||||
private static final Color[] DEFAULT_NORMAL_FG = new Color[]{
|
||||
GraphicsUtils.getWebColor(DEFAULT_NORMAL),
|
||||
GraphicsUtils.getWebColor(DEFAULT_NORMAL)
|
||||
};
|
||||
private static final String DEFAULT_PRELIGHT = "A9A9A9";
|
||||
private static final Color[] DEFAULT_PRELIGHT_FG = new Color[] {
|
||||
private static final Color[] DEFAULT_PRELIGHT_FG = new Color[]{
|
||||
GraphicsUtils.getWebColor(DEFAULT_PRELIGHT),
|
||||
GraphicsUtils.getWebColor(DEFAULT_PRELIGHT)
|
||||
};
|
||||
private static final String DEFAULT_ACTIVE = "222222";
|
||||
private static final Color[] DEFAULT_ACTIVE_FG = new Color[] {
|
||||
private static final Color[] DEFAULT_ACTIVE_FG = new Color[]{
|
||||
GraphicsUtils.getWebColor(DEFAULT_ACTIVE),
|
||||
GraphicsUtils.getWebColor(DEFAULT_ACTIVE)
|
||||
};
|
||||
|
||||
private static final Color[] DISABLED_BG = new Color[] {
|
||||
private static final Color[] DISABLED_BG = new Color[]{
|
||||
GraphicsUtils.getWebColor("E3EFE9"),
|
||||
GraphicsUtils.getMidWebColor("E3EFE9", "DFE2E6"),
|
||||
GraphicsUtils.getWebColor("DFE2E6"),
|
||||
@@ -68,7 +68,7 @@ public class ButtonPainter extends SynthPainter {
|
||||
GraphicsUtils.getWebColor("D8DBE1"),
|
||||
GraphicsUtils.getWebColor("DADDE3")
|
||||
};
|
||||
private static final Color[] DISABLED_FG = new Color[] {
|
||||
private static final Color[] DISABLED_FG = new Color[]{
|
||||
GraphicsUtils.getWebColor("C9CCD2"),
|
||||
GraphicsUtils.getWebColor("C9CCD2"),
|
||||
GraphicsUtils.getWebColor("BCBFC5"),
|
||||
@@ -106,8 +106,8 @@ public class ButtonPainter extends SynthPainter {
|
||||
if ((context.getComponentState() & SynthConstants.PRESSED) != 0)
|
||||
if (context.getComponent() instanceof ConstomButton) {
|
||||
ConstomButton c = (ConstomButton) context.getComponent();
|
||||
fg = new Color[] { c.activeFg, c.activeFg };
|
||||
bg = new Color[] { c.activeFg, c.activeFg };
|
||||
fg = new Color[]{c.activeFg, c.activeFg};
|
||||
bg = new Color[]{c.activeFg, c.activeFg};
|
||||
} else {
|
||||
fg = DEFAULT_ACTIVE_FG;
|
||||
bg = DEFAULT_ACTIVE_FG;
|
||||
@@ -122,8 +122,8 @@ public class ButtonPainter extends SynthPainter {
|
||||
return;
|
||||
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
|
||||
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
|
||||
fg = new Color[] { fgs, fgs };
|
||||
bg = new Color[] { bgs, bgs };
|
||||
fg = new Color[]{fgs, fgs};
|
||||
bg = new Color[]{bgs, bgs};
|
||||
} else {
|
||||
fg = DEFAULT_PRELIGHT_FG;
|
||||
bg = DEFAULT_PRELIGHT_FG;
|
||||
@@ -134,8 +134,8 @@ public class ButtonPainter extends SynthPainter {
|
||||
return;
|
||||
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
|
||||
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
|
||||
fg = new Color[] { fgs, fgs };
|
||||
bg = new Color[] { bgs, bgs };
|
||||
fg = new Color[]{fgs, fgs};
|
||||
bg = new Color[]{bgs, bgs};
|
||||
} else {
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
@@ -143,8 +143,8 @@ public class ButtonPainter extends SynthPainter {
|
||||
else if ((context.getComponentState() & SynthConstants.PRESSED) != 0)
|
||||
if (context.getComponent() instanceof ConstomButton) {
|
||||
ConstomButton c = (ConstomButton) context.getComponent();
|
||||
fg = new Color[] { c.activeFg, c.activeFg };
|
||||
bg = new Color[] { c.activeFg, c.activeFg };
|
||||
fg = new Color[]{c.activeFg, c.activeFg};
|
||||
bg = new Color[]{c.activeFg, c.activeFg};
|
||||
} else {
|
||||
fg = DEFAULT_ACTIVE_FG;
|
||||
bg = DEFAULT_ACTIVE_FG;
|
||||
@@ -159,12 +159,12 @@ public class ButtonPainter extends SynthPainter {
|
||||
return;
|
||||
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
|
||||
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
|
||||
fg = new Color[] { fgs, fgs };
|
||||
bg = new Color[] { bgs, bgs };
|
||||
fg = new Color[]{fgs, fgs};
|
||||
bg = new Color[]{bgs, bgs};
|
||||
} else if (context.getComponent() instanceof ConstomButton) {
|
||||
ConstomButton c = (ConstomButton) context.getComponent();
|
||||
fg = new Color[] { c.prelightFg, c.prelightFg };
|
||||
bg = new Color[] { c.prelightBg, c.prelightBg };
|
||||
fg = new Color[]{c.prelightFg, c.prelightFg};
|
||||
bg = new Color[]{c.prelightBg, c.prelightBg};
|
||||
} else {
|
||||
fg = DEFAULT_PRELIGHT_FG;
|
||||
bg = DEFAULT_PRELIGHT_FG;
|
||||
@@ -175,8 +175,8 @@ public class ButtonPainter extends SynthPainter {
|
||||
return;
|
||||
Color fgs = GraphicsUtils.getMidWebColor(c.normalFg, c.prelightFg, c.drawPercent);
|
||||
Color bgs = GraphicsUtils.getMidWebColor(c.normalBg, c.prelightBg, c.drawPercent);
|
||||
fg = new Color[] { fgs, fgs };
|
||||
bg = new Color[] { bgs, bgs };
|
||||
fg = new Color[]{fgs, fgs};
|
||||
bg = new Color[]{bgs, bgs};
|
||||
} else {
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
@@ -207,21 +207,8 @@ public class ButtonPainter extends SynthPainter {
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
Color[] fg, bg;
|
||||
if ((context.getComponentState() & SynthConstants.DEFAULT) != 0)
|
||||
if ((context.getComponentState() & SynthConstants.PRESSED) != 0 || (context.getComponentState() & SynthConstants.SELECTED) != 0) {
|
||||
fg = DEFAULT_ACTIVE_FG;
|
||||
bg = DEFAULT_ACTIVE_FG;
|
||||
} else if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
|
||||
fg = DISABLED_FG;
|
||||
bg = DISABLED_BG;
|
||||
} else if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0) {
|
||||
fg = DEFAULT_PRELIGHT_FG;
|
||||
bg = DEFAULT_PRELIGHT_FG;
|
||||
} else {
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
}
|
||||
else if ((context.getComponentState() & SynthConstants.PRESSED) != 0 || (context.getComponentState() & SynthConstants.SELECTED) != 0) {
|
||||
//if ((context.getComponentState() & SynthConstants.DEFAULT) != 0)
|
||||
if ((context.getComponentState() & SynthConstants.PRESSED) != 0 || (context.getComponentState() & SynthConstants.SELECTED) != 0) {
|
||||
fg = DEFAULT_ACTIVE_FG;
|
||||
bg = DEFAULT_ACTIVE_FG;
|
||||
} else if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
|
||||
@@ -234,6 +221,19 @@ public class ButtonPainter extends SynthPainter {
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
}
|
||||
/*else if ((context.getComponentState() & SynthConstants.PRESSED) != 0 || (context.getComponentState() & SynthConstants.SELECTED) != 0) {
|
||||
fg = DEFAULT_ACTIVE_FG;
|
||||
bg = DEFAULT_ACTIVE_FG;
|
||||
} else if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
|
||||
fg = DISABLED_FG;
|
||||
bg = DISABLED_BG;
|
||||
} else if ((context.getComponentState() & SynthConstants.MOUSE_OVER) != 0) {
|
||||
fg = DEFAULT_PRELIGHT_FG;
|
||||
bg = DEFAULT_PRELIGHT_FG;
|
||||
} else {
|
||||
fg = DEFAULT_NORMAL_FG;
|
||||
bg = DEFAULT_NORMAL_FG;
|
||||
}*/
|
||||
g2.setColor(fg[0]);
|
||||
Rectangle2D fgshape = new Rectangle2D.Float(x, y, w, h);
|
||||
g2.draw(fgshape);
|
||||
|
||||
@@ -18,6 +18,8 @@ import java.awt.Container;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.plaf.basic.BasicComboPopup;
|
||||
import javax.swing.plaf.basic.ComboPopup;
|
||||
|
||||
/**
|
||||
* NimbusComboBoxUI
|
||||
@@ -87,6 +89,13 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
return new Dimension(size);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ComboPopup createPopup() {
|
||||
BasicComboPopup p = new BasicComboPopup(comboBox);
|
||||
//p.setPopupSize(100, comboBox.getPreferredSize().height);
|
||||
return p;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JButton createArrowButton() {
|
||||
JButton button = new JButton() {
|
||||
@@ -101,8 +110,8 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
else if (mouseInside)
|
||||
img = COMBO_OVER;
|
||||
g.drawImage(img,
|
||||
0, 0, getWidth(), getHeight(),
|
||||
0, 0, img.getWidth(), img.getHeight(), comboBox);
|
||||
0, 0, getWidth(), getHeight(),
|
||||
0, 0, img.getWidth(), img.getHeight(), comboBox);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -141,14 +150,14 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
else if (mouseInside)
|
||||
img = COMBO_OVER;
|
||||
g.drawImage(img,
|
||||
bounds.x, bounds.y, bounds.x + 4, bounds.y + bounds.height,
|
||||
0, 0, 1, 26, comboBox);
|
||||
bounds.x, bounds.y, bounds.x + 4, bounds.y + bounds.height,
|
||||
0, 0, 1, 26, comboBox);
|
||||
g.drawImage(img,
|
||||
bounds.x + 1, bounds.y, bounds.x + bounds.width - 25, bounds.y + bounds.height,
|
||||
1, 0, 3, 26, comboBox);
|
||||
bounds.x + 1, bounds.y, bounds.x + bounds.width - 25, bounds.y + bounds.height,
|
||||
1, 0, 3, 26, comboBox);
|
||||
g.drawImage(img,
|
||||
bounds.x + bounds.width - 25, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height,
|
||||
4, 0, 29, 26, comboBox);
|
||||
bounds.x + bounds.width - 25, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height,
|
||||
4, 0, 29, 26, comboBox);
|
||||
} else {
|
||||
/*g.setColor(Color.WHITE);
|
||||
g.fillRect(bounds.x, bounds.y, bounds.width - btnSize.width, bounds.height - 1);
|
||||
@@ -257,23 +266,25 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
|
||||
|
||||
@Override
|
||||
public void layoutContainer(Container parent) {
|
||||
JComboBox cb = (JComboBox) parent;
|
||||
int width = cb.getWidth();
|
||||
if (parent instanceof JComboBox) {
|
||||
JComboBox cb = (JComboBox) parent;
|
||||
int width = cb.getWidth();
|
||||
|
||||
Insets insets = getInsets();
|
||||
Rectangle cvb;
|
||||
Insets insets = getInsets();
|
||||
Rectangle cvb;
|
||||
|
||||
if (arrowButton != null)
|
||||
if (cb.getComponentOrientation().isLeftToRight())
|
||||
arrowButton.setBounds(width - (insets.right + btnSize.width),
|
||||
insets.top,
|
||||
btnSize.width, btnSize.height);
|
||||
else
|
||||
arrowButton.setBounds(insets.left, insets.top,
|
||||
btnSize.width, btnSize.height);
|
||||
if (editor != null) {
|
||||
cvb = rectangleForCurrentValue();
|
||||
editor.setBounds(cvb.x, cvb.y, cvb.width, cvb.height);
|
||||
if (arrowButton != null)
|
||||
if (cb.getComponentOrientation().isLeftToRight())
|
||||
arrowButton.setBounds(width - (insets.right + btnSize.width),
|
||||
insets.top,
|
||||
btnSize.width, btnSize.height);
|
||||
else
|
||||
arrowButton.setBounds(insets.left, insets.top,
|
||||
btnSize.width, btnSize.height);
|
||||
if (editor != null) {
|
||||
cvb = rectangleForCurrentValue();
|
||||
editor.setBounds(cvb.x, cvb.y, cvb.width, cvb.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.awt.Graphics;
|
||||
* @author Created by Jasper Potts (Jan 17, 2007)
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ScrollButton extends MetalScrollButton implements SwingConstants {
|
||||
public class ScrollButton extends MetalScrollButton {
|
||||
|
||||
private final int btnWidth, btnHeight;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ buildscript {
|
||||
mavenCentral();
|
||||
dependencies {
|
||||
classpath 'edu.sc.seis.gradle:launch4j:1.0.6'
|
||||
classpath 'me.tatarka:gradle-retrolambda:3.1.0'
|
||||
classpath 'me.tatarka:gradle-retrolambda:3.4.0'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Main {
|
||||
} catch (ParseException | UnsupportedLookAndFeelException ex) {
|
||||
HMCLog.warn("Failed to set look and feel", ex);
|
||||
}
|
||||
UPDATE_CHECKER.process(false).reg(t -> MessageBox.Show("发现更新!" + t.version)).execute();
|
||||
UPDATE_CHECKER.process(false).reg(t -> MessageBox.show("发现更新!" + t.version)).execute();
|
||||
new MainWindow().setVisible(true);
|
||||
} catch (Throwable t) {
|
||||
HMCLog.err("There's something wrong when running server holder.", t);
|
||||
|
||||
@@ -41,7 +41,6 @@ import org.jackhuang.hellominecraft.util.code.DigestUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.tasks.TaskWindow;
|
||||
import org.jackhuang.hellominecraft.util.tasks.download.FileDownloadTask;
|
||||
@@ -67,7 +66,7 @@ public class ForgeInstaller {
|
||||
|
||||
ZipFile zipFile = new ZipFile(forgeInstaller);
|
||||
ZipEntry entry = zipFile.getEntry("install_profile.json");
|
||||
String content = NetUtils.getStreamContent(zipFile.getInputStream(entry));
|
||||
String content = IOUtils.getStreamContent(zipFile.getInputStream(entry));
|
||||
InstallProfile profile = gson.fromJson(content, InstallProfile.class);
|
||||
|
||||
HMCLog.log("Extracting cauldron server pack..." + profile.install.filePath);
|
||||
@@ -88,8 +87,8 @@ public class ForgeInstaller {
|
||||
File minecraftserver = new File(gameDir, "minecraft_server." + profile.install.minecraft + ".jar");
|
||||
if (minecraftserver.exists() && JOptionPane.showConfirmDialog(null, "已发现官方服务端文件,是否要重新下载?") == JOptionPane.YES_OPTION)
|
||||
if (!TaskWindow.factory().append(new FileDownloadTask("https://s3.amazonaws.com/Minecraft.Download/versions/{MCVER}/minecraft_server.{MCVER}.jar".replace("{MCVER}", profile.install.minecraft),
|
||||
minecraftserver).setTag("minecraft_server")).create())
|
||||
MessageBox.Show("Minecraft官方服务端下载失败!");
|
||||
minecraftserver).setTag("minecraft_server")).execute())
|
||||
MessageBox.show("Minecraft官方服务端下载失败!");
|
||||
TaskWindow.TaskWindowFactory tw = TaskWindow.factory();
|
||||
for (MinecraftLibrary library : profile.versionInfo.libraries) {
|
||||
library.init();
|
||||
@@ -99,8 +98,8 @@ public class ForgeInstaller {
|
||||
libURL = library.url;
|
||||
tw.append(new FileDownloadTask(libURL + library.formatted.replace("\\", "/"), lib).setTag(library.name));
|
||||
}
|
||||
if (!tw.create())
|
||||
MessageBox.Show("压缩库下载失败!");
|
||||
if (!tw.execute())
|
||||
MessageBox.show("压缩库下载失败!");
|
||||
|
||||
tw = TaskWindow.factory();
|
||||
for (MinecraftLibrary library : profile.versionInfo.libraries) {
|
||||
@@ -114,8 +113,8 @@ public class ForgeInstaller {
|
||||
libURL = library.url;
|
||||
tw.append(new FileDownloadTask(libURL + library.formatted.replace("\\", "/"), lib).setTag(library.name));
|
||||
}
|
||||
if (!tw.create())
|
||||
MessageBox.Show("库下载失败!");
|
||||
if (!tw.execute())
|
||||
MessageBox.show("库下载失败!");
|
||||
|
||||
ArrayList<String> badLibs = new ArrayList<>();
|
||||
for (MinecraftLibrary library : profile.versionInfo.libraries) {
|
||||
@@ -123,7 +122,7 @@ public class ForgeInstaller {
|
||||
File packFile = new File(gameDir, "libraries" + File.separator + library.formatted + ".pack.xz");
|
||||
if (packFile.exists() && packFile.isFile())
|
||||
try {
|
||||
unpackLibrary(lib.getParentFile(), NetUtils.getBytesFromStream(FileUtils.openInputStream(packFile)));
|
||||
unpackLibrary(lib.getParentFile(), IOUtils.getBytesFromStream(FileUtils.openInputStream(packFile)));
|
||||
if (!checksumValid(lib, Arrays.asList(library.checksums)))
|
||||
badLibs.add(library.name);
|
||||
} catch (IOException e) {
|
||||
@@ -132,7 +131,7 @@ public class ForgeInstaller {
|
||||
}
|
||||
}
|
||||
if (badLibs.size() > 0)
|
||||
MessageBox.Show("这些库在解压的时候出现了问题" + badLibs.toString());
|
||||
MessageBox.show("这些库在解压的时候出现了问题" + badLibs.toString());
|
||||
}
|
||||
|
||||
public static void unpackLibrary(File output, byte[] data)
|
||||
@@ -166,7 +165,7 @@ public class ForgeInstaller {
|
||||
|
||||
private static boolean checksumValid(File libPath, List<String> checksums) {
|
||||
try {
|
||||
byte[] fileData = NetUtils.getBytesFromStream(FileUtils.openInputStream(libPath));
|
||||
byte[] fileData = IOUtils.getBytesFromStream(FileUtils.openInputStream(libPath));
|
||||
boolean valid = (checksums == null) || (checksums.isEmpty()) || (checksums.contains(DigestUtils.sha1Hex(fileData)));
|
||||
if ((!valid) && (libPath.getName().endsWith(".jar")))
|
||||
valid = validateJar(libPath, fileData, checksums);
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.system.Compressor;
|
||||
import org.jackhuang.hellominecraft.util.system.CompressingUtils;
|
||||
import org.jackhuang.hellominecraft.svrmgr.setting.SettingsManager;
|
||||
import org.jackhuang.hellominecraft.svrmgr.util.Utilities;
|
||||
import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||
@@ -50,7 +50,7 @@ public class BackupManager {
|
||||
public void run() {
|
||||
try {
|
||||
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
|
||||
Compressor.zip(Utilities.getGameDir() + folder + File.separator,
|
||||
CompressingUtils.zip(Utilities.getGameDir() + folder + File.separator,
|
||||
backupDir() + "world+" + f.format(new Date()) + "+" + folder + ".zip");
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to compress world pack.", ex);
|
||||
@@ -79,7 +79,7 @@ public class BackupManager {
|
||||
File world = new File(Utilities.getGameDir() + folder + File.separator);
|
||||
FileUtils.deleteDirectoryQuietly(world);
|
||||
world.mkdirs();
|
||||
Compressor.unzip(backupFile, world);
|
||||
CompressingUtils.unzip(backupFile, world);
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to decompress world pack.", ex);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class BackupManager {
|
||||
public void run() {
|
||||
try {
|
||||
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
|
||||
Compressor.zip(Utilities.getGameDir() + "plugins" + File.separator,
|
||||
CompressingUtils.zip(Utilities.getGameDir() + "plugins" + File.separator,
|
||||
backupDir() + "plugin+" + f.format(new Date()) + "+plugins.zip");
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to compress world pack with plugins.", ex);
|
||||
|
||||
@@ -235,7 +235,7 @@ public class Server implements Event<Integer>, MonitorThread.MonitorThreadListen
|
||||
try {
|
||||
run();
|
||||
} catch (IOException ex) {
|
||||
MessageBox.Show("重启失败!");
|
||||
MessageBox.show("重启失败!");
|
||||
HMCLog.warn("Failed to launch!", ex);
|
||||
}
|
||||
isRestart = false;
|
||||
|
||||
@@ -2975,7 +2975,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeTask() {
|
||||
public void executeTask(boolean areDependTasksSucceeded) {
|
||||
javax.swing.JTable table = MainWindow.this.lstDownloads;
|
||||
DefaultTableModel model = (DefaultTableModel) table.getModel();
|
||||
|
||||
@@ -2999,7 +2999,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
|
||||
void refreshDownloads() {
|
||||
clearListDownloads();
|
||||
TaskWindow.factory().append(new RefreshDownloadsDone()).create();
|
||||
TaskWindow.factory().append(new RefreshDownloadsDone()).execute();
|
||||
}
|
||||
|
||||
void refreshInfos() {
|
||||
@@ -3092,7 +3092,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
lstPlayers.setModel(lstPlayersModel);
|
||||
});
|
||||
else
|
||||
MessageBox.Show("服务器未开启!");
|
||||
MessageBox.show("服务器未开启!");
|
||||
}
|
||||
|
||||
class ServerBeginListener implements Event<Void> {
|
||||
@@ -3137,7 +3137,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
else if (option == JOptionPane.NO_OPTION)
|
||||
FileUtils.write(eula, "eula=false");
|
||||
} catch (IOException e) {
|
||||
MessageBox.Show("确认rula失败");
|
||||
MessageBox.show("确认rula失败");
|
||||
}
|
||||
}
|
||||
File serverproperties = new File(new File(SettingsManager.settings.mainjar).getParentFile(), "server.properties");
|
||||
@@ -3164,7 +3164,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
try {
|
||||
Server.getInstance().run();
|
||||
} catch (IOException ex) {
|
||||
MessageBox.Show("启动服务端失败!");
|
||||
MessageBox.show("启动服务端失败!");
|
||||
HMCLog.err("Failed to launch!", ex);
|
||||
}
|
||||
}//GEN-LAST:event_btnLaunchActionPerformed
|
||||
@@ -3335,7 +3335,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
op.saveAsBoth(new File(dir, "ops.txt"), new File(dir, "ops.json"));
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to save ops", ex);
|
||||
MessageBox.Show("添加失败。。。");
|
||||
MessageBox.show("添加失败。。。");
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_btnAddOPActionPerformed
|
||||
@@ -3355,7 +3355,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
op.saveAsBoth(new File(dir, "ops.txt"), new File(dir, "ops.json"));
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to save ops", ex);
|
||||
MessageBox.Show("删除失败。。。");
|
||||
MessageBox.show("删除失败。。。");
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_btnDeleteOPActionPerformed
|
||||
@@ -3374,7 +3374,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
whitelist.saveAsBoth(new File(dir, "white-list.txt"), new File(dir, "white-list.json"));
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to save white-list", ex);
|
||||
MessageBox.Show("添加失败。。。");
|
||||
MessageBox.show("添加失败。。。");
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_btnAddWhiteActionPerformed
|
||||
@@ -3394,7 +3394,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
whitelist.saveAsBoth(new File(dir, "white-list.txt"), new File(dir, "white-list.json"));
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to save white-list", ex);
|
||||
MessageBox.Show("删除失败。。。");
|
||||
MessageBox.show("删除失败。。。");
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_btnDeleteWhiteActionPerformed
|
||||
@@ -3421,7 +3421,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
model.addRow(new Object[] { fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf)) });
|
||||
lstExternalMods.updateUI();
|
||||
} catch (IOException e) {
|
||||
MessageBox.Show(C.i18n("mods.failed"));
|
||||
MessageBox.show(C.i18n("mods.failed"));
|
||||
HMCLog.warn("Failed to add ext mods", e);
|
||||
}
|
||||
}//GEN-LAST:event_btnAddExternelModActionPerformed
|
||||
@@ -3460,7 +3460,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
model.addRow(new Object[] { fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf)) });
|
||||
FileUtils.copyFile(new File(path), newf);
|
||||
} catch (IOException e) {
|
||||
MessageBox.Show(C.i18n("mods.failed"));
|
||||
MessageBox.show(C.i18n("mods.failed"));
|
||||
HMCLog.warn("Failed to add ext core mod.", e);
|
||||
}
|
||||
}//GEN-LAST:event_btnAddExternelCoreModActionPerformed
|
||||
@@ -3500,7 +3500,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
model.addRow(new Object[] { fc.getSelectedFile().getName(), ModType.getModTypeShowName(ModType.getModType(newf)) });
|
||||
FileUtils.copyFile(new File(path), newf);
|
||||
} catch (IOException e) {
|
||||
MessageBox.Show(C.i18n("mods.failed"));
|
||||
MessageBox.show(C.i18n("mods.failed"));
|
||||
HMCLog.warn("Failed to add plugin", e);
|
||||
}
|
||||
}//GEN-LAST:event_btnAddPluginsActionPerformed
|
||||
@@ -3566,7 +3566,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
whitelist.saveAsBoth(new File(dir, "banned-players.txt"), new File(dir, "banned-players.json"));
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to save banned-players", ex);
|
||||
MessageBox.Show(C.i18n("mods.failed"));
|
||||
MessageBox.show(C.i18n("mods.failed"));
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_btnAddBanActionPerformed
|
||||
@@ -3606,7 +3606,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
resizeBackgroundLabel();
|
||||
} catch (IOException e) {
|
||||
HMCLog.warn("Failed to set background path", e);
|
||||
MessageBox.Show(C.i18n("ui.label.failed_set") + e.getMessage());
|
||||
MessageBox.show(C.i18n("ui.label.failed_set") + e.getMessage());
|
||||
}
|
||||
}//GEN-LAST:event_btnSetBackgroundPathActionPerformed
|
||||
|
||||
@@ -3628,7 +3628,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
s.per = Double.parseDouble(txtTimerTaskPeriod.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
HMCLog.warn("Failed to parse double: " + txtTimerTaskPeriod.getText(), e);
|
||||
MessageBox.Show("错误的间隔时间");
|
||||
MessageBox.show("错误的间隔时间");
|
||||
return;
|
||||
}
|
||||
SettingsManager.settings.schedules.add(s);
|
||||
@@ -3720,7 +3720,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
serverjar.delete();
|
||||
|
||||
String downloadURL = url + "minecraft_server." + id + ".jar";
|
||||
TaskWindow.factory().append(new FileDownloadTask(downloadURL, serverjar).setTag(id)).create();
|
||||
TaskWindow.factory().append(new FileDownloadTask(downloadURL, serverjar).setTag(id)).execute();
|
||||
}//GEN-LAST:event_btnMinecraftServerDownloadActionPerformed
|
||||
|
||||
private void btnRefreshInfosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshInfosActionPerformed
|
||||
@@ -3783,7 +3783,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
txtCrashReport.setText(content);
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to get crash-report.", ex);
|
||||
MessageBox.Show("无法获取崩溃报告");
|
||||
MessageBox.show("无法获取崩溃报告");
|
||||
}
|
||||
}//GEN-LAST:event_btnShowReportActionPerformed
|
||||
|
||||
@@ -3855,7 +3855,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
BukkitVersion v = cb.get(idx);
|
||||
File file = new File("craftbukkit-" + ext + "-" + v.version + ".jar");
|
||||
TaskWindow.factory().append(new FileDownloadTask(v.downloadLink, IOUtils.tryGetCanonicalFile(file)).setTag("bukkit-" + ext + "-" + v.version))
|
||||
.create();
|
||||
.execute();
|
||||
}//GEN-LAST:event_btnDownloadCraftbukkitActionPerformed
|
||||
|
||||
private void btnDownloadMCPCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadMCPCActionPerformed
|
||||
@@ -3866,8 +3866,8 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
String url;
|
||||
File filepath = new File("forge-installer.jar");
|
||||
url = v.installer[1];
|
||||
if (!TaskWindow.factory().append(new FileDownloadTask(url, filepath).setTag("cauldron-" + v.ver)).create())
|
||||
MessageBox.Show(C.i18n("install.failed_download_forge"));
|
||||
if (!TaskWindow.factory().append(new FileDownloadTask(url, filepath).setTag("cauldron-" + v.ver)).execute())
|
||||
MessageBox.show(C.i18n("install.failed_download_forge"));
|
||||
else
|
||||
installMCPC(filepath);
|
||||
}//GEN-LAST:event_btnDownloadMCPCActionPerformed
|
||||
@@ -3876,10 +3876,10 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
try {
|
||||
ForgeInstaller installer = new ForgeInstaller(new File("."), filepath);
|
||||
installer.install();
|
||||
MessageBox.Show(C.i18n("install.success"));
|
||||
MessageBox.show(C.i18n("install.success"));
|
||||
} catch (Exception e) {
|
||||
HMCLog.warn("Failed to install liteloader", e);
|
||||
MessageBox.Show(C.i18n("install.failed_forge"));
|
||||
MessageBox.show(C.i18n("install.failed_forge"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3907,7 +3907,7 @@ public final class MainWindow extends javax.swing.JFrame
|
||||
private void btnInstallMCPCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInstallMCPCActionPerformed
|
||||
File filepath = new File("forge-installer.jar");
|
||||
if (!filepath.exists()) {
|
||||
MessageBox.Show("您还未下载Cauldron!请点击下载按钮下载并自动安装!");
|
||||
MessageBox.show("您还未下载Cauldron!请点击下载按钮下载并自动安装!");
|
||||
return;
|
||||
}
|
||||
installMCPC(filepath);
|
||||
|
||||
@@ -234,7 +234,7 @@ public class PluginInfoDialog extends javax.swing.JDialog {
|
||||
TaskWindow.factory()
|
||||
.append(new FileDownloadTask(url, new File(Utilities.getGameDir() + "plugins"
|
||||
+ File.separator + pi.versions.get(index).filename)))
|
||||
.create();
|
||||
.execute();
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
||||
@@ -32,7 +32,7 @@ public class FolderOpener {
|
||||
f.mkdirs();
|
||||
java.awt.Desktop.getDesktop().open(f);
|
||||
} catch (Exception ex) {
|
||||
MessageBox.Show("无法打开资源管理器: " + ex.getMessage());
|
||||
MessageBox.show("无法打开资源管理器: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.jackhuang.hellominecraft.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -26,7 +25,10 @@ import java.util.Map;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class ArrayUtils {
|
||||
public final class ArrayUtils {
|
||||
|
||||
private ArrayUtils() {
|
||||
}
|
||||
|
||||
public static <T> boolean isEmpty(T[] array) {
|
||||
return array == null || array.length <= 0;
|
||||
@@ -72,42 +74,20 @@ public class ArrayUtils {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static ArrayList merge(List a, List b) {
|
||||
public static <T> ArrayList<T> merge(List<T> a, List<T> b) {
|
||||
ArrayList al = new ArrayList(a.size() + b.size());
|
||||
al.addAll(a);
|
||||
al.addAll(b);
|
||||
return al;
|
||||
}
|
||||
|
||||
public static <K> K getEnd(K[] k) {
|
||||
if (k == null)
|
||||
return null;
|
||||
else
|
||||
return k[k.length - 1];
|
||||
}
|
||||
|
||||
public static List tryGetMapWithList(Map map, String key) {
|
||||
List l = (List) map.get(key);
|
||||
if (l == null)
|
||||
map.put(key, l = new ArrayList());
|
||||
return l;
|
||||
}
|
||||
|
||||
public static <T> int matchArray(T[] a, T[] b) {
|
||||
for (int i = 0; i < a.length - b.length; i++) {
|
||||
int j = 1;
|
||||
for (int k = 0; k < b.length; k++) {
|
||||
if (b[k].equals(a[(i + k)]))
|
||||
continue;
|
||||
j = 0;
|
||||
break;
|
||||
}
|
||||
if (j != 0)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public static <T> int matchArray(byte[] a, byte[] b) {
|
||||
for (int i = 0; i < a.length - b.length; i++) {
|
||||
int j = 1;
|
||||
@@ -122,19 +102,4 @@ public class ArrayUtils {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static <T> boolean equals(T[] a, T[] b) {
|
||||
if (a == null && b == null)
|
||||
return true;
|
||||
if (a == null || b == null)
|
||||
return false;
|
||||
if (a.length != b.length)
|
||||
return false;
|
||||
Arrays.sort(a);
|
||||
Arrays.sort(b);
|
||||
for (int i = 0; i < a.length; i++)
|
||||
if (a[i] == null && b[i] != null || a[i] != null && b[i] == null || !a[i].equals(b[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ import java.util.Iterator;
|
||||
*/
|
||||
public final class CollectionUtils {
|
||||
|
||||
private CollectionUtils() {
|
||||
}
|
||||
|
||||
public static <T> ArrayList<T> map(Collection<T> coll, Predicate<T> p) {
|
||||
ArrayList<T> newColl = new ArrayList<>();
|
||||
for (T t : coll)
|
||||
|
||||
@@ -21,7 +21,10 @@ package org.jackhuang.hellominecraft.util;
|
||||
*
|
||||
* @author huang
|
||||
*/
|
||||
public class MathUtils {
|
||||
public final class MathUtils {
|
||||
|
||||
private MathUtils() {
|
||||
}
|
||||
|
||||
public static int parseInt(String s, int def) {
|
||||
try {
|
||||
|
||||
@@ -92,7 +92,7 @@ public class MessageBox {
|
||||
*
|
||||
* @return user operation.
|
||||
*/
|
||||
public static int Show(String Msg, String Title, int Option) {
|
||||
public static int show(String Msg, String Title, int Option) {
|
||||
switch (Option) {
|
||||
case YES_NO_OPTION:
|
||||
case YES_NO_CANCEL_OPTION:
|
||||
@@ -112,8 +112,8 @@ public class MessageBox {
|
||||
*
|
||||
* @return User Operation
|
||||
*/
|
||||
public static int Show(String Msg, int Option) {
|
||||
return Show(Msg, TITLE, Option);
|
||||
public static int show(String Msg, int Option) {
|
||||
return show(Msg, TITLE, Option);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,11 +123,11 @@ public class MessageBox {
|
||||
*
|
||||
* @return User Operation
|
||||
*/
|
||||
public static int Show(String Msg) {
|
||||
return Show(Msg, TITLE, INFORMATION_MESSAGE);
|
||||
public static int show(String Msg) {
|
||||
return show(Msg, TITLE, INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
public static int ShowLocalized(String msg) {
|
||||
return Show(C.i18n(msg));
|
||||
public static int showLocalized(String msg) {
|
||||
return show(C.i18n(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.ArrayUtils;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
|
||||
/**
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class MinecraftVersionRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final int UNKOWN = 0, INVALID = 1, INVALID_JAR = 2,
|
||||
MODIFIED = 3, OK = 4, NOT_FOUND = 5, UNREADABLE = 6, NOT_FILE = 7;
|
||||
@@ -38,34 +38,25 @@ public class MinecraftVersionRequest implements Serializable {
|
||||
public String version;
|
||||
|
||||
public static String getResponse(MinecraftVersionRequest minecraftVersion) {
|
||||
String text = "";
|
||||
switch (minecraftVersion.type) {
|
||||
case MinecraftVersionRequest.INVALID:
|
||||
text = C.i18n("minecraft.invalid");
|
||||
break;
|
||||
return C.i18n("minecraft.invalid");
|
||||
case MinecraftVersionRequest.INVALID_JAR:
|
||||
text = C.i18n("minecraft.invalid_jar");
|
||||
break;
|
||||
return C.i18n("minecraft.invalid_jar");
|
||||
case MinecraftVersionRequest.NOT_FILE:
|
||||
text = C.i18n("minecraft.not_a_file");
|
||||
break;
|
||||
return C.i18n("minecraft.not_a_file");
|
||||
case MinecraftVersionRequest.NOT_FOUND:
|
||||
text = C.i18n("minecraft.not_found");
|
||||
break;
|
||||
return C.i18n("minecraft.not_found");
|
||||
case MinecraftVersionRequest.UNREADABLE:
|
||||
text = C.i18n("minecraft.not_readable");
|
||||
break;
|
||||
return C.i18n("minecraft.not_readable");
|
||||
case MinecraftVersionRequest.MODIFIED:
|
||||
text = C.i18n("minecraft.modified") + " ";
|
||||
return C.i18n("minecraft.modified") + ' ' + minecraftVersion.version;
|
||||
case MinecraftVersionRequest.OK:
|
||||
text += minecraftVersion.version;
|
||||
break;
|
||||
return minecraftVersion.version;
|
||||
case MinecraftVersionRequest.UNKOWN:
|
||||
default:
|
||||
text = "???";
|
||||
break;
|
||||
return "???";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static int lessThan32(byte[] b, int x) {
|
||||
@@ -77,11 +68,11 @@ public class MinecraftVersionRequest implements Serializable {
|
||||
|
||||
private static MinecraftVersionRequest getVersionOfOldMinecraft(ZipFile file, ZipEntry entry) throws IOException {
|
||||
MinecraftVersionRequest r = new MinecraftVersionRequest();
|
||||
byte[] tmp = NetUtils.getBytesFromStream(file.getInputStream(entry));
|
||||
byte[] tmp = IOUtils.getBytesFromStream(file.getInputStream(entry));
|
||||
|
||||
byte[] bytes = "Minecraft Minecraft ".getBytes("ASCII");
|
||||
int j;
|
||||
if ((j = ArrayUtils.matchArray(tmp, bytes)) < 0) {
|
||||
int j = ArrayUtils.matchArray(tmp, bytes);
|
||||
if (j < 0) {
|
||||
r.type = MinecraftVersionRequest.UNKOWN;
|
||||
return r;
|
||||
}
|
||||
@@ -101,7 +92,7 @@ public class MinecraftVersionRequest implements Serializable {
|
||||
|
||||
private static MinecraftVersionRequest getVersionOfNewMinecraft(ZipFile file, ZipEntry entry) throws IOException {
|
||||
MinecraftVersionRequest r = new MinecraftVersionRequest();
|
||||
byte[] tmp = NetUtils.getBytesFromStream(file.getInputStream(entry));
|
||||
byte[] tmp = IOUtils.getBytesFromStream(file.getInputStream(entry));
|
||||
|
||||
byte[] str = "-server.txt".getBytes("ASCII");
|
||||
int j = ArrayUtils.matchArray(tmp, str);
|
||||
@@ -145,7 +136,7 @@ public class MinecraftVersionRequest implements Serializable {
|
||||
while (tmp[k] >= 48 && tmp[k] <= 57 || tmp[k] == (int) '-' || tmp[k] == (int) '.' || tmp[k] >= 97 && tmp[k] <= (int) 'z')
|
||||
k--;
|
||||
k++;
|
||||
r.version = new String(tmp, k, i - k + 1);
|
||||
r.version = new String(tmp, k, i - k + 1, "ASCII");
|
||||
}
|
||||
r.type = file.getEntry("META-INF/MANIFEST.MF") == null
|
||||
? MinecraftVersionRequest.MODIFIED : MinecraftVersionRequest.OK;
|
||||
@@ -166,27 +157,27 @@ public class MinecraftVersionRequest implements Serializable {
|
||||
r.type = MinecraftVersionRequest.UNREADABLE;
|
||||
return r;
|
||||
}
|
||||
ZipFile localZipFile = null;
|
||||
ZipFile f = null;
|
||||
try {
|
||||
localZipFile = new ZipFile(file);
|
||||
ZipEntry minecraft = localZipFile
|
||||
f = new ZipFile(file);
|
||||
ZipEntry minecraft = f
|
||||
.getEntry("net/minecraft/client/Minecraft.class");
|
||||
if (minecraft != null)
|
||||
return getVersionOfOldMinecraft(localZipFile, minecraft);
|
||||
ZipEntry main = localZipFile.getEntry("net/minecraft/client/main/Main.class");
|
||||
ZipEntry minecraftserver = localZipFile.getEntry("net/minecraft/server/MinecraftServer.class");
|
||||
return getVersionOfOldMinecraft(f, minecraft);
|
||||
ZipEntry main = f.getEntry("net/minecraft/client/main/Main.class");
|
||||
ZipEntry minecraftserver = f.getEntry("net/minecraft/server/MinecraftServer.class");
|
||||
if ((main != null) && (minecraftserver != null))
|
||||
return getVersionOfNewMinecraft(localZipFile, minecraftserver);
|
||||
return getVersionOfNewMinecraft(f, minecraftserver);
|
||||
r.type = MinecraftVersionRequest.INVALID;
|
||||
return r;
|
||||
} catch (IOException localException) {
|
||||
HMCLog.warn("Zip file is invalid", localException);
|
||||
} catch (IOException e) {
|
||||
HMCLog.warn("Zip file is invalid", e);
|
||||
r.type = MinecraftVersionRequest.INVALID_JAR;
|
||||
return r;
|
||||
} finally {
|
||||
if (localZipFile != null)
|
||||
if (f != null)
|
||||
try {
|
||||
localZipFile.close();
|
||||
f.close();
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to close zip file", ex);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@
|
||||
package org.jackhuang.hellominecraft.util;
|
||||
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
@@ -35,38 +33,16 @@ import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
* @author huang
|
||||
*/
|
||||
public final class NetUtils {
|
||||
|
||||
public static byte[] getBytesFromStream(InputStream is) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
IOUtils.copyStream(is, out);
|
||||
is.close();
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
public static String getStreamContent(InputStream is) throws IOException {
|
||||
return getStreamContent(is, DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
public static String getStreamContent(InputStream is, String encoding)
|
||||
throws IOException {
|
||||
if (is == null)
|
||||
return null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try (InputStreamReader br = new InputStreamReader(is, encoding)) {
|
||||
int len;
|
||||
char[] buf = new char[16384];
|
||||
while ((len = br.read(buf)) != -1)
|
||||
sb.append(buf, 0, len);
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
private NetUtils() {
|
||||
}
|
||||
|
||||
public static String get(String url, String encoding) throws IOException {
|
||||
return getStreamContent(new URL(url).openConnection().getInputStream());
|
||||
return IOUtils.getStreamContent(new URL(url).openConnection().getInputStream());
|
||||
}
|
||||
|
||||
public static String get(String url) throws IOException {
|
||||
return get(url, DEFAULT_CHARSET);
|
||||
return get(url, IOUtils.DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
public static String get(URL url) throws IOException {
|
||||
@@ -74,7 +50,7 @@ public final class NetUtils {
|
||||
}
|
||||
|
||||
public static String get(URL url, Proxy proxy) throws IOException {
|
||||
return getStreamContent(url.openConnection(proxy).getInputStream());
|
||||
return IOUtils.getStreamContent(url.openConnection(proxy).getInputStream());
|
||||
}
|
||||
|
||||
public static String post(URL u, Map<String, String> params) throws IOException {
|
||||
@@ -104,7 +80,7 @@ public final class NetUtils {
|
||||
con.setConnectTimeout(30000);
|
||||
con.setReadTimeout(30000);
|
||||
con.setRequestProperty("Content-Type", contentType + "; charset=utf-8");
|
||||
byte[] bytes = post.getBytes(DEFAULT_CHARSET);
|
||||
byte[] bytes = post.getBytes(IOUtils.DEFAULT_CHARSET);
|
||||
con.setRequestProperty("Content-Length", "" + bytes.length);
|
||||
con.connect();
|
||||
OutputStream os = null;
|
||||
@@ -119,19 +95,17 @@ public final class NetUtils {
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = con.getInputStream();
|
||||
result = getStreamContent(is);
|
||||
result = IOUtils.getStreamContent(is);
|
||||
} catch (IOException ex) {
|
||||
IOUtils.closeQuietly(is);
|
||||
is = con.getErrorStream();
|
||||
result = getStreamContent(is);
|
||||
result = IOUtils.getStreamContent(is);
|
||||
}
|
||||
|
||||
con.disconnect();
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final String DEFAULT_CHARSET = "UTF-8";
|
||||
|
||||
public static URL constantURL(String url) {
|
||||
try {
|
||||
return new URL(url);
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.jackhuang.hellominecraft.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.swing.SwingWorker;
|
||||
import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||
|
||||
@@ -47,13 +48,13 @@ public abstract class OverridableSwingWorker<T> extends SwingWorker<Void, T> {
|
||||
}
|
||||
|
||||
public OverridableSwingWorker reg(Consumer<T> c) {
|
||||
Utils.requireNonNull(c);
|
||||
Objects.requireNonNull(c);
|
||||
processListeners.add(c);
|
||||
return this;
|
||||
}
|
||||
|
||||
public OverridableSwingWorker regDone(Runnable c) {
|
||||
Utils.requireNonNull(c);
|
||||
Objects.requireNonNull(c);
|
||||
doneListeners.add(c);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ import org.jackhuang.hellominecraft.util.func.Predicate;
|
||||
* @author huang
|
||||
*/
|
||||
public final class StrUtils {
|
||||
|
||||
private StrUtils() {
|
||||
}
|
||||
|
||||
public static String substring(String src, int start_idx, int end_idx) {
|
||||
byte[] b = src.getBytes();
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.util;
|
||||
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.IOException;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -52,7 +54,7 @@ public final class UpdateChecker implements IUpdateChecker {
|
||||
if (value == null) {
|
||||
HMCLog.warn("Failed to check update...");
|
||||
if (showMessage)
|
||||
MessageBox.Show(C.i18n("update.failed"));
|
||||
MessageBox.show(C.i18n("update.failed"));
|
||||
} else if (VersionNumber.isOlder(base, value))
|
||||
OUT_DATED = true;
|
||||
if (OUT_DATED)
|
||||
@@ -74,7 +76,7 @@ public final class UpdateChecker implements IUpdateChecker {
|
||||
if (download_link == null)
|
||||
try {
|
||||
download_link = C.GSON.fromJson(NetUtils.get("http://huangyuhui.duapp.com/update_link.php?type=" + type), Map.class);
|
||||
} catch (Exception e) {
|
||||
} catch (JsonSyntaxException | IOException e) {
|
||||
HMCLog.warn("Failed to get update link.", e);
|
||||
}
|
||||
publish(download_link);
|
||||
|
||||
@@ -17,49 +17,32 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.util;
|
||||
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
||||
/**
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class Utils {
|
||||
|
||||
@SuppressWarnings("ResultOfObjectAllocationIgnored")
|
||||
public static boolean isURL(String s) {
|
||||
try {
|
||||
new URL(s);
|
||||
return true;
|
||||
} catch (MalformedURLException ex) {
|
||||
return false;
|
||||
}
|
||||
private Utils() {
|
||||
}
|
||||
|
||||
public static URL[] getURL() {
|
||||
return ((URLClassLoader) Utils.class.getClassLoader()).getURLs();
|
||||
}
|
||||
|
||||
public static int getSuggestedMemorySize() {
|
||||
try {
|
||||
OperatingSystemMXBean osmb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
|
||||
int memory = (int) (osmb.getTotalPhysicalMemorySize() / 1024 / 1024) / 4;
|
||||
memory = Math.round((float) memory / 128.0f) * 128;
|
||||
return memory;
|
||||
} catch (Throwable t) {
|
||||
HMCLog.warn("Failed to get total memory size, use 1024MB.", t);
|
||||
return 1024;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setClipborad(String text) {
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null);
|
||||
try {
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null);
|
||||
} catch(HeadlessException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,21 +51,12 @@ public final class Utils {
|
||||
* @param status exit code
|
||||
*/
|
||||
public static void shutdownForcely(int status) throws Exception {
|
||||
Class z = Class.forName("java.lang.Shutdown");
|
||||
Method exit = z.getDeclaredMethod("exit", int.class);
|
||||
exit.setAccessible(true);
|
||||
exit.invoke(z, status);
|
||||
}
|
||||
|
||||
public static void requireNonNull(Object o) {
|
||||
if (o == null)
|
||||
throw new NullPointerException("Oh dear, there is a problem...");
|
||||
}
|
||||
|
||||
public static Object firstNonNull(Object... o) {
|
||||
for (Object s : o)
|
||||
if (s != null)
|
||||
return s;
|
||||
return null;
|
||||
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
|
||||
Class z = Class.forName("java.lang.Shutdown");
|
||||
Method exit = z.getDeclaredMethod("exit", int.class);
|
||||
exit.setAccessible(true);
|
||||
exit.invoke(z, status);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,33 @@ public final class VersionNumber implements Comparable<VersionNumber> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 3;
|
||||
hash = 83 * hash + this.firstVer;
|
||||
hash = 83 * hash + this.secondVer;
|
||||
hash = 83 * hash + this.thirdVer;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
final VersionNumber other = (VersionNumber) obj;
|
||||
if (this.firstVer != other.firstVer)
|
||||
return false;
|
||||
if (this.secondVer != other.secondVer)
|
||||
return false;
|
||||
if (this.thirdVer != other.thirdVer)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(VersionNumber o) {
|
||||
if (isOlder(this, o))
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.util.code;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Base64 {
|
||||
public final class Base64 {
|
||||
|
||||
private Base64() {
|
||||
}
|
||||
|
||||
public static char[] encode(byte[] data) {
|
||||
char[] out = new char[((data.length + 2) / 3) * 4];
|
||||
@@ -52,12 +53,8 @@ public class Base64 {
|
||||
return out;
|
||||
}
|
||||
|
||||
public static char[] encode(String s, String charset) throws UnsupportedEncodingException {
|
||||
return encode(s.getBytes(charset));
|
||||
}
|
||||
|
||||
public static char[] encode(String s) {
|
||||
return encode(s.getBytes());
|
||||
return encode(s.getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
public static byte[] decode(char[] data) {
|
||||
|
||||
@@ -19,7 +19,10 @@ package org.jackhuang.hellominecraft.util.code;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class Charsets {
|
||||
public final class Charsets {
|
||||
|
||||
private Charsets() {
|
||||
}
|
||||
|
||||
public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
|
||||
|
||||
|
||||
@@ -26,7 +26,10 @@ import java.security.NoSuchAlgorithmException;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class DigestUtils {
|
||||
public final class DigestUtils {
|
||||
|
||||
private DigestUtils() {
|
||||
}
|
||||
|
||||
private static final int STREAM_BUFFER_LENGTH = 1024;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.jackhuang.hellominecraft.util.code;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class Hex {
|
||||
public final class Hex {
|
||||
|
||||
public static final Charset DEFAULT_CHARSET = Charsets.UTF_8;
|
||||
public static final String DEFAULT_CHARSET_NAME = "UTF-8";
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Localization {
|
||||
public final class Localization {
|
||||
|
||||
private static final String ROOT_LOCATION = "/org/jackhuang/hellominecraft/lang/I18N%s.lang";
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Localization {
|
||||
String[] strings = IOUtils.readFully(is).toString("UTF-8").split("\n");
|
||||
for (String s : strings)
|
||||
if (!s.isEmpty() && s.charAt(0) != 35) {
|
||||
int i = s.indexOf("=");
|
||||
int i = s.indexOf('=');
|
||||
if (i == -1)
|
||||
continue;
|
||||
lang.put(s.substring(0, i), s.substring(i + 1));
|
||||
|
||||
@@ -36,9 +36,8 @@ public enum SupportedLocales {
|
||||
bundle = Localization.get(self);
|
||||
showString = bundle.localize("lang");
|
||||
this.customized = customized;
|
||||
} catch (Throwable t) {
|
||||
} catch (Throwable ignore) {
|
||||
showString = name();
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +53,7 @@ public enum SupportedLocales {
|
||||
public String translate(String key, Object... format) {
|
||||
try {
|
||||
return String.format(bundle.localize(key), format);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (Exception ignore) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ public class AppenderControl {
|
||||
}
|
||||
|
||||
public void callAppender(LogEvent event) {
|
||||
if ((this.level != null)
|
||||
&& (this.intLevel < event.level.level))
|
||||
if (this.level != null
|
||||
&& this.intLevel < event.level.level)
|
||||
return;
|
||||
|
||||
if (this.recursive.get() != null) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.util.logging.layout;
|
||||
|
||||
import org.jackhuang.hellominecraft.util.code.Charsets;
|
||||
import org.jackhuang.hellominecraft.util.logging.LogEvent;
|
||||
|
||||
/**
|
||||
@@ -27,7 +28,7 @@ public abstract class AbstractStringLayout implements ILayout<String> {
|
||||
|
||||
@Override
|
||||
public byte[] toByteArray(LogEvent event) {
|
||||
return toSerializable(event).getBytes();
|
||||
return toSerializable(event).getBytes(Charsets.UTF_8);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SimpleLogger extends AbstractLogger {
|
||||
super(name, messageFactory);
|
||||
this.level = defaultLevel;
|
||||
if (showShortLogName) {
|
||||
int index = name.lastIndexOf(".");
|
||||
int index = name.lastIndexOf('.');
|
||||
if ((index > 0) && (index < name.length()))
|
||||
this.logName = name.substring(index + 1);
|
||||
else
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ObjectMessage
|
||||
implements IMessage {
|
||||
|
||||
private static final long serialVersionUID = -5903272448334166185L;
|
||||
private final transient Object obj;
|
||||
private final Object obj;
|
||||
|
||||
public ObjectMessage(Object obj) {
|
||||
if (obj == null)
|
||||
|
||||
@@ -35,7 +35,10 @@ import org.jackhuang.hellominecraft.util.func.BiFunction;
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Compressor {
|
||||
public final class CompressingUtils {
|
||||
|
||||
private CompressingUtils() {
|
||||
}
|
||||
|
||||
public static void zip(String sourceDir, String zipFile) throws IOException {
|
||||
zip(new File(sourceDir), new File(zipFile), null);
|
||||
@@ -29,13 +29,15 @@ import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class FileUtils {
|
||||
public final class FileUtils {
|
||||
|
||||
private FileUtils() {
|
||||
}
|
||||
|
||||
public static void deleteDirectory(File directory)
|
||||
throws IOException {
|
||||
@@ -75,7 +77,8 @@ public class FileUtils {
|
||||
public static void cleanDirectory(File directory)
|
||||
throws IOException {
|
||||
if (!directory.exists()) {
|
||||
directory.mkdirs();
|
||||
if (!directory.mkdirs() && !directory.isDirectory())
|
||||
throw new IOException("Failed to create directory: " + directory);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,17 +189,18 @@ public class FileUtils {
|
||||
else
|
||||
doCopyFile(srcFile, dstFile);
|
||||
}
|
||||
destDir.setLastModified(srcDir.lastModified());
|
||||
if (!destDir.setLastModified(srcDir.lastModified()))
|
||||
HMCLog.warn("Failed to set last modified date of dir: " + destDir);
|
||||
}
|
||||
|
||||
public static String read(File file)
|
||||
throws IOException {
|
||||
return NetUtils.getStreamContent(IOUtils.openInputStream(file));
|
||||
return IOUtils.getStreamContent(IOUtils.openInputStream(file));
|
||||
}
|
||||
|
||||
public static String readQuietly(File file) {
|
||||
try {
|
||||
return NetUtils.getStreamContent(IOUtils.openInputStream(file));
|
||||
return IOUtils.getStreamContent(IOUtils.openInputStream(file));
|
||||
} catch (IOException ex) {
|
||||
HMCLog.err("Failed to read file: " + file, ex);
|
||||
return null;
|
||||
@@ -205,12 +209,12 @@ public class FileUtils {
|
||||
|
||||
public static String read(File file, String charset)
|
||||
throws IOException {
|
||||
return NetUtils.getStreamContent(IOUtils.openInputStream(file), charset);
|
||||
return IOUtils.getStreamContent(IOUtils.openInputStream(file), charset);
|
||||
}
|
||||
|
||||
public static String readIgnoreFileNotFound(File file) throws IOException {
|
||||
try {
|
||||
return NetUtils.getStreamContent(IOUtils.openInputStream(file));
|
||||
return IOUtils.getStreamContent(IOUtils.openInputStream(file));
|
||||
} catch (FileNotFoundException ex) {
|
||||
return "";
|
||||
}
|
||||
@@ -364,7 +368,8 @@ public class FileUtils {
|
||||
if ((parent != null)
|
||||
&& (!parent.mkdirs()) && (!parent.isDirectory()))
|
||||
throw new IOException("Directory '" + parent + "' could not be created");
|
||||
file.createNewFile();
|
||||
if (!file.createNewFile())
|
||||
throw new IOException("File `" + file + "` cannot be created.");
|
||||
}
|
||||
|
||||
return new FileOutputStream(file, append);
|
||||
@@ -378,6 +383,6 @@ public class FileUtils {
|
||||
for (File f : files)
|
||||
if (f.getName().endsWith(suffix))
|
||||
al.add(f);
|
||||
return al.toArray(new File[0]);
|
||||
return al.toArray(new File[al.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,22 +27,29 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.jackhuang.hellominecraft.util.func.Consumer;
|
||||
import org.jackhuang.hellominecraft.util.func.Function;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huang
|
||||
*/
|
||||
public class IOUtils {
|
||||
public final class IOUtils {
|
||||
|
||||
private IOUtils() {
|
||||
}
|
||||
|
||||
public static String addSeparator(String path) {
|
||||
if (path == null || path.trim().length() == 0)
|
||||
@@ -109,7 +116,7 @@ public class IOUtils {
|
||||
java.io.File file = new java.io.File(realPath);
|
||||
realPath = file.getAbsolutePath();
|
||||
try {
|
||||
realPath = java.net.URLDecoder.decode(realPath, "utf-8");
|
||||
realPath = java.net.URLDecoder.decode(realPath, DEFAULT_CHARSET);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -119,7 +126,7 @@ public class IOUtils {
|
||||
public static boolean isAbsolutePath(String path) {
|
||||
if (path == null)
|
||||
return true;
|
||||
return path.startsWith("/") || path.indexOf(":") > 0;
|
||||
return path.startsWith("/") || path.indexOf(':') > 0;
|
||||
}
|
||||
|
||||
public static String getLocalMAC() {
|
||||
@@ -205,19 +212,19 @@ public class IOUtils {
|
||||
}
|
||||
|
||||
public static void write(byte[] data, OutputStream output)
|
||||
throws IOException {
|
||||
throws IOException {
|
||||
if (data != null)
|
||||
output.write(data);
|
||||
}
|
||||
|
||||
public static void write(String data, OutputStream output, String encoding)
|
||||
throws IOException {
|
||||
throws IOException {
|
||||
if (data != null)
|
||||
output.write(data.getBytes(encoding));
|
||||
}
|
||||
|
||||
public static FileInputStream openInputStream(File file)
|
||||
throws IOException {
|
||||
throws IOException {
|
||||
if (file.exists()) {
|
||||
if (file.isDirectory())
|
||||
throw new IOException("File '" + file + "' exists but is a directory");
|
||||
@@ -266,21 +273,17 @@ public class IOUtils {
|
||||
}
|
||||
|
||||
public static List<String> readProcessByInputStream(String[] cmd) throws IOException, InterruptedException {
|
||||
JavaProcess jp = new JavaProcess(cmd, new ProcessBuilder(cmd).start(), null);
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(jp.getRawProcess().getInputStream()))) {
|
||||
jp.getRawProcess().waitFor();
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
lines.add(line);
|
||||
}
|
||||
return lines;
|
||||
return readProcessImpl(cmd, p -> p.getInputStream());
|
||||
}
|
||||
|
||||
public static List<String> readProcessByErrorStream(String[] cmd) throws IOException, InterruptedException {
|
||||
return readProcessImpl(cmd, p -> p.getErrorStream());
|
||||
}
|
||||
|
||||
private static List<String> readProcessImpl(String[] cmd, Function<Process, InputStream> callback) throws IOException, InterruptedException {
|
||||
JavaProcess jp = new JavaProcess(cmd, new ProcessBuilder(cmd).start(), null);
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(jp.getRawProcess().getErrorStream()))) {
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(callback.apply(jp.getRawProcess()), Charset.defaultCharset()))) {
|
||||
jp.getRawProcess().waitFor();
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
@@ -298,4 +301,39 @@ public class IOUtils {
|
||||
while ((length = input.read(buf)) != -1)
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
|
||||
public static byte[] getBytesFromStream(InputStream is) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
IOUtils.copyStream(is, out);
|
||||
is.close();
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
public static String getStreamContent(InputStream is) throws IOException {
|
||||
return getStreamContent(is, DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
public static String getStreamContent(InputStream is, String encoding)
|
||||
throws IOException {
|
||||
if (is == null)
|
||||
return null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try (InputStreamReader br = new InputStreamReader(is, encoding)) {
|
||||
int len;
|
||||
char[] buf = new char[16384];
|
||||
while ((len = br.read(buf)) != -1)
|
||||
sb.append(buf, 0, len);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static final String DEFAULT_CHARSET = "UTF-8";
|
||||
|
||||
public static PrintStream createPrintStream(OutputStream out, Charset charset) {
|
||||
try {
|
||||
return new PrintStream(out, false, charset.name());
|
||||
} catch (UnsupportedEncodingException ignore) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
|
||||
@@ -38,8 +40,8 @@ public class Java {
|
||||
temp.add(new Java("Default", System.getProperty("java.home")));
|
||||
temp.add(new Java("Custom", null));
|
||||
if (OS.os() == OS.WINDOWS)
|
||||
temp.addAll(Java.queryAllJavaHomeInWindowsByReg());
|
||||
if (OS.os() == OS.OSX)
|
||||
temp.addAll(Java.queryAllJavaHomeInWindowsByReg().values());
|
||||
else if (OS.os() == OS.OSX)
|
||||
temp.addAll(Java.queryAllJDKInMac());
|
||||
JAVA = Collections.unmodifiableList(temp);
|
||||
}
|
||||
@@ -114,18 +116,18 @@ public class Java {
|
||||
* WINDOWS
|
||||
* -----------------------------------
|
||||
*/
|
||||
public static List<Java> queryAllJavaHomeInWindowsByReg() {
|
||||
List<Java> ans = new ArrayList<>();
|
||||
public static Map<String, Java> queryAllJavaHomeInWindowsByReg() {
|
||||
Map<String, Java> ans = new HashMap<>();
|
||||
try {
|
||||
queryJava(ans, "HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment");
|
||||
queryJava(ans, "HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit");
|
||||
queryJava(ans, "HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\");
|
||||
queryJava(ans, "HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\");
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
HMCLog.err("Faield to query java", ex);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
private static void queryJava(List<Java> ans, String location) throws IOException, InterruptedException {
|
||||
private static void queryJava(Map<String, Java> ans, String location) throws IOException, InterruptedException {
|
||||
for (String java : queryRegSubFolders(location)) {
|
||||
int s = 0;
|
||||
for (char c : java.toCharArray())
|
||||
@@ -133,9 +135,9 @@ public class Java {
|
||||
++s;
|
||||
if (s <= 1)
|
||||
continue;
|
||||
String javahome = queryRegValue(java, "JavaHome");
|
||||
if (javahome != null)
|
||||
ans.add(new Java(java.substring(location.length()), javahome));
|
||||
String javahome = queryRegValue(java, "JavaHome"), ver = java.substring(location.length());
|
||||
if (javahome != null && !ans.containsKey(ver))
|
||||
ans.put(ver, new Java(ver, javahome));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,9 +59,12 @@ public final class JdkVersion implements Cloneable {
|
||||
if (!(obj instanceof JdkVersion))
|
||||
return false;
|
||||
JdkVersion b = (JdkVersion) obj;
|
||||
if (b.location == null || location == null)
|
||||
return b.location == location;
|
||||
return new File(b.location).equals(new File(location));
|
||||
if (b.location == null && location == null)
|
||||
return true;
|
||||
else if (b.location == null || location == null)
|
||||
return false;
|
||||
else
|
||||
return new File(b.location).equals(new File(location));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -175,7 +178,7 @@ public final class JdkVersion implements Cloneable {
|
||||
private static final Pattern p = Pattern.compile("java version \"[1-9]*\\.[1-9]*\\.[0-9]*(.*?)\"");
|
||||
|
||||
public static JdkVersion getJavaVersionFromExecutable(String file) throws IOException {
|
||||
String[] str = new String[] { file, "-version" };
|
||||
String[] str = new String[]{file, "-version"};
|
||||
Platform platform = Platform.BIT_32;
|
||||
String ver = null;
|
||||
try {
|
||||
|
||||
@@ -24,7 +24,9 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Locale;
|
||||
import java.util.StringTokenizer;
|
||||
import org.jackhuang.hellominecraft.util.code.Charsets;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
|
||||
/**
|
||||
@@ -46,7 +48,7 @@ public enum OS {
|
||||
}
|
||||
|
||||
public static OS os() {
|
||||
String str = System.getProperty("os.name").toLowerCase();
|
||||
String str = System.getProperty("os.name").toLowerCase(Locale.US);
|
||||
if (str.contains("win"))
|
||||
return OS.WINDOWS;
|
||||
if (str.contains("mac"))
|
||||
@@ -79,33 +81,42 @@ public enum OS {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getSuggestedMemorySize() {
|
||||
long total = getTotalPhysicalMemory();
|
||||
if (total == -1)
|
||||
return 1024;
|
||||
int memory = (int) (total / 1024 / 1024) / 4;
|
||||
memory = Math.round((float) memory / 128.0f) * 128;
|
||||
return memory;
|
||||
}
|
||||
|
||||
public static long[] memoryInfoForLinux() throws IOException {
|
||||
File file = new File("/proc/meminfo");
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||
new FileInputStream(file)));
|
||||
long[] result = new long[4];
|
||||
String str;
|
||||
StringTokenizer token;
|
||||
while ((str = br.readLine()) != null) {
|
||||
token = new StringTokenizer(str);
|
||||
if (!token.hasMoreTokens())
|
||||
continue;
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8))) {
|
||||
long[] result = new long[4];
|
||||
String str;
|
||||
StringTokenizer token;
|
||||
while ((str = br.readLine()) != null) {
|
||||
token = new StringTokenizer(str);
|
||||
if (!token.hasMoreTokens())
|
||||
continue;
|
||||
|
||||
str = token.nextToken();
|
||||
if (!token.hasMoreTokens())
|
||||
continue;
|
||||
str = token.nextToken();
|
||||
if (!token.hasMoreTokens())
|
||||
continue;
|
||||
|
||||
if (str.equalsIgnoreCase("MemTotal:"))
|
||||
result[0] = Long.parseLong(token.nextToken());
|
||||
else if (str.equalsIgnoreCase("MemFree:"))
|
||||
result[1] = Long.parseLong(token.nextToken());
|
||||
else if (str.equalsIgnoreCase("SwapTotal:"))
|
||||
result[2] = Long.parseLong(token.nextToken());
|
||||
else if (str.equalsIgnoreCase("SwapFree:"))
|
||||
result[3] = Long.parseLong(token.nextToken());
|
||||
if (str.equalsIgnoreCase("MemTotal:"))
|
||||
result[0] = Long.parseLong(token.nextToken());
|
||||
else if (str.equalsIgnoreCase("MemFree:"))
|
||||
result[1] = Long.parseLong(token.nextToken());
|
||||
else if (str.equalsIgnoreCase("SwapTotal:"))
|
||||
result[2] = Long.parseLong(token.nextToken());
|
||||
else if (str.equalsIgnoreCase("SwapFree:"))
|
||||
result[3] = Long.parseLong(token.nextToken());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getLinuxReleaseVersion() throws IOException {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.util.system;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -75,7 +76,7 @@ public class ProcessThread extends Thread {
|
||||
} else
|
||||
line += (char) ch;
|
||||
stopEvent.execute(p);
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
HMCLog.err("An error occured when reading process stdout/stderr.", e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(br);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.util.system;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
@@ -61,10 +60,9 @@ public class ZipEngine {
|
||||
/**
|
||||
* 功能:把 sourceDir 目录下的所有文件进行 zip 格式的压缩,保存为指定 zip 文件
|
||||
*
|
||||
* @param sourceDir 源文件夹
|
||||
* @param zipFile 压缩生成的zip文件路径。
|
||||
* @param sourceDir 源文件夹
|
||||
* @param pathNameCallback callback(pathName, isDirectory) returns your
|
||||
* modified pathName
|
||||
* modified pathName
|
||||
*
|
||||
* @throws java.io.IOException 压缩失败或无法读取
|
||||
*/
|
||||
@@ -75,11 +73,11 @@ public class ZipEngine {
|
||||
/**
|
||||
* 将文件压缩成zip文件
|
||||
*
|
||||
* @param source zip文件路径
|
||||
* @param basePath 待压缩文件根目录
|
||||
* @param zos zip文件的os
|
||||
* @param source zip文件路径
|
||||
* @param basePath 待压缩文件根目录
|
||||
* @param zos zip文件的os
|
||||
* @param pathNameCallback callback(pathName, isDirectory) returns your
|
||||
* modified pathName, null if you dont want this file zipped
|
||||
* modified pathName, null if you dont want this file zipped
|
||||
*/
|
||||
private void putDirectoryImpl(File source, String basePath, BiFunction<String, Boolean, String> pathNameCallback) throws IOException {
|
||||
File[] files;
|
||||
@@ -95,7 +93,7 @@ public class ZipEngine {
|
||||
for (File file : files)
|
||||
if (file.isDirectory()) {
|
||||
pathName = file.getPath().substring(basePath.length() + 1)
|
||||
+ "/";
|
||||
+ "/";
|
||||
pathName = pathName.replace('\\', '/');
|
||||
if (pathNameCallback != null)
|
||||
pathName = pathNameCallback.apply(pathName, true);
|
||||
@@ -117,14 +115,14 @@ public class ZipEngine {
|
||||
}
|
||||
|
||||
public void putFile(File file, String pathName) throws IOException {
|
||||
putStream(new FileInputStream(file), pathName);
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
putStream(fis, pathName);
|
||||
}
|
||||
}
|
||||
|
||||
public void putStream(InputStream is, String pathName) throws IOException {
|
||||
try (BufferedInputStream bis = new BufferedInputStream(is)) {
|
||||
put(new ZipEntry(pathName));
|
||||
IOUtils.copyStream(bis, zos, buf);
|
||||
}
|
||||
put(new ZipEntry(pathName));
|
||||
IOUtils.copyStream(is, zos, buf);
|
||||
}
|
||||
|
||||
public void putTextFile(String text, String pathName) throws IOException {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user