|
13 | 13 | import org.jetbrains.annotations.ApiStatus;
|
14 | 14 | import org.jetbrains.annotations.NotNull;
|
15 | 15 | import org.jetbrains.annotations.Nullable;
|
| 16 | + |
| 17 | +import top.hendrixshen.magiclib.MagicLib; |
16 | 18 | import top.hendrixshen.magiclib.MagicLibReference;
|
| 19 | +import top.hendrixshen.magiclib.util.GsonUtil; |
| 20 | +import top.hendrixshen.magiclib.util.JsonUtil; |
17 | 21 | import top.hendrixshen.magiclib.util.MiscUtil;
|
18 | 22 |
|
19 | 23 | import java.io.File;
|
@@ -65,17 +69,13 @@ public ConfigHandler(String modId, ConfigManager configManager, int configVersio
|
65 | 69 | public ConfigHandler(String modId, Path configPath, ConfigManager configManager, int configVersion,
|
66 | 70 | @Nullable Consumer<ConfigHandler> preDeserializeCallback,
|
67 | 71 | @Nullable Consumer<ConfigHandler> postSerializeCallback) {
|
68 |
| - this.configPath = FileUtils.getConfigDirectory().toPath().resolve(configPath); |
69 |
| - this.configManager = configManager; |
| 72 | + this(modId, configPath, configManager, configVersion); |
70 | 73 | this.preDeserializeCallback = preDeserializeCallback;
|
71 | 74 | this.postSerializeCallback = postSerializeCallback;
|
72 |
| - this.configVersion = configVersion; |
73 |
| - this.jsonObject = new JsonObject(); |
74 |
| - this.modId = modId; |
75 | 75 | }
|
76 | 76 |
|
77 | 77 | public ConfigHandler(String modId, Path configPath, ConfigManager configManager, int configVersion) {
|
78 |
| - this.configPath = FileUtils.getConfigDirectory().toPath().resolve(configPath); |
| 78 | + this.configPath = MagicLib.getInstance().getCurrentPlatform().getConfigFolder().resolve(configPath); |
79 | 79 | this.configManager = configManager;
|
80 | 80 | this.configVersion = configVersion;
|
81 | 81 | this.jsonObject = new JsonObject();
|
@@ -119,7 +119,7 @@ public static JsonElement parseJsonFile(File file) {
|
119 | 119 |
|
120 | 120 | try {
|
121 | 121 | InputStreamReader inputStreamReader = new InputStreamReader(Files.newInputStream(file.toPath()), StandardCharsets.UTF_8);
|
122 |
| - JsonElement element = MiscUtil.GSON.fromJson(inputStreamReader, JsonElement.class); |
| 122 | + JsonElement element = GsonUtil.GSON.fromJson(inputStreamReader, JsonElement.class); |
123 | 123 | inputStreamReader.close();
|
124 | 124 | return element;
|
125 | 125 | } catch (Exception e) {
|
|
0 commit comments