This commit is contained in:
yushijinhun 2018-12-16 00:31:37 +08:00
parent e6bd55aa69
commit 176968d883
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4

View File

@ -41,6 +41,7 @@ import org.jackhuang.hmcl.util.i18n.Locales;
import org.jackhuang.hmcl.util.i18n.Locales.SupportedLocale;
import org.jackhuang.hmcl.util.javafx.ObservableHelper;
import org.jackhuang.hmcl.util.javafx.PropertyUtils;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.net.Proxy;
@ -62,8 +63,12 @@ public final class Config implements Cloneable, Observable {
.setPrettyPrinting()
.create();
@Nullable
public static Config fromJson(String json) throws JsonParseException {
Config loaded = CONFIG_GSON.fromJson(json, Config.class);
if (loaded == null) {
return null;
}
Config instance = new Config();
PropertyUtils.copyProperties(loaded, instance);
return instance;