Files
FalsePatternLib/src/main/java/com/falsepattern/lib/config/Config.java
T

188 lines
5.0 KiB
Java
Raw Normal View History

2022-05-06 18:57:02 +02:00
package com.falsepattern.lib.config;
2022-05-06 23:53:11 +02:00
import com.falsepattern.lib.StableAPI;
2022-06-08 16:01:06 +02:00
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
2022-05-06 23:53:11 +02:00
2022-07-25 00:31:10 +02:00
/**
* A modern configuration system to replace the old and obtuse forge config system.
*
* Note that just annotating a configuration class with {@link Config} is not enough, you must also register it using
* {@link com.falsepattern.lib.config.ConfigurationManager#registerConfig}!
*/
2022-05-06 23:53:11 +02:00
@Documented
2022-05-06 18:57:02 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
2022-05-06 23:53:11 +02:00
@StableAPI(since = "0.6.0")
2022-05-06 18:57:02 +02:00
public @interface Config {
/**
* The mod id that this configuration is associated with.
*/
String modid();
/**
2022-05-07 16:43:34 +02:00
* Root element category, defaults to "general". You must not specify an empty string.
2022-05-06 18:57:02 +02:00
*/
String category() default "general";
2022-07-25 00:31:10 +02:00
/**
* The lang file key of this configuration. Used in config GUIs.
*/
@Documented
2022-05-06 18:57:02 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
@interface LangKey {
String value();
}
2022-07-25 00:31:10 +02:00
/**
* The description of the configuration.
*/
@Documented
2022-05-06 18:57:02 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface Comment {
String[] value();
}
2022-07-25 00:31:10 +02:00
/**
* If you have extra fields in the config class used for anything else other than configuring, you must annotate
* the using this so that the config engine doesn't pick them up.
*/
@Documented
2022-05-06 18:57:02 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
2022-06-08 16:01:06 +02:00
@interface Ignore {
}
2022-05-06 18:57:02 +02:00
2022-07-25 00:31:10 +02:00
/**
* The default value for a boolean field. Not having a default is deprecated since 0.10, and will be strongly
* enforced in 0.11+!
*/
@Documented
2022-05-07 01:33:04 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultBoolean {
boolean value();
}
2022-07-25 00:31:10 +02:00
/**
* The range of possible values an int config can have.
*/
@Documented
2022-05-06 18:57:02 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface RangeInt {
int min() default Integer.MIN_VALUE;
int max() default Integer.MAX_VALUE;
}
2022-07-25 00:31:10 +02:00
/**
* The default value for an int field. Not having a default is deprecated since 0.10, and will be strongly
* enforced in 0.11+!
*/
@Documented
2022-05-06 23:48:24 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultInt {
2022-05-07 01:33:04 +02:00
int value();
}
2022-07-25 00:31:10 +02:00
/**
* The range of possible values a float config can have.
*/
@Documented
2022-05-07 01:33:04 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface RangeFloat {
float min() default Float.MIN_VALUE;
float max() default Float.MAX_VALUE;
2022-05-06 23:48:24 +02:00
}
2022-07-25 00:31:10 +02:00
/**
* The default value for a float field. Not having a default is deprecated since 0.10, and will be strongly
* enforced in 0.11+!
*/
@Documented
2022-05-06 18:57:02 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
2022-05-07 01:33:04 +02:00
@interface DefaultFloat {
float value();
}
2022-05-06 18:57:02 +02:00
2022-07-25 00:31:10 +02:00
/**
* The default value for a String field. Not having a default is deprecated since 0.10, and will be strongly
* enforced in 0.11+!
*/
@Documented
2022-05-07 01:33:04 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultString {
String value();
2022-05-06 18:57:02 +02:00
}
2022-07-25 00:31:10 +02:00
/**
* A regex pattern for restricting the allowed strings.
*/
@Documented
2022-05-06 23:48:24 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
2022-05-07 01:33:04 +02:00
@interface Pattern {
String value();
2022-05-06 23:48:24 +02:00
}
2022-07-25 00:31:10 +02:00
/**
* The default value for an Enum field. Not having a default is deprecated since 0.10, and will be strongly
* enforced in 0.11+!
*/
@Documented
2022-05-07 11:45:57 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultEnum {
String value();
}
2022-07-25 00:31:10 +02:00
/**
* The default value for a string array field. Not having a default is deprecated since 0.10, and will be strongly
* enforced in 0.11+!
*/
@Documented
2022-06-07 21:10:21 -04:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface DefaultStringList {
String[] value();
}
2022-07-25 00:31:10 +02:00
/**
* The name of this config property in the config file. If not specified, the field's name will be used instead.
*/
@Documented
2022-05-06 18:57:02 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface Name {
String value();
}
2022-07-25 00:31:10 +02:00
/**
* Whether the specific configuration needs a minecraft restart to be applied.
*/
@Documented
2022-05-06 18:57:02 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
2022-06-08 16:01:06 +02:00
@interface RequiresMcRestart {
}
2022-05-06 18:57:02 +02:00
2022-07-25 00:31:10 +02:00
/**
* Whether the specific configuration needs a world/server rejoin to be applied.
*/
@Documented
2022-05-06 18:57:02 +02:00
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
2022-06-08 16:01:06 +02:00
@interface RequiresWorldRestart {
}
2022-05-06 18:57:02 +02:00
}