mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-17 18:05:01 +00:00
Annotate all the things
This commit is contained in:
63 files changed
+623
-369
No files matched your search
@@ -44,11 +44,13 @@ public @interface Config {
|
||||
/**
|
||||
* The mod id that this configuration is associated with.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
String modid();
|
||||
|
||||
/**
|
||||
* Root element category, defaults to "general". You must not specify an empty string.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
String category() default "general";
|
||||
|
||||
/**
|
||||
@@ -59,6 +61,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@interface LangKey {
|
||||
@StableAPI.Expose
|
||||
String value();
|
||||
}
|
||||
|
||||
@@ -70,6 +73,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Comment {
|
||||
@StableAPI.Expose
|
||||
String[] value();
|
||||
}
|
||||
|
||||
@@ -93,6 +97,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultBoolean {
|
||||
@StableAPI.Expose
|
||||
boolean value();
|
||||
}
|
||||
|
||||
@@ -104,8 +109,9 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface RangeInt {
|
||||
@StableAPI.Expose
|
||||
int min() default Integer.MIN_VALUE;
|
||||
|
||||
@StableAPI.Expose
|
||||
int max() default Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@@ -118,6 +124,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultInt {
|
||||
@StableAPI.Expose
|
||||
int value();
|
||||
}
|
||||
|
||||
@@ -126,14 +133,15 @@ public @interface Config {
|
||||
* Notice: float configs are deprecated! Use double configs instead!
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecationDetails(stableSince = "0.6.0",
|
||||
deprecatedSince = "0.10.0")
|
||||
@DeprecationDetails(deprecatedSince = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@StableAPI(since = "0.6.0")
|
||||
@interface RangeFloat {
|
||||
@StableAPI.Expose
|
||||
float min() default -Float.MAX_VALUE;
|
||||
|
||||
@StableAPI.Expose
|
||||
float max() default Float.MAX_VALUE;
|
||||
}
|
||||
|
||||
@@ -143,12 +151,13 @@ public @interface Config {
|
||||
* Notice: float configs are deprecated! Use double configs instead!
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecationDetails(stableSince = "0.6.0",
|
||||
deprecatedSince = "0.10.0")
|
||||
@DeprecationDetails(deprecatedSince = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@StableAPI(since = "0.6.0")
|
||||
@interface DefaultFloat {
|
||||
@StableAPI.Expose
|
||||
float value();
|
||||
}
|
||||
|
||||
@@ -160,8 +169,9 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface RangeDouble {
|
||||
@StableAPI.Expose
|
||||
double min() default -Double.MAX_VALUE;
|
||||
|
||||
@StableAPI.Expose
|
||||
double max() default Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
@@ -174,6 +184,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultDouble {
|
||||
@StableAPI.Expose
|
||||
double value();
|
||||
}
|
||||
|
||||
@@ -186,6 +197,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultString {
|
||||
@StableAPI.Expose
|
||||
String value();
|
||||
}
|
||||
|
||||
@@ -203,6 +215,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface StringMaxLength {
|
||||
@StableAPI.Expose
|
||||
int value();
|
||||
}
|
||||
|
||||
@@ -214,6 +227,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Pattern {
|
||||
@StableAPI.Expose
|
||||
String value();
|
||||
}
|
||||
|
||||
@@ -226,6 +240,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultEnum {
|
||||
@StableAPI.Expose
|
||||
String value();
|
||||
}
|
||||
|
||||
@@ -238,6 +253,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultStringList {
|
||||
@StableAPI.Expose
|
||||
String[] value();
|
||||
}
|
||||
|
||||
@@ -250,6 +266,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultDoubleList {
|
||||
@StableAPI.Expose
|
||||
double[] value();
|
||||
}
|
||||
|
||||
@@ -262,6 +279,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultIntList {
|
||||
@StableAPI.Expose
|
||||
int[] value();
|
||||
}
|
||||
|
||||
@@ -274,6 +292,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultBooleanList {
|
||||
@StableAPI.Expose
|
||||
boolean[] value();
|
||||
}
|
||||
|
||||
@@ -300,6 +319,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface ListMaxLength {
|
||||
@StableAPI.Expose
|
||||
int value();
|
||||
}
|
||||
|
||||
@@ -312,6 +332,7 @@ public @interface Config {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Name {
|
||||
@StableAPI.Expose
|
||||
String value();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,12 @@ import com.falsepattern.lib.StableAPI;
|
||||
@StableAPI(since = "0.6.0")
|
||||
public class ConfigException extends Exception {
|
||||
|
||||
@StableAPI.Internal
|
||||
public ConfigException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public ConfigException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ public class ConfigurationManager {
|
||||
* @param configClass The class to register.
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecationDetails(stableSince = "0.6.0",
|
||||
deprecatedSince = "0.10.0")
|
||||
@DeprecationDetails(deprecatedSince = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public static void registerConfig(Class<?> configClass) throws ConfigException {
|
||||
FalsePatternLib.getLog()
|
||||
.warn("A mod is using the deprecated config registration method! The following exception contains the stacktrace.",
|
||||
@@ -114,7 +114,7 @@ public class ConfigurationManager {
|
||||
* @return The configuration elements.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@StableAPI(since = "0.6.0")
|
||||
@StableAPI.Expose
|
||||
public static List<IConfigElement> getConfigElements(Class<?> configClass) throws ConfigException {
|
||||
return ConfigurationManagerImpl.getConfigElements(configClass);
|
||||
}
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
|
||||
import cpw.mods.fml.client.config.ConfigGuiType;
|
||||
import cpw.mods.fml.client.config.GuiConfigEntries;
|
||||
import cpw.mods.fml.client.config.GuiEditArrayEntries;
|
||||
import cpw.mods.fml.client.config.IConfigElement;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class IConfigElementProxy<T> implements IConfigElement<T> {
|
||||
private final IConfigElement<T> proxied;
|
||||
private final Runnable onUpdate;
|
||||
|
||||
public IConfigElementProxy(IConfigElement<T> proxied, Runnable onUpdate) {
|
||||
this.proxied = proxied;
|
||||
this.onUpdate = onUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProperty() {
|
||||
return proxied.isProperty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Class<? extends GuiConfigEntries.IConfigEntry> getConfigEntryClass() {
|
||||
return proxied.getConfigEntryClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiEditArrayEntries.IArrayEntry> getArrayEntryClass() {
|
||||
return proxied.getArrayEntryClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return proxied.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQualifiedName() {
|
||||
return proxied.getQualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageKey() {
|
||||
return proxied.getLanguageKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComment() {
|
||||
return proxied.getComment();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public List<IConfigElement> getChildElements() {
|
||||
return proxied.getChildElements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigGuiType getType() {
|
||||
return proxied.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isList() {
|
||||
return proxied.isList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListLengthFixed() {
|
||||
return proxied.isListLengthFixed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxListLength() {
|
||||
return proxied.getMaxListLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault() {
|
||||
return proxied.isDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDefault() {
|
||||
return proxied.getDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getDefaults() {
|
||||
return proxied.getDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToDefault() {
|
||||
proxied.setToDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresWorldRestart() {
|
||||
return proxied.requiresWorldRestart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInGui() {
|
||||
return proxied.showInGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMcRestart() {
|
||||
return proxied.requiresMcRestart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get() {
|
||||
return proxied.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getList() {
|
||||
return proxied.getList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(T value) {
|
||||
proxied.set(value);
|
||||
onUpdate.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(T[] aVal) {
|
||||
proxied.set(aVal);
|
||||
onUpdate.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getValidValues() {
|
||||
return proxied.getValidValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getMinValue() {
|
||||
return proxied.getMinValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getMaxValue() {
|
||||
return proxied.getMaxValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern getValidationPattern() {
|
||||
return proxied.getValidationPattern();
|
||||
}
|
||||
}
|
||||
@@ -31,13 +31,14 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
@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, new Class<?>[]{configClass}, modID, modName);
|
||||
this(parent, modID, modName, configClass);
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public SimpleGuiConfig(GuiScreen parent, Class<?>[] configClasses, String modID, String modName)
|
||||
public SimpleGuiConfig(GuiScreen parent, String modID, String modName, Class<?>... configClasses)
|
||||
throws ConfigException {
|
||||
super(parent, ConfigurationManager.getConfigElementsMulti(configClasses), modID, false, false,
|
||||
modName + " Configuration", I18n.format("falsepatternlib.gui.config.description"));
|
||||
|
||||
@@ -37,23 +37,27 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED,
|
||||
onConstructor_ = @StableAPI.Internal)
|
||||
public class AllConfigSyncEvent extends Event {
|
||||
|
||||
@StableAPI.Internal
|
||||
public static boolean postStart() {
|
||||
val event = new Start();
|
||||
FMLCommonHandler.instance().bus().post(event);
|
||||
return !event.isCanceled();
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postEnd() {
|
||||
FMLCommonHandler.instance().bus().post(new End());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public static class Start extends AllConfigSyncEvent {
|
||||
@NoArgsConstructor(access = AccessLevel.PUBLIC,
|
||||
onConstructor_ = @StableAPI.Internal)
|
||||
public static final class Start extends AllConfigSyncEvent {
|
||||
@Override
|
||||
public boolean isCancelable() {
|
||||
return true;
|
||||
@@ -62,7 +66,8 @@ public class AllConfigSyncEvent extends Event {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public static class End extends AllConfigSyncEvent {
|
||||
@NoArgsConstructor(access = AccessLevel.PUBLIC,
|
||||
onConstructor_ = @StableAPI.Internal)
|
||||
public static final class End extends AllConfigSyncEvent {
|
||||
}
|
||||
}
|
||||
@@ -37,29 +37,35 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED,
|
||||
onConstructor_ = @StableAPI.Internal)
|
||||
public class ConfigSyncEvent extends Event {
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final Class<?> configClass;
|
||||
|
||||
@StableAPI.Internal
|
||||
public static boolean postStart(Class<?> configClass) {
|
||||
val event = new Start(configClass);
|
||||
FMLCommonHandler.instance().bus().post(event);
|
||||
return !event.isCanceled();
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postEndSuccess(Class<?> configClass) {
|
||||
FMLCommonHandler.instance().bus().post(new End(configClass, true, null));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postEndFailure(Class<?> configClass, Throwable error) {
|
||||
FMLCommonHandler.instance().bus().post(new End(configClass, false, error));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static class Start extends ConfigSyncEvent {
|
||||
private Start(Class<?> configClass) {
|
||||
public static final class Start extends ConfigSyncEvent {
|
||||
|
||||
@StableAPI.Internal
|
||||
public Start(Class<?> configClass) {
|
||||
super(configClass);
|
||||
}
|
||||
|
||||
@@ -71,16 +77,15 @@ public class ConfigSyncEvent extends Event {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static class End extends ConfigSyncEvent {
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class End extends ConfigSyncEvent {
|
||||
@StableAPI.Expose
|
||||
public final boolean successful;
|
||||
/**
|
||||
* null if successful == true.
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
|
||||
@StableAPI.Expose
|
||||
public final Throwable error;
|
||||
|
||||
private End(Class<?> configClass, boolean successful, Throwable error) {
|
||||
@StableAPI.Internal
|
||||
public End(Class<?> configClass, boolean successful, Throwable error) {
|
||||
super(configClass);
|
||||
this.successful = successful;
|
||||
this.error = error;
|
||||
|
||||
@@ -38,28 +38,33 @@ import java.util.List;
|
||||
* {@link #postClient}
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED,
|
||||
onConstructor_ = @StableAPI.Internal)
|
||||
public class ConfigSyncRequestEvent extends Event {
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public static void postClient() {
|
||||
FMLCommonHandler.instance().bus().post(new Client());
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public static void postServer(List<EntityPlayerMP> players) {
|
||||
FMLCommonHandler.instance().bus().post(new Server(new ArrayList<>(players)));
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static class Client extends ConfigSyncRequestEvent {
|
||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED,
|
||||
onConstructor_ = @StableAPI.Internal)
|
||||
public static final class Client extends ConfigSyncRequestEvent {
|
||||
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static class Server extends ConfigSyncRequestEvent {
|
||||
@RequiredArgsConstructor(access = AccessLevel.PUBLIC,
|
||||
onConstructor_ = @StableAPI.Internal)
|
||||
public static final class Server extends ConfigSyncRequestEvent {
|
||||
private final List<EntityPlayerMP> players;
|
||||
|
||||
@StableAPI.Expose
|
||||
public List<EntityPlayerMP> getPlayers() {
|
||||
return Collections.unmodifiableList(players);
|
||||
}
|
||||
|
||||
@@ -40,19 +40,21 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED,
|
||||
onConstructor_ = @StableAPI.Internal)
|
||||
public abstract class ConfigValidationFailureEvent extends Event {
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final String reason;
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final Class<?> configClass;
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final String fieldName;
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final boolean listElement;
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final int listIndex;
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postNumericRangeOutOfBounds(Field field, int listIndex, String value, String min, String max) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
@@ -60,6 +62,7 @@ public abstract class ConfigValidationFailureEvent extends Event {
|
||||
min, max));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postSize(Field field, int requestedSize, boolean fixedSize, int maxSize, int defaultSize) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
@@ -67,6 +70,7 @@ public abstract class ConfigValidationFailureEvent extends Event {
|
||||
fixedSize, maxSize, defaultSize));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postStringSizeOutOfBounds(Field field, int listIndex, String text, int maxSize) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
@@ -74,10 +78,12 @@ public abstract class ConfigValidationFailureEvent extends Event {
|
||||
maxSize));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void fieldIsNull(Field field, int listIndex) {
|
||||
FMLCommonHandler.instance().bus().post(new FieldIsNull(field.getDeclaringClass(), field.getName(), listIndex));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postStringPatternMismatch(Field field, int listIndex, String text, String pattern) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
@@ -86,6 +92,7 @@ public abstract class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI.Internal
|
||||
public void toast() {
|
||||
val ann = configClass.getAnnotation(Config.class);
|
||||
val toast = new SimpleToast(ToastBG.TOAST_DARK, null,
|
||||
@@ -97,8 +104,10 @@ public abstract class ConfigValidationFailureEvent extends Event {
|
||||
GuiToast.add(toast);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
protected abstract void customText(StringBuilder b);
|
||||
|
||||
@StableAPI.Internal
|
||||
public void logWarn() {
|
||||
val errorString = new StringBuilder("Error validating configuration field!");
|
||||
errorString.append("\nReason: ").append(reason);
|
||||
@@ -111,14 +120,15 @@ public abstract class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static class NumericRangeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class NumericRangeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final String value;
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final String min;
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final String max;
|
||||
|
||||
@StableAPI.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;
|
||||
@@ -133,17 +143,18 @@ public abstract class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static class ListSizeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class ListSizeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final int size;
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final boolean fixedSize;
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final int maxSize;
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final int defaultSize;
|
||||
|
||||
private ListSizeOutOfBounds(Class<?> configClass, String fieldName, int size, boolean fixedSize, int maxSize, int defaultSize) {
|
||||
@StableAPI.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;
|
||||
this.fixedSize = fixedSize;
|
||||
@@ -162,13 +173,14 @@ public abstract class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static class StringSizeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class StringSizeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final String text;
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final int maxSize;
|
||||
|
||||
private StringSizeOutOfBounds(Class<?> configClass, String fieldName, int listIndex, String text, int maxSize) {
|
||||
@StableAPI.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;
|
||||
this.maxSize = maxSize;
|
||||
@@ -186,8 +198,9 @@ public abstract class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static class FieldIsNull extends ConfigValidationFailureEvent {
|
||||
private FieldIsNull(Class<?> configClass, String fieldName, int listIndex) {
|
||||
public static final class FieldIsNull extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Internal
|
||||
public FieldIsNull(Class<?> configClass, String fieldName, int listIndex) {
|
||||
super("Unexpected null", configClass, fieldName, listIndex >= 0, listIndex);
|
||||
}
|
||||
|
||||
@@ -198,13 +211,14 @@ public abstract class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static class StringPatternMismatch extends ConfigValidationFailureEvent {
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class StringPatternMismatch extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final String text;
|
||||
@StableAPI(since = "0.10.0")
|
||||
@StableAPI.Expose
|
||||
public final String pattern;
|
||||
|
||||
private StringPatternMismatch(Class<?> configClass, String fieldName, int listIndex, String text, String pattern) {
|
||||
@StableAPI.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;
|
||||
this.pattern = pattern;
|
||||
|
||||
Reference in new issue
Block a user