mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-18 12:39:14 +00:00
Deprecate the StableAPI annotations, switch to JB annotations
This commit is contained in:
96 files changed
+1079
-762
No files matched your search
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
@@ -75,7 +74,6 @@ import java.util.function.BiConsumer;
|
||||
* <br>
|
||||
* {@link NoSync} - You MUST add this to fields that you don't want to be synchronized by {@link Synchronize}.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@@ -85,19 +83,21 @@ public @interface Config {
|
||||
* If {@link #customPath()} is not set, this is used for the config file name (.minecraft/config/modid.cfg)
|
||||
* @see #customPath()
|
||||
*/
|
||||
@StableAPI.Expose String modid();
|
||||
String modid();
|
||||
|
||||
/**
|
||||
* Root element category, defaults to "general". MUST NOT be an empty string.
|
||||
*/
|
||||
@StableAPI.Expose String category() default "general";
|
||||
String category() default "general";
|
||||
|
||||
/**
|
||||
* Define category migrations here.
|
||||
* Used to rename config categories without losing data.
|
||||
* @see #pathMigrations()
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "1.5.0") String[] categoryMigrations() default {};
|
||||
String[] categoryMigrations() default {};
|
||||
|
||||
/**
|
||||
* A custom configuration file path. Relative to the .minecraft/config folder.
|
||||
@@ -110,8 +110,10 @@ public @interface Config {
|
||||
* customPath = "mymod.config" -> .minecraft/config/mymod.config
|
||||
* <br>
|
||||
* @see #modid()
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "1.5.0") String customPath() default "";
|
||||
String customPath() default "";
|
||||
|
||||
/**
|
||||
* Define file migration paths here.
|
||||
@@ -124,8 +126,10 @@ public @interface Config {
|
||||
* the category of this config.
|
||||
* @see #customPath()
|
||||
* @see #categoryMigrations()
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "1.5.0") String[] pathMigrations() default {};
|
||||
String[] pathMigrations() default {};
|
||||
|
||||
// region Common
|
||||
|
||||
@@ -133,12 +137,11 @@ public @interface Config {
|
||||
* The description of the configuration or the category. Should be in the primary language of the mod.
|
||||
* @see LangKey
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@interface Comment {
|
||||
@StableAPI.Expose String[] value();
|
||||
String[] value();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,19 +155,17 @@ public @interface Config {
|
||||
* Also applies to categories, where it gets autogenerated from the modid and category (config.MODID.CATEGORY)
|
||||
* @see Comment
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@interface LangKey {
|
||||
@StableAPI.Expose String value() default "";
|
||||
String value() default "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@@ -173,23 +174,23 @@ public @interface Config {
|
||||
/**
|
||||
* The name of this config property in the config file. If not specified, the field's name will be used instead.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Name {
|
||||
@StableAPI.Expose String value();
|
||||
String value();
|
||||
|
||||
/**
|
||||
* Use this to migrate from old config names. "" is resolved to the name of the field
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "1.5.0") String[] migrations() default {};
|
||||
String[] migrations() default {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the specific configuration needs a minecraft restart to be applied.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@@ -198,7 +199,6 @@ public @interface Config {
|
||||
/**
|
||||
* Whether the specific configuration needs a world/server rejoin to be applied.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@@ -214,8 +214,9 @@ public @interface Config {
|
||||
* <p>
|
||||
* 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.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@@ -223,8 +224,9 @@ public @interface Config {
|
||||
|
||||
/**
|
||||
* Use this to mark config fields you don't want to synchronize in a class marked with {@link Synchronize}.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@@ -238,12 +240,11 @@ public @interface Config {
|
||||
* The default value for a boolean field. Not having a default is deprecated since 0.10, and will be strongly
|
||||
* enforced in 0.11+!
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultBoolean {
|
||||
@StableAPI.Expose boolean value();
|
||||
boolean value();
|
||||
}
|
||||
|
||||
// endregion
|
||||
@@ -254,25 +255,23 @@ public @interface Config {
|
||||
* The default value for an int field.
|
||||
* @see RangeInt
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultInt {
|
||||
@StableAPI.Expose int value();
|
||||
int value();
|
||||
}
|
||||
|
||||
/**
|
||||
* The range of possible values an int config can have.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface RangeInt {
|
||||
@StableAPI.Expose int min() default Integer.MIN_VALUE;
|
||||
int min() default Integer.MIN_VALUE;
|
||||
|
||||
@StableAPI.Expose int max() default Integer.MAX_VALUE;
|
||||
int max() default Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
// endregion
|
||||
@@ -282,26 +281,28 @@ public @interface Config {
|
||||
/**
|
||||
* The default value for a double field.
|
||||
* @see RangeDouble
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultDouble {
|
||||
@StableAPI.Expose double value();
|
||||
double value();
|
||||
}
|
||||
|
||||
/**
|
||||
* The range of possible values a double config can have.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface RangeDouble {
|
||||
@StableAPI.Expose double min() default -Double.MAX_VALUE;
|
||||
double min() default -Double.MAX_VALUE;
|
||||
|
||||
@StableAPI.Expose double max() default Double.MAX_VALUE;
|
||||
double max() default Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
// endregion
|
||||
@@ -313,37 +314,36 @@ public @interface Config {
|
||||
* @see StringMaxLength
|
||||
* @see Pattern
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultString {
|
||||
@StableAPI.Expose String value();
|
||||
String value();
|
||||
}
|
||||
|
||||
/**
|
||||
* This annotation limits the maximum number of characters present in a string configuration.
|
||||
* <p>
|
||||
* When used with a string list, this limit will apply to each element individually, not to the size of the list as a whole.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface StringMaxLength {
|
||||
@StableAPI.Expose int value();
|
||||
int value();
|
||||
}
|
||||
|
||||
/**
|
||||
* A regex pattern for restricting the allowed strings.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Pattern {
|
||||
@Language("RegExp")
|
||||
@StableAPI.Expose String value();
|
||||
String value();
|
||||
}
|
||||
|
||||
// endregion
|
||||
@@ -353,12 +353,11 @@ public @interface Config {
|
||||
/**
|
||||
* The default value for an Enum field.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultEnum {
|
||||
@StableAPI.Expose String value();
|
||||
String value();
|
||||
}
|
||||
|
||||
// endregion
|
||||
@@ -369,13 +368,14 @@ public @interface Config {
|
||||
* The default value for a boolean array field.
|
||||
* @see ListFixedLength
|
||||
* @see ListMaxLength
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultBooleanList {
|
||||
@StableAPI.Expose boolean[] value();
|
||||
boolean[] value();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -383,13 +383,14 @@ public @interface Config {
|
||||
* @see ListFixedLength
|
||||
* @see ListMaxLength
|
||||
* @see RangeInt
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultIntList {
|
||||
@StableAPI.Expose int[] value();
|
||||
int[] value();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,13 +398,14 @@ public @interface Config {
|
||||
* @see ListFixedLength
|
||||
* @see ListMaxLength
|
||||
* @see RangeDouble
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultDoubleList {
|
||||
@StableAPI.Expose double[] value();
|
||||
double[] value();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,20 +415,20 @@ public @interface Config {
|
||||
* @see StringMaxLength
|
||||
* @see Pattern
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultStringList {
|
||||
@StableAPI.Expose String[] value();
|
||||
String[] value();
|
||||
}
|
||||
|
||||
/**
|
||||
* If this annotation is present, the list in the config will be forced to have exactly the amount of elements as
|
||||
* the default value.
|
||||
* @see ListMaxLength
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@@ -435,13 +437,14 @@ public @interface Config {
|
||||
/**
|
||||
* This annotation limits the maximum number of elements present in an array configuration. Only effective if
|
||||
* {@link ListFixedLength} is NOT present.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface ListMaxLength {
|
||||
@StableAPI.Expose int value();
|
||||
int value();
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
@@ -21,25 +21,24 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* A really basic wrapper for config to simplify handling them in external code.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
public class ConfigException extends Exception {
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ConfigException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ConfigException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ConfigException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.ReflectionUtil;
|
||||
import com.falsepattern.lib.internal.impl.config.ConfigurationManagerImpl;
|
||||
import lombok.AccessLevel;
|
||||
@@ -41,24 +40,28 @@ import java.util.function.BiConsumer;
|
||||
* Class for controlling the loading of configuration files.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@StableAPI(since = "0.6.0")
|
||||
public class ConfigurationManager {
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static void initialize(Class<?>... configClasses) throws ConfigException {
|
||||
initialize((a, b) -> {}, configClasses);
|
||||
}
|
||||
|
||||
/**
|
||||
* You can use this method in the static initializer of a config class to self-load it without extra effort.
|
||||
*
|
||||
* @since 0.10.3
|
||||
*/
|
||||
@StableAPI.Expose(since = "0.10.3")
|
||||
@SneakyThrows
|
||||
public static void selfInit() {
|
||||
initialize(ReflectionUtil.getCallerClass());
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static void initialize(BiConsumer<Class<?>, Field> validatorErrorCallback, Class<?>... configClasses)
|
||||
throws ConfigException {
|
||||
for (val clazz : configClasses) {
|
||||
@@ -69,12 +72,16 @@ public class ConfigurationManager {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static boolean validate(boolean resetInvalid, Class<?>... configClasses) throws ConfigException {
|
||||
return validate((x, y) -> {}, resetInvalid, configClasses);
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static boolean validate(BiConsumer<Class<?>, Field> validatorErrorCallback, boolean resetInvalid, Class<?>... configClasses)
|
||||
throws ConfigException {
|
||||
boolean valid = true;
|
||||
@@ -84,14 +91,18 @@ public class ConfigurationManager {
|
||||
return valid;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static void loadFromFile(Class<?>... configClasses) throws ConfigException {
|
||||
for (val clazz : configClasses) {
|
||||
ConfigurationManagerImpl.load(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static void saveToFile(boolean validateAndResetInvalid, Class<?>... configClasses) throws ConfigException {
|
||||
for (val clazz : configClasses) {
|
||||
if (validateAndResetInvalid) {
|
||||
@@ -109,7 +120,6 @@ public class ConfigurationManager {
|
||||
* @return The configuration elements.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@StableAPI.Expose
|
||||
public static List<IConfigElement> getConfigElements(Class<?> configClass) throws ConfigException {
|
||||
return ConfigurationManagerImpl.getConfigElements(configClass);
|
||||
}
|
||||
@@ -120,9 +130,10 @@ public class ConfigurationManager {
|
||||
* @param configClasses The classes to process.
|
||||
*
|
||||
* @return The configuration elements.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
public static List<IConfigElement> getConfigElementsMulti(Class<?>... configClasses) throws ConfigException {
|
||||
switch (configClasses.length) {
|
||||
case 0:
|
||||
@@ -139,10 +150,11 @@ public class ConfigurationManager {
|
||||
}
|
||||
/**
|
||||
* @return The configuration elements, structured with DummyCategoryElement groups per config class
|
||||
* @see #getConfigElementsMulti(Class[])
|
||||
* @see #getConfigElementsMulti(Class[])
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@StableAPI.Expose(since = "1.5.0")
|
||||
public static List<IConfigElement> getConfigElementsMultiStructured(Class<?>... configClasses) throws ConfigException {
|
||||
if (configClasses.length == 0) {
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -21,29 +21,33 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import cpw.mods.fml.client.config.GuiConfig;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @since 0.9.0
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.9.0")
|
||||
public class SimpleGuiConfig extends GuiConfig {
|
||||
@StableAPI.Expose
|
||||
public SimpleGuiConfig(GuiScreen parent, Class<?> configClass, String modID, String modName)
|
||||
throws ConfigException {
|
||||
this(parent, modID, modName, configClass);
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public SimpleGuiConfig(GuiScreen parent, String modID, String title, Class<?>... configClasses)
|
||||
throws ConfigException {
|
||||
this(parent, modID, title, null, configClasses);
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "1.5.0")
|
||||
|
||||
/**
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public SimpleGuiConfig(GuiScreen parent, String modID, String title, String titleLine2, Class<?>... configClasses)
|
||||
throws ConfigException {
|
||||
super(parent,
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import cpw.mods.fml.client.IModGuiFactory;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -30,8 +28,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @since 0.9.0
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.9.0")
|
||||
public interface SimpleGuiFactory extends IModGuiFactory {
|
||||
@Override
|
||||
default void initialize(Minecraft minecraftInstance) {
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -35,28 +35,26 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
* This is a client-only event, and is never triggered serverside!
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class AllConfigSyncEvent extends Event {
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public AllConfigSyncEvent() {
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static boolean postStart() {
|
||||
val event = new Start();
|
||||
return EventUtil.postOnCommonBus(event);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postEnd() {
|
||||
EventUtil.postOnCommonBus(new End());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class Start extends AllConfigSyncEvent {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public Start() {
|
||||
}
|
||||
|
||||
@@ -67,9 +65,8 @@ public class AllConfigSyncEvent extends Event {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class End extends AllConfigSyncEvent {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public End() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -35,37 +35,34 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
* This is a client-only event, and is never triggered serverside!
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class ConfigSyncEvent extends Event {
|
||||
@StableAPI.Expose
|
||||
public final Class<?> configClass;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ConfigSyncEvent(Class<?> configClass) {
|
||||
this.configClass = configClass;
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static boolean postStart(Class<?> configClass) {
|
||||
val event = new Start(configClass);
|
||||
return EventUtil.postOnCommonBus(event);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postEndSuccess(Class<?> configClass) {
|
||||
EventUtil.postOnCommonBus(new End(configClass, true, null));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postEndFailure(Class<?> configClass, Throwable error) {
|
||||
EventUtil.postOnCommonBus(new End(configClass, false, error));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class Start extends ConfigSyncEvent {
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public Start(Class<?> configClass) {
|
||||
super(configClass);
|
||||
}
|
||||
@@ -77,15 +74,11 @@ public class ConfigSyncEvent extends Event {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class End extends ConfigSyncEvent {
|
||||
@StableAPI.Expose
|
||||
public final boolean successful;
|
||||
|
||||
@StableAPI.Expose
|
||||
public final Throwable error;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public End(Class<?> configClass, boolean successful, Throwable error) {
|
||||
super(configClass);
|
||||
this.successful = successful;
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
@@ -36,39 +36,33 @@ import java.util.List;
|
||||
* different game sides. If you want to trigger this on the server, use {@link #postServer}, and if on the client, use
|
||||
* {@link #postClient}
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class ConfigSyncRequestEvent extends Event {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ConfigSyncRequestEvent() {
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void postClient() {
|
||||
EventUtil.postOnCommonBus(new Client());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void postServer(List<EntityPlayerMP> players) {
|
||||
EventUtil.postOnCommonBus(new Server(new ArrayList<>(players)));
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class Client extends ConfigSyncRequestEvent {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public Client() {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class Server extends ConfigSyncRequestEvent {
|
||||
private final List<EntityPlayerMP> players;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public Server(List<EntityPlayerMP> players) {
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public List<EntityPlayerMP> getPlayers() {
|
||||
return Collections.unmodifiableList(players);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
import com.falsepattern.lib.internal.FPLog;
|
||||
@@ -30,6 +29,7 @@ import com.falsepattern.lib.toasts.GuiToast;
|
||||
import com.falsepattern.lib.toasts.SimpleToast;
|
||||
import com.falsepattern.lib.toasts.icon.ToastBG;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
@@ -38,20 +38,14 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class ConfigValidationFailureEvent extends Event {
|
||||
@StableAPI.Expose
|
||||
public final String reason;
|
||||
@StableAPI.Expose
|
||||
public final Class<?> configClass;
|
||||
@StableAPI.Expose
|
||||
public final String fieldName;
|
||||
@StableAPI.Expose
|
||||
public final boolean listElement;
|
||||
@StableAPI.Expose
|
||||
public final int listIndex;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
protected ConfigValidationFailureEvent(String reason, Class<?> configClass, String fieldName, boolean listElement, int listIndex) {
|
||||
this.reason = reason;
|
||||
this.configClass = configClass;
|
||||
@@ -60,7 +54,7 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
this.listIndex = listIndex;
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postNumericRangeOutOfBounds(Field field, int listIndex, String value, String min, String max) {
|
||||
EventUtil.postOnCommonBus(new NumericRangeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
@@ -70,7 +64,7 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
max));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postSize(Field field, int requestedSize, boolean fixedSize, int maxSize, int defaultSize) {
|
||||
EventUtil.postOnCommonBus(new ListSizeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
@@ -80,7 +74,7 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
defaultSize));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postStringSizeOutOfBounds(Field field, int listIndex, String text, int maxSize) {
|
||||
EventUtil.postOnCommonBus(new StringSizeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
@@ -89,12 +83,12 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
maxSize));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void fieldIsNull(Field field, int listIndex) {
|
||||
EventUtil.postOnCommonBus(new FieldIsNull(field.getDeclaringClass(), field.getName(), listIndex));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postStringPatternMismatch(Field field, int listIndex, String text, String pattern) {
|
||||
EventUtil.postOnCommonBus(new StringPatternMismatch(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
@@ -103,8 +97,8 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
pattern));
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI.Internal
|
||||
public void toast() {
|
||||
val ann = configClass.getAnnotation(Config.class);
|
||||
val toast = new SimpleToast(ToastBG.TOAST_DARK,
|
||||
@@ -118,11 +112,11 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
GuiToast.add(toast);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
protected void customText(StringBuilder b) {
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public void logWarn() {
|
||||
val errorString = new StringBuilder("Error validating configuration field!");
|
||||
errorString.append("\nReason: ").append(reason);
|
||||
@@ -136,16 +130,12 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class NumericRangeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final String value;
|
||||
@StableAPI.Expose
|
||||
public final String min;
|
||||
@StableAPI.Expose
|
||||
public final String max;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public NumericRangeOutOfBounds(Class<?> configClass, String fieldName, int listIndex, String value, String min, String max) {
|
||||
super("Number range out of bounds", configClass, fieldName, listIndex >= 0, listIndex);
|
||||
this.value = value;
|
||||
@@ -159,18 +149,13 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class ListSizeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final int size;
|
||||
@StableAPI.Expose
|
||||
public final boolean fixedSize;
|
||||
@StableAPI.Expose
|
||||
public final int maxSize;
|
||||
@StableAPI.Expose
|
||||
public final int defaultSize;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ListSizeOutOfBounds(Class<?> configClass, String fieldName, int size, boolean fixedSize, int maxSize, int defaultSize) {
|
||||
super("Array size out of bounds", configClass, fieldName, false, -1);
|
||||
this.size = size;
|
||||
@@ -189,14 +174,11 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class StringSizeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final String text;
|
||||
@StableAPI.Expose
|
||||
public final int maxSize;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public StringSizeOutOfBounds(Class<?> configClass, String fieldName, int listIndex, String text, int maxSize) {
|
||||
super("String size out of bounds", configClass, fieldName, listIndex >= 0, listIndex);
|
||||
this.text = text;
|
||||
@@ -214,9 +196,8 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class FieldIsNull extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public FieldIsNull(Class<?> configClass, String fieldName, int listIndex) {
|
||||
super("Unexpected null", configClass, fieldName, listIndex >= 0, listIndex);
|
||||
}
|
||||
@@ -227,14 +208,11 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class StringPatternMismatch extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final String text;
|
||||
@StableAPI.Expose
|
||||
public final String pattern;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public StringPatternMismatch(Class<?> configClass, String fieldName, int listIndex, String text, String pattern) {
|
||||
super("String pattern mismatch", configClass, fieldName, listIndex >= 0, listIndex);
|
||||
this.text = text;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib 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, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
package com.falsepattern.lib.config.event;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib 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, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.6.0
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
Reference in new issue
Block a user