aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-07-27 13:26:44 +0200
committerGitHub <noreply@github.com>2022-07-27 13:26:44 +0200
commit78407ee8f0eb5f7786042e82108a755319ec8ced (patch)
treebc8ce3d35b3c60e83d963fb4344ea269d3c6b78e /src
parent4f6bb78ddc2e6a418a555189ee665f892c85dfb4 (diff)
downloadOneConfig-78407ee8f0eb5f7786042e82108a755319ec8ced.tar.gz
OneConfig-78407ee8f0eb5f7786042e82108a755319ec8ced.tar.bz2
OneConfig-78407ee8f0eb5f7786042e82108a755319ec8ced.zip
Custom option fixes (#72)
some small changes
Diffstat (limited to 'src')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/Config.java15
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/config/annotations/CustomOption.java8
2 files changed, 10 insertions, 13 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
index 8a90857..1e1f371 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/Config.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/Config.java
@@ -1,9 +1,6 @@
package cc.polyfrost.oneconfig.config;
-import cc.polyfrost.oneconfig.config.annotations.Button;
-import cc.polyfrost.oneconfig.config.annotations.CustomOption;
-import cc.polyfrost.oneconfig.config.annotations.HUD;
-import cc.polyfrost.oneconfig.config.annotations.Page;
+import cc.polyfrost.oneconfig.config.annotations.*;
import cc.polyfrost.oneconfig.config.core.ConfigUtils;
import cc.polyfrost.oneconfig.config.core.OneKeyBind;
import cc.polyfrost.oneconfig.config.data.Mod;
@@ -141,7 +138,7 @@ public class Config {
Object pageInstance = ConfigUtils.getField(field, instance);
if (pageInstance == null) continue;
ConfigPageButton button;
- if(pageInstance instanceof cc.polyfrost.oneconfig.gui.pages.Page) {
+ if (pageInstance instanceof cc.polyfrost.oneconfig.gui.pages.Page) {
button = new ConfigPageButton(field, instance, optionPage.name(), optionPage.description(), optionPage.category(), optionPage.subcategory(), (cc.polyfrost.oneconfig.gui.pages.Page) pageInstance);
} else {
OptionPage newPage = new OptionPage(optionPage.name(), mod);
@@ -154,7 +151,7 @@ public class Config {
HUDUtils.addHudOptions(page, field, instance, this);
}
}
- for (Method method : instance.getClass().getDeclaredMethods()) {
+ /*for (Method method : instance.getClass().getDeclaredMethods()) {
Button button = ConfigUtils.findAnnotation(method, Button.class);
String optionName = pagePath + method.getName();
if (button != null) {
@@ -162,11 +159,12 @@ public class Config {
ConfigUtils.getSubCategory(page, button.category(), button.subcategory()).options.add(option);
optionNames.put(optionName, option);
}
- }
+ }*/
}
/**
- * All fields with the CustomOption annotation are sent to this function
+ * All fields with the CustomOption annotation are sent to this function, overwrite this function to handle custom options,
+ * For documentation please see: <a href="https://docs.polyfrost.cc/oneconfig/config/adding-options/custom-options">https://docs.polyfrost.cc/oneconfig/config/adding-options/custom-options</a>
*
* @param field Target field
* @param annotation The annotation the field has
@@ -175,7 +173,6 @@ public class Config {
* @param migrate If the data should be migrated
*/
protected BasicOption getCustomOption(Field field, CustomOption annotation, OptionPage page, Mod mod, boolean migrate) {
- ConfigUtils.check("CustomOption", field, BasicOption.class);
return null;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/config/annotations/CustomOption.java b/src/main/java/cc/polyfrost/oneconfig/config/annotations/CustomOption.java
index dcfca53..d9ebc80 100644
--- a/src/main/java/cc/polyfrost/oneconfig/config/annotations/CustomOption.java
+++ b/src/main/java/cc/polyfrost/oneconfig/config/annotations/CustomOption.java
@@ -1,15 +1,15 @@
package cc.polyfrost.oneconfig.config.annotations;
-import cc.polyfrost.oneconfig.config.data.OptionType;
-import cc.polyfrost.oneconfig.internal.config.annotations.Option;
-
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+/**
+ * For documentation please see: <a href="https://docs.polyfrost.cc/oneconfig/config/adding-options/custom-options">https://docs.polyfrost.cc/oneconfig/config/adding-options/custom-options</a>
+ */
@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
+@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
public @interface CustomOption {
String id() default "";
}