Fix #498
This commit is contained in:
@@ -41,6 +41,7 @@ import org.jackhuang.hmcl.util.i18n.Locales;
|
|||||||
import org.jackhuang.hmcl.util.i18n.Locales.SupportedLocale;
|
import org.jackhuang.hmcl.util.i18n.Locales.SupportedLocale;
|
||||||
import org.jackhuang.hmcl.util.javafx.ObservableHelper;
|
import org.jackhuang.hmcl.util.javafx.ObservableHelper;
|
||||||
import org.jackhuang.hmcl.util.javafx.PropertyUtils;
|
import org.jackhuang.hmcl.util.javafx.PropertyUtils;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
@@ -62,8 +63,12 @@ public final class Config implements Cloneable, Observable {
|
|||||||
.setPrettyPrinting()
|
.setPrettyPrinting()
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static Config fromJson(String json) throws JsonParseException {
|
public static Config fromJson(String json) throws JsonParseException {
|
||||||
Config loaded = CONFIG_GSON.fromJson(json, Config.class);
|
Config loaded = CONFIG_GSON.fromJson(json, Config.class);
|
||||||
|
if (loaded == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
Config instance = new Config();
|
Config instance = new Config();
|
||||||
PropertyUtils.copyProperties(loaded, instance);
|
PropertyUtils.copyProperties(loaded, instance);
|
||||||
return instance;
|
return instance;
|
||||||
|
|||||||
Reference in New Issue
Block a user