From 04fe933f4c24817100f3101f088accf55a621f8a Mon Sep 17 00:00:00 2001 From: isxander Date: Thu, 11 Apr 2024 18:43:06 +0100 Subject: Extremely fragile and broken multiversion build with stonecutter --- .../yacl3/config/v2/api/ConfigClassHandler.java | 107 -------- .../isxander/yacl3/config/v2/api/ConfigField.java | 40 --- .../yacl3/config/v2/api/ConfigSerializer.java | 64 ----- .../isxander/yacl3/config/v2/api/FieldAccess.java | 14 -- .../yacl3/config/v2/api/ReadOnlyFieldAccess.java | 36 --- .../isxander/yacl3/config/v2/api/SerialEntry.java | 39 --- .../isxander/yacl3/config/v2/api/SerialField.java | 16 -- .../yacl3/config/v2/api/autogen/AutoGen.java | 32 --- .../yacl3/config/v2/api/autogen/AutoGenField.java | 12 - .../yacl3/config/v2/api/autogen/Boolean.java | 41 --- .../yacl3/config/v2/api/autogen/ColorField.java | 21 -- .../config/v2/api/autogen/CustomDescription.java | 12 - .../yacl3/config/v2/api/autogen/CustomFormat.java | 17 -- .../yacl3/config/v2/api/autogen/CustomImage.java | 69 ------ .../yacl3/config/v2/api/autogen/CustomName.java | 18 -- .../yacl3/config/v2/api/autogen/DoubleField.java | 46 ---- .../yacl3/config/v2/api/autogen/DoubleSlider.java | 48 ---- .../yacl3/config/v2/api/autogen/Dropdown.java | 43 ---- .../yacl3/config/v2/api/autogen/EnumCycler.java | 35 --- .../yacl3/config/v2/api/autogen/FloatField.java | 46 ---- .../yacl3/config/v2/api/autogen/FloatSlider.java | 48 ---- .../config/v2/api/autogen/FormatTranslation.java | 25 -- .../yacl3/config/v2/api/autogen/IntField.java | 41 --- .../yacl3/config/v2/api/autogen/IntSlider.java | 35 --- .../yacl3/config/v2/api/autogen/ItemField.java | 17 -- .../yacl3/config/v2/api/autogen/Label.java | 18 -- .../yacl3/config/v2/api/autogen/ListGroup.java | 60 ----- .../yacl3/config/v2/api/autogen/LongField.java | 41 --- .../yacl3/config/v2/api/autogen/LongSlider.java | 35 --- .../yacl3/config/v2/api/autogen/MasterTickBox.java | 26 -- .../yacl3/config/v2/api/autogen/OptionAccess.java | 35 --- .../yacl3/config/v2/api/autogen/OptionFactory.java | 40 --- .../config/v2/api/autogen/SimpleOptionFactory.java | 138 ----------- .../yacl3/config/v2/api/autogen/StringField.java | 17 -- .../yacl3/config/v2/api/autogen/TickBox.java | 17 -- .../serializer/GsonConfigSerializerBuilder.java | 98 -------- .../config/v2/impl/ConfigClassHandlerImpl.java | 274 --------------------- .../yacl3/config/v2/impl/ConfigFieldImpl.java | 75 ------ .../yacl3/config/v2/impl/FieldBackedBinding.java | 22 -- .../config/v2/impl/ReflectionFieldAccess.java | 49 ---- .../yacl3/config/v2/impl/autogen/AutoGenUtils.java | 54 ---- .../yacl3/config/v2/impl/autogen/BooleanImpl.java | 25 -- .../config/v2/impl/autogen/ColorFieldImpl.java | 19 -- .../config/v2/impl/autogen/DoubleFieldImpl.java | 32 --- .../config/v2/impl/autogen/DoubleSliderImpl.java | 33 --- .../yacl3/config/v2/impl/autogen/DropdownImpl.java | 19 -- .../v2/impl/autogen/EmptyCustomImageFactory.java | 17 -- .../config/v2/impl/autogen/EnumCyclerImpl.java | 42 ---- .../config/v2/impl/autogen/FloatFieldImpl.java | 32 --- .../config/v2/impl/autogen/FloatSliderImpl.java | 33 --- .../yacl3/config/v2/impl/autogen/IntFieldImpl.java | 28 --- .../config/v2/impl/autogen/IntSliderImpl.java | 29 --- .../config/v2/impl/autogen/ItemFieldImpl.java | 17 -- .../yacl3/config/v2/impl/autogen/LabelImpl.java | 16 -- .../config/v2/impl/autogen/ListGroupImpl.java | 102 -------- .../config/v2/impl/autogen/LongFieldImpl.java | 28 --- .../config/v2/impl/autogen/LongSliderImpl.java | 29 --- .../config/v2/impl/autogen/MasterTickBoxImpl.java | 25 -- .../config/v2/impl/autogen/OptionAccessImpl.java | 44 ---- .../v2/impl/autogen/OptionFactoryRegistry.java | 64 ----- .../config/v2/impl/autogen/StringFieldImpl.java | 16 -- .../yacl3/config/v2/impl/autogen/TickBoxImpl.java | 16 -- .../v2/impl/autogen/YACLAutoGenException.java | 11 - .../v2/impl/serializer/GsonConfigSerializer.java | 269 -------------------- 64 files changed, 2867 deletions(-) delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigClassHandler.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigField.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigSerializer.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/FieldAccess.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/ReadOnlyFieldAccess.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/SerialEntry.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/SerialField.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/AutoGen.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/AutoGenField.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Boolean.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ColorField.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomDescription.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomFormat.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomImage.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomName.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/DoubleField.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/DoubleSlider.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Dropdown.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/EnumCycler.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FloatField.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FloatSlider.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FormatTranslation.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/IntField.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/IntSlider.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ItemField.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Label.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ListGroup.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/LongField.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/LongSlider.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/MasterTickBox.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/OptionAccess.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/OptionFactory.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/StringField.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/TickBox.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/api/serializer/GsonConfigSerializerBuilder.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/ConfigClassHandlerImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/ConfigFieldImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/FieldBackedBinding.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/ReflectionFieldAccess.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/AutoGenUtils.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/BooleanImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ColorFieldImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/DoubleFieldImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/DoubleSliderImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/DropdownImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/EmptyCustomImageFactory.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/EnumCyclerImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/FloatFieldImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/FloatSliderImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/IntFieldImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/IntSliderImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ItemFieldImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/LabelImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/ListGroupImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/LongFieldImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/LongSliderImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/MasterTickBoxImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/OptionAccessImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/OptionFactoryRegistry.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/StringFieldImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/TickBoxImpl.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/autogen/YACLAutoGenException.java delete mode 100644 common/src/main/java/dev/isxander/yacl3/config/v2/impl/serializer/GsonConfigSerializer.java (limited to 'common/src/main/java/dev/isxander/yacl3/config/v2') diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigClassHandler.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigClassHandler.java deleted file mode 100644 index d94280f..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigClassHandler.java +++ /dev/null @@ -1,107 +0,0 @@ -package dev.isxander.yacl3.config.v2.api; - -import dev.isxander.yacl3.api.YetAnotherConfigLib; -import dev.isxander.yacl3.config.v2.impl.ConfigClassHandlerImpl; -import net.minecraft.resources.ResourceLocation; - -import java.util.function.Function; - -/** - * Represents a handled config class. - * - * @param the backing config class to be managed - */ -public interface ConfigClassHandler { - /** - * Gets the working instance of the config class. - * This should be used to get and set fields like usual. - */ - T instance(); - - /** - * Gets a second instance of the config class that - * should be used to get default values only. No fields - * should be modified in this instance. - */ - T defaults(); - - /** - * Gets the class of the config. - */ - Class configClass(); - - /** - * Get all eligible fields in the config class. - * They could either be annotated with {@link dev.isxander.yacl3.config.v2.api.autogen.AutoGen} - * or {@link SerialEntry}, do not assume that a field has both of these. - */ - ConfigField[] fields(); - - /** - * The unique identifier of this config handler. - */ - ResourceLocation id(); - - /** - * Auto-generates a GUI for this config class. - * This throws an exception if auto-gen is not supported. - */ - YetAnotherConfigLib generateGui(); - - /** - * Whether this config class supports auto-gen. - * If on a dedicated server, this returns false. - */ - boolean supportsAutoGen(); - - /** - * Safely loads the config class using the provided serializer. - * @return if the config was loaded successfully - */ - boolean load(); - - /** - * Safely saves the config class using the provided serializer. - */ - void save(); - - /** - * The serializer for this config class. - * Manages saving and loading of the config with fields - * annotated with {@link SerialEntry}. - * - * @deprecated use {@link #load()} and {@link #save()} instead. - */ - @Deprecated - ConfigSerializer serializer(); - - /** - * Creates a builder for a config class. - * - * @param configClass the config class to build - * @param the type of the config class - * @return the builder - */ - static Builder createBuilder(Class configClass) { - return new ConfigClassHandlerImpl.BuilderImpl<>(configClass); - } - - interface Builder { - /** - * The unique identifier of this config handler. - * The namespace should be your modid. - * - * @return this builder - */ - Builder id(ResourceLocation id); - - /** - * The function to create the serializer for this config class. - * - * @return this builder - */ - Builder serializer(Function, ConfigSerializer> serializerFactory); - - ConfigClassHandler build(); - } -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigField.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigField.java deleted file mode 100644 index 181a4d4..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigField.java +++ /dev/null @@ -1,40 +0,0 @@ -package dev.isxander.yacl3.config.v2.api; - -import dev.isxander.yacl3.config.v2.api.autogen.AutoGenField; - -import java.util.Optional; - -/** - * Represents a field in a config class. - * This is used to get all metadata on a field, - * and access the field and its default value. - * - * @param the field's type - */ -public interface ConfigField { - /** - * Gets the accessor for the field on the main instance. - * (Accessed through {@link ConfigClassHandler#instance()}) - */ - FieldAccess access(); - - /** - * Gets the accessor for the field on the default instance. - */ - ReadOnlyFieldAccess defaultAccess(); - - /** - * @return the parent config class handler that manages this field. - */ - ConfigClassHandler parent(); - - /** - * The serial entry metadata for this field, if it exists. - */ - Optional serial(); - - /** - * The auto-gen metadata for this field, if it exists. - */ - Optional autoGen(); -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigSerializer.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigSerializer.java deleted file mode 100644 index 4ac988c..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/ConfigSerializer.java +++ /dev/null @@ -1,64 +0,0 @@ -package dev.isxander.yacl3.config.v2.api; - -import java.util.Map; - -/** - * The base class for config serializers, - * offering a method to save and load. - * @param the config class to be (de)serialized - */ -public abstract class ConfigSerializer { - protected final ConfigClassHandler config; - - public ConfigSerializer(ConfigClassHandler config) { - this.config = config; - } - - /** - * Saves all fields in the config class. - * This can be done any way as it's abstract, but most - * commonly it is saved to a file. - */ - public abstract void save(); - - /** - * Loads all fields into the config class. - * @param bufferAccessMap a map of the field accesses. instead of directly setting the field with - * {@link ConfigField#access()}, use this parameter. This loads into a temporary object, - * and the class handler handles pushing these changes to the instance. - * @return the result of the load - */ - public LoadResult loadSafely(Map, FieldAccess> bufferAccessMap) { - this.load(); - return LoadResult.NO_CHANGE; - } - - /** - * Loads all fields in the config class. - * - * @deprecated use {@link #loadSafely(Map)} instead. - */ - @Deprecated - public void load() { - throw new IllegalArgumentException("load() is deprecated, use loadSafely() instead."); - } - - public enum LoadResult { - /** - * Indicates that the config was loaded successfully and the temporary object should be applied. - */ - SUCCESS, - /** - * Indicates that the config was not loaded successfully and the load should be abandoned. - */ - FAILURE, - /** - * Indicates that the config has not changed after a load and the temporary object should be ignored. - */ - NO_CHANGE, - /** - * Indicates the config was loaded successfully, but the config should be re-saved straight away. - */ - DIRTY - } -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/FieldAccess.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/FieldAccess.java deleted file mode 100644 index ea30cd8..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/FieldAccess.java +++ /dev/null @@ -1,14 +0,0 @@ -package dev.isxander.yacl3.config.v2.api; - -/** - * A writable field instance access. - * - * @param the type of the field - */ -public interface FieldAccess extends ReadOnlyFieldAccess { - /** - * Sets the value of the field. - * @param value the value to set - */ - void set(T value); -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/ReadOnlyFieldAccess.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/ReadOnlyFieldAccess.java deleted file mode 100644 index 566d60d..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/ReadOnlyFieldAccess.java +++ /dev/null @@ -1,36 +0,0 @@ -package dev.isxander.yacl3.config.v2.api; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import java.util.Optional; - -/** - * An abstract interface for accessing properties of an instance of a field. - * You do not need to worry about exceptions as the implementation - * will handle them. - * - * @param the type of the field - */ -public interface ReadOnlyFieldAccess { - /** - * @return the current value of the field. - */ - T get(); - - /** - * @return the name of the field. - */ - String name(); - - /** - * @return the type of the field. - */ - Type type(); - - /** - * @return the class of the field. - */ - Class typeClass(); - - Optional getAnnotation(Class annotationClass); -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/SerialEntry.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/SerialEntry.java deleted file mode 100644 index 94bf785..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/SerialEntry.java +++ /dev/null @@ -1,39 +0,0 @@ -package dev.isxander.yacl3.config.v2.api; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Marks a field as serializable, so it can be used in a {@link ConfigSerializer}. - * Any field without this annotation will not be saved or loaded, but can still be turned - * into an auto-generated option. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface SerialEntry { - /** - * The serial name of the field. - * If empty, the serializer will decide the name. - */ - String value() default ""; - - /** - * The comment to add to the field. - * Some serializers may not support this. - * If empty, the serializer will not add a comment. - */ - String comment() default ""; - - /** - * Whether the field is required in the loaded config to be valid. - * If it's not, the config will be marked as dirty and re-saved with the default value. - */ - boolean required() default true; - - /** - * Whether the field can be null. - */ - boolean nullable() default false; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/SerialField.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/SerialField.java deleted file mode 100644 index cf6abfc..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/SerialField.java +++ /dev/null @@ -1,16 +0,0 @@ -package dev.isxander.yacl3.config.v2.api; - -import java.util.Optional; - -/** - * The backing interface for the {@link SerialEntry} annotation. - */ -public interface SerialField { - String serialName(); - - Optional comment(); - - boolean required(); - - boolean nullable(); -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/AutoGen.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/AutoGen.java deleted file mode 100644 index 4187caf..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/AutoGen.java +++ /dev/null @@ -1,32 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Any field that is annotated with this will generate a config option - * in the auto-generated config GUI. This should be paired with an - * {@link OptionFactory} annotation to define how to create the option. - * Some examples of this are {@link TickBox}, {@link FloatSlider}, {@link Label} or {@link StringField}. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface AutoGen { - /** - * Should be the id of the category. This is used to group options. - * The translation keys also use this. Category IDs can be set as a - * {@code private static final String} and used in the annotation to prevent - * repeating yourself. - */ - String category(); - - /** - * If left blank, the option will go in the root group, where it is - * listed at the top of the category with no group header. If set, - * this also appends to the translation key. Group IDs can be reused - * between multiple categories. - */ - String group() default ""; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/AutoGenField.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/AutoGenField.java deleted file mode 100644 index 7f751fb..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/AutoGenField.java +++ /dev/null @@ -1,12 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.util.Optional; - -/** - * Backing interface for the {@link AutoGen} annotation. - */ -public interface AutoGenField { - String category(); - - Optional group(); -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Boolean.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Boolean.java deleted file mode 100644 index 5598389..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Boolean.java +++ /dev/null @@ -1,41 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * An option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.BooleanControllerBuilder} controller. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Boolean { - enum Formatter { - YES_NO, - TRUE_FALSE, - ON_OFF, - /** - * Uses the translation keys: - *

    - *
  • true: {@code yacl3.config.$configId.$fieldName.fmt.true}
  • - *
  • false: {@code yacl3.config.$configId.$fieldName.fmt.false}
  • - *
- */ - CUSTOM, - } - - /** - * The format used to display the boolean. - */ - Formatter formatter() default Formatter.TRUE_FALSE; - - /** - * Whether to color the formatted text green and red - * depending on the value: true or false respectively. - */ - boolean colored() default false; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ColorField.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ColorField.java deleted file mode 100644 index 74937b4..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ColorField.java +++ /dev/null @@ -1,21 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * An option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.ColorControllerBuilder} controller. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ColorField { - /** - * Whether to show/allow the alpha channel in the color field. - */ - boolean allowAlpha() default false; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomDescription.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomDescription.java deleted file mode 100644 index 08624b4..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomDescription.java +++ /dev/null @@ -1,12 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface CustomDescription { - String[] value() default ""; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomFormat.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomFormat.java deleted file mode 100644 index 15f6336..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomFormat.java +++ /dev/null @@ -1,17 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import dev.isxander.yacl3.api.controller.ValueFormatter; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Allows you to specify a custom {@link ValueFormatter} for a field. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface CustomFormat { - Class> value(); -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomImage.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomImage.java deleted file mode 100644 index d193f42..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomImage.java +++ /dev/null @@ -1,69 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import dev.isxander.yacl3.config.v2.api.ConfigField; -import dev.isxander.yacl3.config.v2.impl.autogen.EmptyCustomImageFactory; -import dev.isxander.yacl3.gui.image.ImageRenderer; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.util.Optional; -import java.util.concurrent.CompletableFuture; - -/** - * Defines a custom image for an option. - * Without this annotation, the option factory will look - * for the resource {@code modid:textures/yacl3/$config_id_path/$fieldName.webp}. - * WEBP was chosen as the default format because file sizes are greatly reduced, - * which is important to keep your JAR size down, if you're so bothered. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface CustomImage { - /** - * The resource path to the image, a {@link net.minecraft.resources.ResourceLocation} - * is constructed with the namespace being the modid of the config, and the path being - * this value. - *

- * The following file formats are supported: - *

    - *
  • {@code .png}
  • - *
  • {@code .webp}
  • - *
  • {@code .jpg}, {@code .jpeg}
  • - *
  • {@code .gif} - HIGHLY DISCOURAGED DUE TO LARGE FILE SIZE
  • - *
- *

- * If left blank, then {@link CustomImage#factory()} is used. - */ - String value() default ""; - - /** - * The width of the image, in pixels. - * This is only required when using a PNG with {@link CustomImage#value()} - */ - int width() default 0; - - /** - * The width of the image, in pixels. - * This is only required when using a PNG with {@link CustomImage#value()} - */ - int height() default 0; - - /** - * The factory to create the image with. - * For the average user, this should not be used as it breaks out of the - * API-safe environment where things could change at any time, but required - * when creating anything advanced with the {@link ImageRenderer}. - *

- * The factory should contain a public, no-args constructor that will be - * invoked via reflection. - * - * @return the class of the factory - */ - Class> factory() default EmptyCustomImageFactory.class; - - interface CustomImageFactory { - CompletableFuture createImage(T value, ConfigField field, OptionAccess access); - } -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomName.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomName.java deleted file mode 100644 index aa235bb..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/CustomName.java +++ /dev/null @@ -1,18 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Overrides the name of an auto-generated option. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface CustomName { - /** - * The translation key to use for the option's name. - */ - String value() default ""; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/DoubleField.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/DoubleField.java deleted file mode 100644 index 963cefd..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/DoubleField.java +++ /dev/null @@ -1,46 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A regular option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.DoubleFieldControllerBuilder} controller. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface DoubleField { - /** - * The minimum value of the field. If a user enters a value less - * than this, it will be clamped to this value. - *

- * If this is set to {@code -Double.MAX_VALUE}, there will be no minimum. - *

- * If the current value is at this minimum, if available, - * the translation key {@code yacl3.config.$configId.$fieldName.fmt.min} - * will be used. - */ - double min() default -Double.MAX_VALUE; - - /** - * The maximum value of the field. If a user enters a value more - * than this, it will be clamped to this value. - *

- * If this is set to {@code Double.MAX_VALUE}, there will be no minimum. - *

- * If the current value is at this maximum, if available, - * the translation key {@code yacl3.config.$configId.$fieldName.fmt.max} - * will be used. - */ - double max() default Double.MAX_VALUE; - - /** - * The format used to display the double. - * This is the syntax used in {@link String#format(String, Object...)}. - */ - String format() default "%.2f"; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/DoubleSlider.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/DoubleSlider.java deleted file mode 100644 index 268f6a4..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/DoubleSlider.java +++ /dev/null @@ -1,48 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A regular option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.DoubleSliderControllerBuilder} controller. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface DoubleSlider { - /** - * The minimum value of the slider. - *

- * If the current value is at this minimum, if available, - * the translation key {@code yacl3.config.$configId.$fieldName.fmt.min} - * will be used. - */ - double min(); - - /** - * The maximum value of the slider. - *

- * If the current value is at this maximum, if available, - * the translation key {@code yacl3.config.$configId.$fieldName.fmt.max} - * will be used. - */ - double max(); - - /** - * The step size of this slider. - * For example, if this is set to 0.1, the slider will - * increment/decrement by 0.1 when dragging, no less, no more and - * will always be a multiple of 0.1. - */ - double step(); - - /** - * The format used to display the double. - * This is the syntax used in {@link String#format(String, Object...)}. - */ - String format() default "%.2f"; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Dropdown.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Dropdown.java deleted file mode 100644 index 44239d5..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Dropdown.java +++ /dev/null @@ -1,43 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * An option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.DropdownStringControllerBuilder} controller. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Dropdown { - /** - * The allowed values for the field. These will be shown in a dropdown - * that the user can filter and select from. - *

- * Only values in this list will be accepted and written to the config - * file, unless {@link #allow()} is set to ${@code ALLOW_ANY}. - *

- * Empty string is a valid value only if it appears in this list, or if - * {@link #allow()} is set to {@code ALLOW_EMPTY} or {@code ALLOW_ANY}. - */ - String[] values(); - - /** - * Whether to accept the empty string as a valid value if it does not - * already appear in {@link #values()}. If it already appears there, - * the value of this does not apply. - */ - boolean allowEmptyValue() default false; - - /** - * Whether to accept any string as a valid value. The list of strings - * supplied in {@link #values()} are only used as dropdown suggestions. - * Empty strings are still prohibited unless the empty string appears in - * {@link #values()} or {@link #allowEmptyValue()}. - */ - boolean allowAnyValue() default false; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/EnumCycler.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/EnumCycler.java deleted file mode 100644 index 98d94f9..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/EnumCycler.java +++ /dev/null @@ -1,35 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import dev.isxander.yacl3.api.NameableEnum; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * An option factory. - *

- * This creates a regular option with a {@link dev.isxander.yacl3.api.controller.CyclingListControllerBuilder} - * controller. If the enum implements {@link CyclableEnum}, the allowed values will be used from that, - * rather than every single enum constant in the class. If not, {@link EnumCycler#allowedOrdinals()} is used. - *

- * There are two methods of formatting for enum values. First, if the enum implements - * {@link dev.isxander.yacl3.api.NameableEnum}, {@link NameableEnum#getDisplayName()} is used. - * Otherwise, the translation key {@code yacl3.config.enum.$enumClassName.$enumName} where - * {@code $enumClassName} is the exact name of the class and {@code $enumName} is equal to the lower - * case of {@link Enum#name()}. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface EnumCycler { - /** - * The allowed ordinals of the enum class. If empty, all ordinals are allowed. - * This is only used if the enum does not implement {@link CyclableEnum}. - */ - int[] allowedOrdinals() default {}; - - interface CyclableEnum> { - T[] allowedValues(); - } -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FloatField.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FloatField.java deleted file mode 100644 index 1e7e71e..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FloatField.java +++ /dev/null @@ -1,46 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A regular option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.FloatFieldControllerBuilder} controller. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface FloatField { - /** - * The minimum value of the field. If a user enters a value less - * than this, it will be clamped to this value. - *

- * If this is set to {@code -Float.MAX_VALUE}, there will be no minimum. - *

- * If the current value is at this minimum, if available, - * the translation key {@code yacl3.config.$configId.$fieldName.fmt.min} - * will be used. - */ - float min() default -Float.MAX_VALUE; - - /** - * The maximum value of the field. If a user enters a value more - * than this, it will be clamped to this value. - *

- * If this is set to {@code Float.MAX_VALUE}, there will be no minimum. - *

- * If the current value is at this maximum, if available, - * the translation key {@code yacl3.config.$configId.$fieldName.fmt.max} - * will be used. - */ - float max() default Float.MAX_VALUE; - - /** - * The format used to display the float. - * This is the syntax used in {@link String#format(String, Object...)}. - */ - String format() default "%.1f"; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FloatSlider.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FloatSlider.java deleted file mode 100644 index 19ae9db..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FloatSlider.java +++ /dev/null @@ -1,48 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A regular option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder} controller. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface FloatSlider { - /** - * The minimum value of the slider. - *

- * If the current value is at this minimum, if available, - * the translation key {@code yacl3.config.$configId.$fieldName.fmt.min} - * will be used. - */ - float min(); - - /** - * The maximum value of the slider. - *

- * If the current value is at this maximum, if available, - * the translation key {@code yacl3.config.$configId.$fieldName.fmt.max} - * will be used. - */ - float max(); - - /** - * The step size of this slider. - * For example, if this is set to 0.1, the slider will - * increment/decrement by 0.1 when dragging, no less, no more and - * will always be a multiple of 0.1. - */ - float step(); - - /** - * The format used to display the float. - * This is the syntax used in {@link String#format(String, Object...)}. - */ - String format() default "%.1f"; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FormatTranslation.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FormatTranslation.java deleted file mode 100644 index 7cc4ded..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/FormatTranslation.java +++ /dev/null @@ -1,25 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Allows you to specify a custom value formatter - * in the form of a translation key. - *

- * Without this annotation, the value will be formatted - * according to the option factory, implementation details - * for that should be found in the javadoc for the factory. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface FormatTranslation { - /** - * The translation key for the value formatter. - * One parameter is passed to this key: the option's value, - * using {@link Object#toString()}. - */ - String value() default ""; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/IntField.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/IntField.java deleted file mode 100644 index 9945d01..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/IntField.java +++ /dev/null @@ -1,41 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A regular option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder} controller. - *

- * If available, the translation key {@code yacl3.config.$configId.$fieldName.fmt.$value} - * is used where {@code $value} is the current value of the option, for example, {@code 5}. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface IntField { - /** - * The minimum value of the field. If a user enters a value less - * than this, it will be clamped to this value. - *

- * If this is set to {@code Integer.MIN_VALUE}, there will be no minimum. - */ - int min() default Integer.MIN_VALUE; - - /** - * The minimum value of the field. If a user enters a value more - * than this, it will be clamped to this value. - *

- * If this is set to {@code Integer.MAX_VALUE}, there will be no minimum. - */ - int max() default Integer.MAX_VALUE; - - /** - * The format used to display the integer. - * This is the syntax used in {@link String#format(String, Object...)}. - */ - String format() default "%.0f"; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/IntSlider.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/IntSlider.java deleted file mode 100644 index 7fd2282..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/IntSlider.java +++ /dev/null @@ -1,35 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A regular option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder} controller. - *

- * If available, the translation key {@code yacl3.config.$configId.$fieldName.fmt.$value} - * is used where {@code $value} is the current value of the option, for example, {@code 5}. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface IntSlider { - /** - * The minimum value of the slider. - */ - int min(); - - /** - * The maximum value of the slider. - */ - int max(); - - /** - * The format used to display the integer. - * This is the syntax used in {@link String#format(String, Object...)}. - */ - int step(); -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ItemField.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ItemField.java deleted file mode 100644 index 84d2c7a..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ItemField.java +++ /dev/null @@ -1,17 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * An option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.ItemControllerBuilder} controller. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ItemField { -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Label.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Label.java deleted file mode 100644 index 41e026f..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/Label.java +++ /dev/null @@ -1,18 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * An option factory that creates an instance - * of a {@link dev.isxander.yacl3.api.LabelOption}. - *

- * The backing field can be private and final and - * must be of type {@link net.minecraft.network.chat.Component}. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Label { -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ListGroup.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ListGroup.java deleted file mode 100644 index c664f71..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/ListGroup.java +++ /dev/null @@ -1,60 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import dev.isxander.yacl3.api.Option; -import dev.isxander.yacl3.api.controller.ControllerBuilder; -import dev.isxander.yacl3.config.v2.api.ConfigField; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.util.List; - -/** - * An option factory. - *

- * This creates a List option with a custom controller. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ListGroup { - /** - * The {@link Class} representing a class that implements {@link ValueFactory}. - * To create a new instance for the list when the user adds a new entry to the list. - * Remember this class can be shared with {@link ControllerFactory} as well. - */ - Class> valueFactory(); - - /** - * The {@link Class} representing a class that implements {@link ControllerBuilder} - * to add a controller to every entry in the list. - * Remember this class can be shared with {@link ValueFactory} as well. - */ - Class> controllerFactory(); - - /** - * The maximum number of entries that can be added to the list. - * Once at this limit, the add button is disabled. - * If this is equal to {@code 0}, there is no limit. - */ - int maxEntries() default 0; - - /** - * The minimum number of entries that must be in the list. - * When at this limit, the remove button of the entries is disabled. - */ - int minEntries() default 0; - - /** - * Whether to add new entries at the bottom of the list rather than the top. - */ - boolean addEntriesToBottom() default false; - - interface ValueFactory { - T provideNewValue(); - } - - interface ControllerFactory { - ControllerBuilder createController(ListGroup annotation, ConfigField> field, OptionAccess storage, Option option); - } -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/LongField.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/LongField.java deleted file mode 100644 index 01c3a7e..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/LongField.java +++ /dev/null @@ -1,41 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A regular option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.LongFieldControllerBuilder} controller. - *

- * If available, the translation key {@code yacl3.config.$configId.$fieldName.fmt.$value} - * is used where {@code $value} is the current value of the option, for example, {@code 5}. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface LongField { - /** - * The minimum value of the field. If a user enters a value less - * than this, it will be clamped to this value. - *

- * If this is set to {@code Long.MIN_VALUE}, there will be no minimum. - */ - long min() default Long.MIN_VALUE; - - /** - * The maximum value of the field. If a user enters a value more - * than this, it will be clamped to this value. - *

- * If this is set to {@code Long.MAX_VALUE}, there will be no minimum. - */ - long max() default Long.MAX_VALUE; - - /** - * The format used to display the long. - * This is the syntax used in {@link String#format(String, Object...)}. - */ - String format() default "%.0f"; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/LongSlider.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/LongSlider.java deleted file mode 100644 index 5563bd0..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/LongSlider.java +++ /dev/null @@ -1,35 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A regular option factory. - *

- * This creates a regular option with a - * {@link dev.isxander.yacl3.api.controller.LongSliderControllerBuilder} controller. - *

- * If available, the translation key {@code yacl3.config.$configId.$fieldName.fmt.$value} - * is used where {@code $value} is the current value of the option, for example, {@code 5}. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface LongSlider { - /** - * The minimum value of the slider. - */ - long min(); - - /** - * The maximum value of the slider. - */ - long max(); - - /** - * The format used to display the integer. - * This is the syntax used in {@link String#format(String, Object...)}. - */ - long step(); -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/MasterTickBox.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/MasterTickBox.java deleted file mode 100644 index 70dee1a..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/MasterTickBox.java +++ /dev/null @@ -1,26 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * An option factory like {@link TickBox} but controls - * other options' availability based on its state. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface MasterTickBox { - /** - * The exact names of the fields with {@link AutoGen} annotation - * to control the availability of. - */ - String[] value(); - - /** - * Whether having the tickbox disabled should enable the options - * rather than disable. - */ - boolean invert() default false; -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/OptionAccess.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/OptionAccess.java deleted file mode 100644 index c55afe4..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/OptionAccess.java +++ /dev/null @@ -1,35 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import dev.isxander.yacl3.api.Option; -import org.jetbrains.annotations.Nullable; - -import java.util.function.Consumer; - -/** - * An accessor to all options that are auto-generated - * by the config system. - */ -public interface OptionAccess { - /** - * Gets an option by its field name. - * This could be null if the option hasn't been created yet. It is created - * in order of the fields in the class, so if you are trying to get an option - * lower-down in the class, this will return null. - * - * @param fieldName the exact, case-sensitive name of the field. - * @return the created option, or {@code null} if it hasn't been created yet. - */ - @Nullable Option getOption(String fieldName); - - /** - * Schedules an operation to be performed on an option. - * If the option has already been created, the consumer will be - * accepted immediately upon calling this method, if not, it will - * be added to the queue of operations to be performed on the option - * once it does get created. - * - * @param fieldName the exact, case-sensitive name of the field. - * @param optionConsumer the operation to perform on the option. - */ - void scheduleOptionOperation(String fieldName, Consumer> optionConsumer); -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/OptionFactory.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/OptionFactory.java deleted file mode 100644 index 515a40b..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/OptionFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import dev.isxander.yacl3.api.Option; -import dev.isxander.yacl3.config.v2.api.ConfigField; -import dev.isxander.yacl3.config.v2.impl.autogen.OptionFactoryRegistry; - -import java.lang.annotation.Annotation; - -/** - * The backing builder for option factories' annotations. - *

- * If you want to make a basic option with a controller, it's recommended - * to use {@link SimpleOptionFactory} instead which is a subclass of this. - * - * @param the annotation type - * @param the option's binding type - */ -public interface OptionFactory { - /** - * Creates an option from the given annotation, backing field, and storage. - * - * @param annotation the annotation that fields are annotated with to use this factory - * @param field the backing field - * @param optionAccess the option access to access other options in the GUI - * @return the built option to be added to the group/category - */ - Option createOption(A annotation, ConfigField field, OptionAccess optionAccess); - - /** - * Registers an option factory to be used by configs. - * - * @param annotationClass the class of the annotation to use a factory - * @param factory an instance of the factory - * @param the type of the annotation - * @param the type of the option's binding - */ - static void register(Class annotationClass, OptionFactory factory) { - OptionFactoryRegistry.registerOptionFactory(annotationClass, factory); - } -} diff --git a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java b/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java deleted file mode 100644 index f7d807f..0000000 --- a/common/src/main/java/dev/isxander/yacl3/config/v2/api/autogen/SimpleOptionFactory.java +++ /dev/null @@ -1,138 +0,0 @@ -package dev.isxander.yacl3.config.v2.api.autogen; - -import dev.isxander.yacl3.api.Option; -import dev.isxander.yacl3.api.OptionDescription; -import dev.isxander.yacl3.api.OptionFlag; -import dev.isxander.yacl3.api.controller.ControllerBuilder; -import dev.isxander.yacl3.config.v2.api.ConfigField; -import dev.isxander.yacl3.config.v2.impl.FieldBackedBinding; -import dev.isxander.yacl3.config.v2.impl.autogen.AutoGenUtils; -import dev.isxander.yacl3.config.v2.impl.autogen.EmptyCustomImageFactory; -import dev.isxander.yacl3.config.v2.impl.autogen.YACLAutoGenException; -import net.minecraft.client.Minecraft; -import net.minecraft.locale.Language; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.Nullable; - -import java.lang.annotation.Annotation; -import java.util.Optional; -import java.util.Set; - -public abstract class SimpleOptionFactory implements OptionFactory { - @Override - public Option createOption(A annotation, ConfigField field, OptionAccess optionAccess) { - Option option = Option.createBuilder() - .name(this.name(annotation, field, optionAccess)) - .description(v -> this.description(v, annotation, field, optionAccess).build()) - .binding(new FieldBackedBinding<>(field.access(), field.defaultAccess())) - .controller(opt -> { - ControllerBuilder builder = this.createController(annotation, field, optionAccess, opt); - - AutoGenUtils.addCustomFormatterToController(builder, field.access()); - - return builder; - }) - .available(this.available(annotation, field, optionAccess)) - .flags(this.flags(annotation, field, optionAccess)) - .listener((opt, v) -> this.listener(annotation, field, optionAccess, opt, v)) - .build(); - - postInit(annotation, field, optionAccess, option); - return option; - } - - protected abstract ControllerBuilder createController(A annotation, ConfigField field, OptionAccess storage, Option option); - - protected MutableComponent name(A annotation, ConfigField field, OptionAccess storage) { - Optional customName = field.access().getAnnotation(CustomName.class); - return Component.translatable(customName.map(CustomName::value).orElse(this.getTranslationKey(field, null))); - } - - protected OptionDescription.Builder description(T value, A annotation, ConfigField field, OptionAccess storage) { - OptionDescription.Builder builder = OptionDescription.createBuilder(); - - String key = this.getTranslationKey(field, "desc"); - if (Language.getInstance().has(key)) { - builder.text(Component.translatable(key)); - } else { - key += "."; - int i = 1; - while (Language.getInstance().has(key + i)) { - builder.text(Component.translatable(key + i)); - i++; - } - } - - field.access().getAnnotation(CustomDescription.class).ifPresent(customDescription -> { - for (String line : customDescription.value()) { - builder.text(Component.translatable(line)); - } - }); - - Optional imageOverrideOpt = field.access().getAnnotation(CustomImage.class); - if (imageOverrideOpt.isPresent()) { - CustomImage imageOverride = imageOverrideOpt.get(); - - if (!imageOverride.factory().equals(EmptyCustomImageFactory.class)) { - CustomImage.CustomImageFactory imageFactory; - try { - imageFactory = (CustomImage.CustomImageFactory) AutoGenUtils.constructNoArgsClass( - imageOverride.factory(), - () -> "'%s': The factory class on @OverrideImage has no no-args constructor.".formatted(field.access().name()), - () -> "'%s': Failed to instantiate factory class %s.".formatted(field.access().name(), imageOverride.factory().getName()) - ); - } catch (ClassCastException e) { - throw new YACLAutoGenException("'%s': The factory class on @OverrideImage is of incorrect type. Expected %s, got %s.".formatted(field.access().name(), field.access().type().getTypeName(), imageOverride.factory().getTypeParameters()[0].getName())); - } - - builder.customImage(imageFactory.createImage(value, field, storage).thenApply(Optional::of)); - } else if (!imageOverride.value().isEmpty()) { - String path = imageOverride.value(); - ResourceLocation imageLocation = new ResourceLocation(field.parent().id().getNamespace(), path); - String extension = path.substring(path.lastIndexOf('.') + 1); - - switch (extension) { - case "png", "jpg", "jpeg" -> builder.image(imageLocation, imageOverride.width(), imageOverride.height()); - case "webp" -> builder.webpImage(imageLocation); - case "gif" -> builder.gifImage(imageLocation); - default -> throw new YACLAutoGenException("'%s': Invalid image extension '%s' on @OverrideImage. Expected: ('png','jpg','webp','gif')".formatted(field.access().name(), extension)); - } - } else { - throw new YACLAutoGenException("'%s': @OverrideImage has no value or factory class.".formatted(field.access().name())); - } - } else { - String imagePath = "tex