aboutsummaryrefslogtreecommitdiff
path: root/src/oneconfig
diff options
context:
space:
mode:
authorLinnea Gräf <roman.graef@gmail.com>2023-10-02 17:36:27 +0200
committerGitHub <noreply@github.com>2023-10-02 17:36:27 +0200
commitf4f7ec10fd724b05d922204ac1739536b1ec9caa (patch)
tree57e8fb9f98721c7ec8d9a9fec263b1a1523878fc /src/oneconfig
parent3a957574b11d4a3b897ac6b6519ed5689dda2b44 (diff)
downloadNotEnoughUpdates-f4f7ec10fd724b05d922204ac1739536b1ec9caa.tar.gz
NotEnoughUpdates-f4f7ec10fd724b05d922204ac1739536b1ec9caa.tar.bz2
NotEnoughUpdates-f4f7ec10fd724b05d922204ac1739536b1ec9caa.zip
Moul Config (#814)
* Moul Config * Bump version * Fix IQ test and oneconfig * Add version to title * Fix NPE * Fix merge
Diffstat (limited to 'src/oneconfig')
-rw-r--r--src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneConfigCompat.java11
-rw-r--r--src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneMoulConfig.java49
2 files changed, 26 insertions, 34 deletions
diff --git a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneConfigCompat.java b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneConfigCompat.java
index b80db70a..069c3d6a 100644
--- a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneConfigCompat.java
+++ b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneConfigCompat.java
@@ -21,14 +21,9 @@ package io.github.moulberry.notenoughupdates.compat.oneconfig;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.data.ModType;
-import io.github.moulberry.notenoughupdates.core.config.Config;
+import io.github.moulberry.moulconfig.Config;
import io.github.moulberry.notenoughupdates.oneconfig.IOneConfigCompat;
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-
public class OneConfigCompat extends IOneConfigCompat {
Mod mod = new Mod("NotEnoughUpdates", ModType.SKYBLOCK, "/assets/notenoughupdates/logo.png");
@@ -36,7 +31,7 @@ public class OneConfigCompat extends IOneConfigCompat {
OneMoulConfig omc;
@Override
- public void initConfig(Config moulConfig, Runnable saveCallback) {
- omc = new OneMoulConfig(mod, moulConfig, saveCallback);
+ public void initConfig(Config moulConfig) {
+ omc = new OneMoulConfig(mod, moulConfig);
}
}
diff --git a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneMoulConfig.java b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneMoulConfig.java
index 59aa25d1..3e37f12a 100644
--- a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneMoulConfig.java
+++ b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneMoulConfig.java
@@ -26,21 +26,20 @@ import cc.polyfrost.oneconfig.config.elements.OptionSubcategory;
import cc.polyfrost.oneconfig.gui.elements.config.ConfigButton;
import cc.polyfrost.oneconfig.gui.elements.config.ConfigDropdown;
import cc.polyfrost.oneconfig.gui.elements.config.ConfigInfo;
-import cc.polyfrost.oneconfig.gui.elements.config.ConfigSlider;
import cc.polyfrost.oneconfig.gui.elements.config.ConfigSwitch;
import cc.polyfrost.oneconfig.gui.elements.config.ConfigTextBox;
-import io.github.moulberry.notenoughupdates.core.config.Config;
-import io.github.moulberry.notenoughupdates.core.config.annotations.Category;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorText;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
+import io.github.moulberry.moulconfig.Config;
+import io.github.moulberry.moulconfig.annotations.Category;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorButton;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorColour;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorInfoText;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorText;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import java.lang.reflect.Field;
@@ -48,25 +47,23 @@ import java.lang.reflect.Field;
public class OneMoulConfig extends cc.polyfrost.oneconfig.config.Config {
final Config moulConfig;
- private final Runnable saveCallback;
- public OneMoulConfig(Mod modData, Config moulConfig, Runnable saveCallback) {
+ public OneMoulConfig(Mod modData, Config moulConfig) {
super(modData, "_SHOULD_NOT_BE_WRITTEN.json");
if (moulConfig == null) throw new IllegalArgumentException("mfw no moulconfig");
this.moulConfig = moulConfig;
- this.saveCallback = saveCallback;
initialize();
}
@Override
public void initialize() {
- mod.config = this;
+ mod.config = this;
- try {
- processMoulConfig();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
+ try {
+ processMoulConfig();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
cc.polyfrost.oneconfig.config.Config.register(mod);
}
@@ -86,8 +83,8 @@ public class OneMoulConfig extends cc.polyfrost.oneconfig.config.Config {
if (annotation == null) continue;
String cat = category.getName();
String subcategory = "";
- String annotationName = StringUtils.cleanColour( annotation.name());
- String annotationDesc = StringUtils.cleanColour( annotation.desc());
+ String annotationName = StringUtils.cleanColour(annotation.name());
+ String annotationDesc = StringUtils.cleanColour(annotation.desc());
ConfigEditorBoolean configEditorBoolean = optionField.getAnnotation(ConfigEditorBoolean.class);
if (configEditorBoolean != null) {
category.options.add(new ConfigSwitch(
@@ -174,7 +171,7 @@ public class OneMoulConfig extends cc.polyfrost.oneconfig.config.Config {
cat, subcategory, 2, InfoType.ERROR
));
}
- ConfigEditorFSR configEditorFSR = optionField.getAnnotation(ConfigEditorFSR.class);
+ ConfigEditorInfoText configEditorFSR = optionField.getAnnotation(ConfigEditorInfoText.class);
if (configEditorFSR != null) {
category.options.add(new ConfigInfo(
optionField, categoryInstance,
@@ -186,7 +183,7 @@ public class OneMoulConfig extends cc.polyfrost.oneconfig.config.Config {
@Override
public void save() {
- saveCallback.run();
+ moulConfig.saveNow();
}
@Override