From 39fd0d62be8fd74b33894f6c09f56b008758dec3 Mon Sep 17 00:00:00 2001 From: FalsePattern <30945458+FalsePattern@users.noreply.github.com> Date: Fri, 6 May 2022 18:57:02 +0200 Subject: [PATCH] backport config annotations --- .../com/falsepattern/lib/config/Config.java | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/main/java/com/falsepattern/lib/config/Config.java diff --git a/src/main/java/com/falsepattern/lib/config/Config.java b/src/main/java/com/falsepattern/lib/config/Config.java new file mode 100644 index 0000000..3764399 --- /dev/null +++ b/src/main/java/com/falsepattern/lib/config/Config.java @@ -0,0 +1,88 @@ +package com.falsepattern.lib.config; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface Config { + /** + * The mod id that this configuration is associated with. + */ + String modid(); + + /** + * A user friendly name for the config file, + * the default will be modid + */ + String name() default ""; + + /** + * Root element category, defaults to "general", if this is an empty string then the root category is disabled. + * Any primitive fields will cause an error, and you must specify sub-category objects + */ + String category() default "general"; + + public static enum Type { + /** + * Loaded once, directly after mod construction. Before pre-init. + * This class must have static fields. + */ + INSTANCE(true); + + + private boolean isStatic = true; + + private Type(boolean isStatic) {this.isStatic = isStatic;} + + public boolean isStatic() {return this.isStatic;} + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.FIELD, ElementType.TYPE}) + @interface LangKey { + String value(); + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.FIELD) + @interface Comment { + String[] value(); + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.FIELD) + @interface Ignore {} + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.FIELD) + @interface RangeInt { + int min() default Integer.MIN_VALUE; + + int max() default Integer.MAX_VALUE; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.FIELD) + @interface RangeDouble { + double min() default Double.MIN_VALUE; + + double max() default Double.MAX_VALUE; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.FIELD) + @interface Name { + String value(); + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.FIELD, ElementType.TYPE}) + @interface RequiresMcRestart {} + + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.FIELD, ElementType.TYPE}) + @interface RequiresWorldRestart {} +} \ No newline at end of file