Fix problems with launching

This commit is contained in:
huangyuhui
2016-02-06 00:02:35 +08:00
parent 27a013450e
commit b0845c700f
5 changed files with 24 additions and 19 deletions

View File

@@ -27,7 +27,6 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.util.C;
@@ -47,7 +46,7 @@ import org.jackhuang.hellominecraft.util.Utils;
*/
public final class Launcher {
static final Logger LOGGER = LogManager.getLogManager().getLogger(Launcher.class.getName());
static final Logger LOGGER = Logger.getLogger(Launcher.class.getName());
static String classPath = "", proxyHost = "", proxyPort = "", proxyUsername = "", proxyPassword = "";

View File

@@ -71,7 +71,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
if (!checkAssetsExist())
if (MessageBox.Show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
IAssetsHandler.ASSETS_HANDLER.getList(version, service.asset()).execute();
IAssetsHandler.ASSETS_HANDLER.getList(version, service.asset()).run();
TaskWindow.getInstance().addTask(IAssetsHandler.ASSETS_HANDLER.getDownloadTask(service.getDownloadType().getProvider())).start();
}

View File

@@ -52,17 +52,7 @@ public class DefaultMinecraftService extends IMinecraftService {
this.provider = new HMCLGameProvider(this);
provider.initializeMiencraft();
provider.onRefreshingVersions.register(versionSettings::clear);
provider.onLoadedVersion.register(id -> {
VersionSetting vs = new VersionSetting();
File f = new File(provider.versionRoot(id), "hmclversion.cfg");
if (f.exists()) {
String s = FileUtils.readFileToStringQuietly(f);
if (s != null)
vs = C.GSON.fromJson(s, VersionSetting.class);
}
vs.id = id;
versionSettings.put(id, vs);
});
provider.onLoadedVersion.register(this::loadVersionSetting);
this.mms = new MinecraftModService(this);
this.mds = new MinecraftDownloadService(this);
this.mas = new MinecraftAssetService(this);
@@ -77,7 +67,23 @@ public class DefaultMinecraftService extends IMinecraftService {
});
}
private void loadVersionSetting(String id) {
if (provider.getVersionById(id) == null)
return;
VersionSetting vs = new VersionSetting();
File f = new File(provider.versionRoot(id), "hmclversion.cfg");
if (f.exists()) {
String s = FileUtils.readFileToStringQuietly(f);
if (s != null)
vs = C.GSON.fromJson(s, VersionSetting.class);
}
vs.id = id;
versionSettings.put(id, vs);
}
public VersionSetting getVersionSetting(String id) {
if (!versionSettings.containsKey(id))
loadVersionSetting(id);
return versionSettings.get(id);
}

View File

@@ -69,9 +69,10 @@ public final class Profile {
public VersionSetting getSelectedVersionSetting() {
String s = getSelectedVersion();
if (s == null)
return defaultVersionSetting;
return getVersionSetting(getSelectedVersion());
VersionSetting vs = defaultVersionSetting;
if (s != null)
vs = getVersionSetting(getSelectedVersion());
return vs;
}
public VersionSetting getVersionSetting(String id) {

View File

@@ -23,7 +23,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.util.C;
@@ -42,7 +41,7 @@ import org.jackhuang.hellominecraft.util.ui.LogWindow;
*/
public class CrashReporter implements Thread.UncaughtExceptionHandler {
private static final Logger LOGGER = LogManager.getLogManager().getLogger(CrashReporter.class.getName());
private static final Logger LOGGER = Logger.getLogger(CrashReporter.class.getName());
boolean enableLogger = false;