|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2022 Team Galacticraft |
| 2 | + * Copyright (c) 2023 Team Galacticraft |
3 | 3 | *
|
4 | 4 | * Licensed under the MIT license.
|
5 | 5 | * See LICENSE file in the project root for details.
|
|
8 | 8 | package micdoodle8.mods.miccore;
|
9 | 9 |
|
10 | 10 | import java.io.File;
|
| 11 | + |
11 | 12 | import net.minecraftforge.common.config.Configuration;
|
| 13 | +import net.minecraftforge.common.config.Property; |
12 | 14 |
|
13 | 15 | public class ConfigManagerMicCore
|
14 | 16 | {
|
15 | 17 |
|
16 | 18 | public static boolean loaded;
|
17 | 19 |
|
18 |
| - static Configuration configuration; |
| 20 | + static Configuration configuration; |
19 | 21 |
|
20 |
| - public static boolean enableSmallMoons; |
21 | 22 | public static boolean enableDebug;
|
22 | 23 |
|
23 | 24 | public static void init()
|
24 | 25 | {
|
| 26 | + File oldCoreConfig = new File(MicdoodlePlugin.canonicalConfigDir, "Galacticraft/miccore.conf"); |
| 27 | + File coremodConfig = new File(MicdoodlePlugin.canonicalConfigDir, "Galacticraft/MicdoodleCore.cfg"); |
| 28 | + |
25 | 29 | if (!ConfigManagerMicCore.loaded)
|
26 | 30 | {
|
27 |
| - ConfigManagerMicCore.configuration = new Configuration(new File(MicdoodlePlugin.canonicalConfigDir, "Galacticraft/miccore.conf")); |
| 31 | + if (oldCoreConfig.exists()) |
| 32 | + { |
| 33 | + ConfigManagerMicCore.configuration = ConfigManagerMicCore.handleConfigFileMove(new Configuration(oldCoreConfig), coremodConfig); |
| 34 | + oldCoreConfig.delete(); |
| 35 | + } |
| 36 | + else |
| 37 | + { |
| 38 | + ConfigManagerMicCore.configuration = new Configuration(coremodConfig); |
| 39 | + } |
28 | 40 | }
|
29 | 41 |
|
30 | 42 | ConfigManagerMicCore.configuration.load();
|
31 | 43 | ConfigManagerMicCore.syncConfig();
|
32 | 44 | }
|
33 | 45 |
|
| 46 | + private static Configuration handleConfigFileMove(Configuration oldConfig, File newFile) |
| 47 | + { |
| 48 | + Property logDebugOutput = oldConfig.get(Configuration.CATEGORY_GENERAL, "Enable Debug messages", false); |
| 49 | + |
| 50 | + Configuration newConfig = new Configuration(newFile); |
| 51 | + newConfig.get(Configuration.CATEGORY_GENERAL, "logDebugOutput", logDebugOutput.getBoolean(), "If `true` Enable debug messages during Galacticraft bytecode injection at startup"); |
| 52 | + newConfig.save(); |
| 53 | + |
| 54 | + return newConfig; |
| 55 | + } |
| 56 | + |
34 | 57 | public static void syncConfig()
|
35 | 58 | {
|
36 | 59 | try
|
37 | 60 | {
|
38 |
| - ConfigManagerMicCore.enableSmallMoons = ConfigManagerMicCore.configuration |
39 |
| - .get(Configuration.CATEGORY_GENERAL, "Enable Small Moons", true, "This will cause some dimensions to appear round, disable if render transformations cause a conflict.") |
40 |
| - .getBoolean(true); |
41 |
| - ConfigManagerMicCore.enableDebug = ConfigManagerMicCore.configuration |
42 |
| - .get(Configuration.CATEGORY_GENERAL, "Enable Debug messages", false, "Enable debug messages during Galacticraft bytecode injection at startup.").getBoolean(false); |
| 61 | + ConfigManagerMicCore.enableDebug = ConfigManagerMicCore.configuration.get(Configuration.CATEGORY_GENERAL, "logDebugOutput", false, "If `true` Enable debug messages during Galacticraft bytecode injection at startup").getBoolean(false); |
43 | 62 | } catch (final Exception e)
|
44 | 63 | {
|
45 |
| - MicdoodlePlugin.miccoreLogger.error("Problem loading core config (\"miccore.conf\")"); |
| 64 | + MicdoodlePlugin.miccoreLogger.error("Problem loading core config (\"MicdoodleCore.conf\")"); |
46 | 65 | } finally
|
47 | 66 | {
|
48 | 67 | if (ConfigManagerMicCore.configuration.hasChanged())
|
|
0 commit comments