Skip to content

Commit 39fd0d6

Browse files
committed
backport config annotations
1 parent 97b7716 commit 39fd0d6

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.falsepattern.lib.config;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
@Retention(RetentionPolicy.RUNTIME)
9+
@Target(ElementType.TYPE)
10+
public @interface Config {
11+
/**
12+
* The mod id that this configuration is associated with.
13+
*/
14+
String modid();
15+
16+
/**
17+
* A user friendly name for the config file,
18+
* the default will be modid
19+
*/
20+
String name() default "";
21+
22+
/**
23+
* Root element category, defaults to "general", if this is an empty string then the root category is disabled.
24+
* Any primitive fields will cause an error, and you must specify sub-category objects
25+
*/
26+
String category() default "general";
27+
28+
public static enum Type {
29+
/**
30+
* Loaded once, directly after mod construction. Before pre-init.
31+
* This class must have static fields.
32+
*/
33+
INSTANCE(true);
34+
35+
36+
private boolean isStatic = true;
37+
38+
private Type(boolean isStatic) {this.isStatic = isStatic;}
39+
40+
public boolean isStatic() {return this.isStatic;}
41+
}
42+
43+
@Retention(RetentionPolicy.RUNTIME)
44+
@Target({ElementType.FIELD, ElementType.TYPE})
45+
@interface LangKey {
46+
String value();
47+
}
48+
49+
@Retention(RetentionPolicy.RUNTIME)
50+
@Target(ElementType.FIELD)
51+
@interface Comment {
52+
String[] value();
53+
}
54+
55+
@Retention(RetentionPolicy.RUNTIME)
56+
@Target(ElementType.FIELD)
57+
@interface Ignore {}
58+
59+
@Retention(RetentionPolicy.RUNTIME)
60+
@Target(ElementType.FIELD)
61+
@interface RangeInt {
62+
int min() default Integer.MIN_VALUE;
63+
64+
int max() default Integer.MAX_VALUE;
65+
}
66+
67+
@Retention(RetentionPolicy.RUNTIME)
68+
@Target(ElementType.FIELD)
69+
@interface RangeDouble {
70+
double min() default Double.MIN_VALUE;
71+
72+
double max() default Double.MAX_VALUE;
73+
}
74+
75+
@Retention(RetentionPolicy.RUNTIME)
76+
@Target(ElementType.FIELD)
77+
@interface Name {
78+
String value();
79+
}
80+
81+
@Retention(RetentionPolicy.RUNTIME)
82+
@Target({ElementType.FIELD, ElementType.TYPE})
83+
@interface RequiresMcRestart {}
84+
85+
@Retention(RetentionPolicy.RUNTIME)
86+
@Target({ElementType.FIELD, ElementType.TYPE})
87+
@interface RequiresWorldRestart {}
88+
}

0 commit comments

Comments
 (0)