Skip to content

Commit

Permalink
ModDetectedDefault config annotation (#65)
Browse files Browse the repository at this point in the history
* ModDetectedDefault annotation v2

* better default value parsing and more descriptive exceptions

* A ModDetectedDefaultList would be nice too

* remove test stuff

* remove the mountain of exceptions from parsers

* check coremod first

* return the default value string instead of annotation
  • Loading branch information
Lyfts authored Sep 2, 2024
1 parent d1714b9 commit 0ec72e9
Show file tree
Hide file tree
Showing 2 changed files with 292 additions and 116 deletions.
27 changes: 27 additions & 0 deletions src/main/java/com/gtnewhorizon/gtnhlib/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,31 @@
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD, ElementType.TYPE })
@interface RequiresWorldRestart {}

/**
* Set a default value if the listed coremod or modID is found. Coremod will take precedence value will be parsed to
* target field's type
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface ModDetectedDefault {

String coremod() default "";

String modID() default "";

String value() default "";

/**
* Can be used instead of value() for array fields
*/
String[] values() default {};
}

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface ModDetectedDefaultList {

ModDetectedDefault[] values() default {};
}
}
Loading

0 comments on commit 0ec72e9

Please sign in to comment.