cleanup code

This commit is contained in:
FalsePattern committed 2023-07-16 13:21:51 +02:00
1 parent 6868e1f718
commit dfba569048
51 files changed
+637 -373

No files matched your search

@@ -80,8 +80,7 @@ public @interface Config {
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface Ignore {
}
@interface Ignore {}
/**
* The default value for a boolean field. Not having a default is deprecated since 0.10, and will be strongly
@@ -253,8 +252,7 @@ public @interface Config {
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface ListFixedLength {
}
@interface ListFixedLength {}
/**
* This annotation limits the maximum number of elements present in an array configuration. Only effective if
@@ -290,8 +288,7 @@ public @interface Config {
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
@interface RequiresMcRestart {
}
@interface RequiresMcRestart {}
/**
* Whether the specific configuration needs a world/server rejoin to be applied.
@@ -300,8 +297,7 @@ public @interface Config {
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.TYPE})
@interface RequiresWorldRestart {
}
@interface RequiresWorldRestart {}
/**
* Signals that this configuration class should be synchronized between the client and the server when
@@ -314,8 +310,7 @@ public @interface Config {
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface Synchronize {
}
@interface Synchronize {}
/**
* Use this to mark config fields you don't want to synchronize in a class marked with {@link Synchronize}.
@@ -324,6 +319,5 @@ public @interface Config {
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@interface NoSync {
}
@interface NoSync {}
}
@@ -40,7 +40,12 @@ public class SimpleGuiConfig extends GuiConfig {
@StableAPI.Expose(since = "0.10.0")
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"));
super(parent,
ConfigurationManager.getConfigElementsMulti(configClasses),
modID,
false,
false,
modName + " Configuration",
I18n.format("falsepatternlib.gui.config.description"));
}
}
@@ -63,23 +63,34 @@ public class ConfigValidationFailureEvent extends Event {
public static void postNumericRangeOutOfBounds(Field field, int listIndex, String value, String min, String max) {
FMLCommonHandler.instance()
.bus()
.post(new NumericRangeOutOfBounds(field.getDeclaringClass(), field.getName(), listIndex, value,
min, max));
.post(new NumericRangeOutOfBounds(field.getDeclaringClass(),
field.getName(),
listIndex,
value,
min,
max));
}
@StableAPI.Internal
public static void postSize(Field field, int requestedSize, boolean fixedSize, int maxSize, int defaultSize) {
FMLCommonHandler.instance()
.bus()
.post(new ListSizeOutOfBounds(field.getDeclaringClass(), field.getName(), requestedSize,
fixedSize, maxSize, defaultSize));
.post(new ListSizeOutOfBounds(field.getDeclaringClass(),
field.getName(),
requestedSize,
fixedSize,
maxSize,
defaultSize));
}
@StableAPI.Internal
public static void postStringSizeOutOfBounds(Field field, int listIndex, String text, int maxSize) {
FMLCommonHandler.instance()
.bus()
.post(new StringSizeOutOfBounds(field.getDeclaringClass(), field.getName(), listIndex, text,
.post(new StringSizeOutOfBounds(field.getDeclaringClass(),
field.getName(),
listIndex,
text,
maxSize));
}
@@ -92,7 +103,10 @@ public class ConfigValidationFailureEvent extends Event {
public static void postStringPatternMismatch(Field field, int listIndex, String text, String pattern) {
FMLCommonHandler.instance()
.bus()
.post(new StringPatternMismatch(field.getDeclaringClass(), field.getName(), listIndex, text,
.post(new StringPatternMismatch(field.getDeclaringClass(),
field.getName(),
listIndex,
text,
pattern));
}
@@ -100,11 +114,13 @@ public class ConfigValidationFailureEvent extends Event {
@StableAPI.Internal
public void toast() {
val ann = configClass.getAnnotation(Config.class);
val toast = new SimpleToast(ToastBG.TOAST_DARK, null,
val toast = new SimpleToast(ToastBG.TOAST_DARK,
null,
FormattedText.parse(EnumChatFormatting.RED + "Config validation failed")
.toChatText()
.get(0),
FormattedText.parse(ann.modid() + ":" + ann.category()).toChatText().get(0), false,
FormattedText.parse(ann.modid() + ":" + ann.category()).toChatText().get(0),
false,
2000);
GuiToast.add(toast);
}
@@ -122,7 +138,7 @@ public class ConfigValidationFailureEvent extends Event {
errorString.append("\nArray index: ").append(listIndex);
}
customText(errorString);
for (val line: errorString.toString().split("\n")) {
for (val line : errorString.toString().split("\n")) {
Share.LOG.error(line);
}
}