mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-14 22:37:06 -04:00
Fix #498
This commit is contained in:
parent
e6bd55aa69
commit
176968d883
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user