diff options
Diffstat (limited to 'src/main/java/cc/polyfrost')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/config/Config.java | 7 | ||||
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java | 1 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/Config.java index 2ba5077..62609d4 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/Config.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/Config.java @@ -93,13 +93,14 @@ public class Config { protected void generateOptionList(Object instance, OptionPage page, Mod mod, boolean migrate) { for (Field field : instance.getClass().getDeclaredFields()) { Option option = ConfigUtils.findAnnotation(field, Option.class); + String optionName = (page.equals(mod.defaultPage) ? "" : page.name + ".") + field.getName(); if (option != null) { BasicOption configOption = ConfigUtils.addOptionToPage(page, option, field, instance, migrate ? mod.migrator : null); - optionNames.put(page.equals(mod.defaultPage) ? "" : page.name + "." + field.getName(), configOption); + optionNames.put(optionName, configOption); } else if (field.isAnnotationPresent(CustomOption.class)) { BasicOption configOption = getCustomOption(field, page, mod, migrate); if (configOption == null) continue; - optionNames.put(page.equals(mod.defaultPage) ? "" : page.name + "." + field.getName(), configOption); + optionNames.put(optionName, configOption); } else if (field.isAnnotationPresent(Page.class)) { Page optionPage = field.getAnnotation(Page.class); OptionSubcategory subcategory = ConfigUtils.getSubCategory(page, optionPage.category(), optionPage.subcategory()); @@ -196,7 +197,7 @@ public class Config { /** * Disable an option if a certain condition is not met * - * @param option The name of the field, or if the field is in a page "pageName.fieldName" + * @param option The name of the field, or if the field is in a page "pageName.fieldName" * @param value The value of the dependency */ protected void addDependency(String option, boolean value) { diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java index aee6d6b..8279353 100644 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java +++ b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java @@ -121,6 +121,7 @@ public class TestConfig_Test extends Config { public TestConfig_Test() { super(new Mod("Test Mod", ModType.UTIL_QOL, new VigilanceMigrator("./config/testConfig.toml")), "hacksConfig.json"); + addDependency("testCheckBox", "testSwitch"); } } |