2022-07-30 15:21:11 +02:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2022 FalsePattern
|
|
|
|
|
* All Rights Reserved
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice, this permission notice and the word "SNEED"
|
|
|
|
|
* shall be included in all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
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-07-25 00:32:10 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Signals that this configuration entry/class should be synchronized between the client and the server when
|
|
|
|
|
* joining a multiplayer instance.
|
|
|
|
|
*
|
|
|
|
|
* Note that synchronization ALWAYS happens FROM the server TO the client. The server should NEVER attempt to get
|
|
|
|
|
* configuration values from a client. This is to avoid malicious clients manipulating the server configs.
|
|
|
|
|
*/
|
|
|
|
|
@StableAPI(since = "0.10.0")
|
|
|
|
|
@Documented
|
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
|
|
|
@Target({ElementType.FIELD, ElementType.TYPE})
|
|
|
|
|
@interface Synchronize {
|
|
|
|
|
/**
|
|
|
|
|
* This is a limit on how many bytes the client will accept from the server. If this limit is exceeded,
|
|
|
|
|
* the client shall refuse to connect to the server. For String[]-s, the amount of bytes is the sum of all
|
|
|
|
|
* strings inside the array.<br><br>
|
|
|
|
|
*
|
|
|
|
|
* This limitation option exists to avoid malicious servers flooding clients with data.<br><br>
|
|
|
|
|
*
|
|
|
|
|
* By default, the client will accept any amount of bytes.<br><br>
|
|
|
|
|
*
|
|
|
|
|
* This only applies for String and String[] configurations, and is ignored on the other config types.
|
|
|
|
|
* For enums, this value is computed automatically.
|
|
|
|
|
*/
|
|
|
|
|
int maxLength();
|
|
|
|
|
}
|
2022-05-06 18:57:02 +02:00
|
|
|
}
|