diff options
author | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-05-10 20:19:07 +0100 |
---|---|---|
committer | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-05-10 20:19:07 +0100 |
commit | cefe13f6c232ed5ca2d458b896a76df2ee25a8a3 (patch) | |
tree | d64f34e2ee55124ce9c3469fea9333d94ccfb23f /src/main/java/cc/polyfrost/oneconfig/config/interfaces | |
parent | b5a1aea2239b0beace4d4407d2ab75294c6eab12 (diff) | |
parent | 3872c0ae8746e69671ac9b44ff94dc3c7b194817 (diff) | |
download | OneConfig-cefe13f6c232ed5ca2d458b896a76df2ee25a8a3.tar.gz OneConfig-cefe13f6c232ed5ca2d458b896a76df2ee25a8a3.tar.bz2 OneConfig-cefe13f6c232ed5ca2d458b896a76df2ee25a8a3.zip |
reduce dependency on minecraft + stuff
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/config/interfaces')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java index 756d3c3..9eecc52 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java @@ -6,6 +6,7 @@ import cc.polyfrost.oneconfig.config.core.ConfigCore; import cc.polyfrost.oneconfig.config.data.Mod; import cc.polyfrost.oneconfig.config.data.OptionCategory; import cc.polyfrost.oneconfig.config.data.OptionPage; +import cc.polyfrost.oneconfig.config.data.OptionSubcategory; import cc.polyfrost.oneconfig.config.profiles.Profiles; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.elements.config.*; @@ -84,6 +85,10 @@ public class Config { ConfigPage option = field.getAnnotation(ConfigPage.class); if (!page.categories.containsKey(option.category())) page.categories.put(option.category(), new OptionCategory()); + OptionCategory category = page.categories.get(option.category()); + if (category.subcategories.size() == 0 || !category.subcategories.get(category.subcategories.size() - 1).getName().equals(option.subcategory())) + category.subcategories.add(new OptionSubcategory(option.subcategory())); + OptionSubcategory subcategory = category.subcategories.get(category.subcategories.size() - 1); OptionPage newPage = new OptionPage(option.name(), mod); try { field.setAccessible(true); @@ -91,10 +96,10 @@ public class Config { generateOptionList(object.getClass(), newPage, mod); switch (option.location()) { case TOP: - page.categories.get(option.category()).topPages.add(new ConfigPageButton(field, option.name(), option.description(), newPage)); + subcategory.topButtons.add(new ConfigPageButton(field, option.name(), option.description(), newPage)); break; case BOTTOM: - page.categories.get(option.category()).bottomPages.add(new ConfigPageButton(field, option.name(), option.description(), newPage)); + subcategory.bottomButtons.add(new ConfigPageButton(field, option.name(), option.description(), newPage)); break; } } catch (IllegalAccessException e) { @@ -105,9 +110,10 @@ public class Config { Option option = field.getAnnotation(Option.class); if (!page.categories.containsKey(option.category())) page.categories.put(option.category(), new OptionCategory()); - if (!page.categories.get(option.category()).subcategories.containsKey(option.subcategory())) - page.categories.get(option.category()).subcategories.put(option.subcategory(), new ArrayList<>()); - ArrayList<BasicOption> options = page.categories.get(option.category()).subcategories.get(option.subcategory()); + OptionCategory category = page.categories.get(option.category()); + if (category.subcategories.size() == 0 || !category.subcategories.get(category.subcategories.size() - 1).getName().equals(option.subcategory())) + category.subcategories.add(new OptionSubcategory(option.subcategory())); + ArrayList<BasicOption> options = category.subcategories.get(category.subcategories.size() - 1).options; switch (option.type()) { case SWITCH: options.add(new ConfigSwitch(field, option.name(), option.size())); @@ -136,6 +142,12 @@ public class Config { case COLOR: options.add(new ConfigColorElement(field, option.name(), option.size())); break; + case HEADER: + options.add(new ConfigHeader(field, option.name(), option.size())); + break; + case BUTTON: + options.add(new ConfigButton(field, option.name(), option.size(), option.buttonText())); + break; } } } @@ -172,7 +184,7 @@ public class Config { Object object = adapter.fromJsonTree(value); field.setAccessible(true); field.set(this, object); - } catch (NoSuchFieldException | IllegalAccessException ignored) { + } catch (Exception ignored) { } } } |