From 8e718cdd0905c8aee4dda410e3c559bcf2a28dec Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Wed, 16 Feb 2022 13:08:12 +0100 Subject: custom option support --- .../io/polyfrost/oneconfig/config/interfaces/Config.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/main/java/io') 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,11 +87,19 @@ 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 * -- cgit