aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-02-16 13:08:12 +0100
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-02-16 13:08:12 +0100
commit8e718cdd0905c8aee4dda410e3c559bcf2a28dec (patch)
tree89180765e99e00e146642359a448211ff7b0da8b /src/main/java/io/polyfrost/oneconfig
parent476954e4e0e2fadcd434045534d632e46b33781f (diff)
downloadOneConfig-8e718cdd0905c8aee4dda410e3c559bcf2a28dec.tar.gz
OneConfig-8e718cdd0905c8aee4dda410e3c559bcf2a28dec.tar.bz2
OneConfig-8e718cdd0905c8aee4dda410e3c559bcf2a28dec.zip
custom option support
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java
index ce73f0c..f592152 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java
@@ -15,8 +15,7 @@ import java.util.Map;
public class Config {
private final File configFile;
-
- Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting()
+ private final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting()
.registerTypeAdapterFactory(OneConfigTypeAdapterFactory.getStaticTypeAdapterFactory()).create();
/**
@@ -88,12 +87,20 @@ public class Config {
} else if (field.isAnnotationPresent(TextField.class)) {
TextField textField = field.getAnnotation(TextField.class);
options.add(new OConfigText(field, textField.name(), textField.description(), textField.placeholder(), textField.hideText()));
- }
+ } else loadCustomType(field);
}
return options;
}
/**
+ * Overwrite this method to add your own custom option types
+ *
+ * @param field target field
+ */
+ protected void loadCustomType(Field field) {
+ }
+
+ /**
* Deserialize part of config and load values
*
* @param json json to deserialize