diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-06-11 10:29:58 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-06-11 10:29:58 +0200 |
commit | d888d6b7358226792bf0cedbe67c7bb26204983f (patch) | |
tree | ef012f65d06d1520312f51e8ccea79384b78e23c /src/main/java/cc/polyfrost/oneconfig | |
parent | 7abfe87ea8fcda67ce4bb6089b61f0efd82bec47 (diff) | |
download | OneConfig-d888d6b7358226792bf0cedbe67c7bb26204983f.tar.gz OneConfig-d888d6b7358226792bf0cedbe67c7bb26204983f.tar.bz2 OneConfig-d888d6b7358226792bf0cedbe67c7bb26204983f.zip |
fix dependencies
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig')
-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"); } } |