Fix JSON Exception.
This commit is contained in:
@@ -88,12 +88,12 @@ public abstract class IMinecraftLoader {
|
||||
res.add("-Xmn128m");
|
||||
}
|
||||
|
||||
if (jv != null && jv.platform == Platform.BIT_32 && Platform.getPlatform() == Platform.BIT_64)
|
||||
if (jv != null && jv.getPlatform() == Platform.BIT_32 && Platform.getPlatform() == Platform.BIT_64)
|
||||
MessageBox.Show(C.i18n("advice.os64butjdk32"));
|
||||
|
||||
if (!StrUtils.isBlank(v.getMaxMemory())) {
|
||||
int mem = MathUtils.parseMemory(v.getMaxMemory(), 2147483647);
|
||||
if (jv != null && jv.platform == Platform.BIT_32 && mem > 1024)
|
||||
if (jv != null && jv.getPlatform() == Platform.BIT_32 && mem > 1024)
|
||||
MessageBox.Show(C.i18n("launch.too_big_memory_alloc_64bit"));
|
||||
else {
|
||||
long a = OS.getTotalPhysicalMemory() / 1024 / 1024;
|
||||
@@ -107,7 +107,7 @@ public abstract class IMinecraftLoader {
|
||||
}
|
||||
|
||||
if (!StrUtils.isBlank(v.getPermSize()) && !v.isNoJVMArgs())
|
||||
if (jv != null && jv.ver != null && (jv.ver.startsWith("1.8") || jv.ver.startsWith("1.9")));
|
||||
if (jv != null && jv.getVersion() != null && (jv.getVersion().startsWith("1.8") || jv.getVersion().startsWith("1.9")));
|
||||
else res.add("-XX:MaxPermSize=" + v.getPermSize() + "m");
|
||||
|
||||
if (!v.isNoJVMArgs()) appendJVMArgs(res);
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.utils.settings;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -27,12 +25,10 @@ import java.util.Objects;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.Main;
|
||||
import org.jackhuang.hellominecraft.utils.EnumAdapter;
|
||||
import org.jackhuang.hellominecraft.utils.tinystream.CollectionUtils;
|
||||
import org.jackhuang.hellominecraft.utils.FileUtils;
|
||||
import org.jackhuang.hellominecraft.utils.IOUtils;
|
||||
import org.jackhuang.hellominecraft.utils.MessageBox;
|
||||
import org.jackhuang.hellominecraft.utils.Platform;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
import org.jackhuang.hellominecraft.utils.UpdateChecker;
|
||||
import org.jackhuang.hellominecraft.utils.VersionNumber;
|
||||
@@ -44,7 +40,7 @@ import org.jackhuang.hellominecraft.utils.VersionNumber;
|
||||
public final class Settings {
|
||||
|
||||
public static final File settingsFile = new File(IOUtils.currentDir(), "hmcl.json");
|
||||
public static final Gson gson = new GsonBuilder().setPrettyPrinting().registerTypeAdapter(Platform.class, new EnumAdapter<>(Platform.values())).create();
|
||||
//public static final Gson gson = new GsonBuilder().setPrettyPrinting().registerTypeAdapter(Platform.class, new EnumAdapter<>(Platform.values())).create();
|
||||
|
||||
private static boolean isFirstLoad;
|
||||
private static final Config settings;
|
||||
@@ -75,7 +71,7 @@ public final class Settings {
|
||||
if (str == null || str.trim().equals(""))
|
||||
HMCLog.log("Settings file is empty, use the default settings.");
|
||||
else {
|
||||
Config d = gson.fromJson(str, Config.class);
|
||||
Config d = C.gsonPrettyPrinting.fromJson(str, Config.class);
|
||||
if (d != null) c = d;
|
||||
}
|
||||
HMCLog.log("Initialized settings.");
|
||||
@@ -96,7 +92,7 @@ public final class Settings {
|
||||
|
||||
public static void save() {
|
||||
try {
|
||||
FileUtils.write(settingsFile, gson.toJson(settings));
|
||||
FileUtils.write(settingsFile, C.gsonPrettyPrinting.toJson(settings));
|
||||
} catch (IOException ex) {
|
||||
HMCLog.err("Failed to save config", ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user