Lortseam 4 år sedan
förälder
incheckning
507845800b

+ 22 - 0
lib/src/main/java/me/lortseam/completeconfig/CompleteConfig.java

@@ -34,6 +34,13 @@ public final class CompleteConfig {
         }
     }
 
+    /**
+     * Registers a custom extension type which depends on the environment type and a list of loaded mods.
+     *
+     * @param extensionType the extension type
+     * @param environment the required environment type
+     * @param mods the required mods
+     */
     public static void registerExtensionType(@NonNull Class<? extends Extension> extensionType, EnvType environment, String... mods) {
         if(validExtensionTypes.contains(extensionType)) return;
         if(environment != null && FabricLoader.getInstance().getEnvironmentType() != environment || Arrays.stream(mods).anyMatch(modId -> {
@@ -42,6 +49,12 @@ public final class CompleteConfig {
         validExtensionTypes.add(extensionType);
     }
 
+    /**
+     * Registers a custom extension type which depends on a list of loaded mods.
+     *
+     * @param extensionType the extension type
+     * @param mods the required mods
+     */
     public static void registerExtensionType(@NonNull Class<? extends Extension> extensionType, String... mods) {
         registerExtensionType(extensionType, null, mods);
     }
@@ -64,6 +77,15 @@ public final class CompleteConfig {
         }
     }
 
+    /**
+     * Registers an external CompleteConfig extension. To register an extension provided by your own mod, use the
+     * {@link CompleteConfigExtension} entrypoint.
+     *
+     * @param modId the ID of the external mod
+     * @param extension the extension
+     *
+     * @see CompleteConfigExtension
+     */
     public static void registerExtension(@NonNull String modId, @NonNull Class<? extends CompleteConfigExtension> extension) {
         if(!FabricLoader.getInstance().isModLoaded(modId)) return;
         registerExtension(extension);

+ 0 - 3
lib/src/main/java/me/lortseam/completeconfig/api/ConfigContainer.java

@@ -8,9 +8,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-/**
- * A container for config entries. Entries are added by declaring fields or registering transitive containers.
- */
 public interface ConfigContainer {
 
     default Iterable<Class<? extends ConfigContainer>> getConfigClasses() {

+ 5 - 0
lib/src/main/java/me/lortseam/completeconfig/api/ConfigEntry.java

@@ -194,6 +194,11 @@ public @interface ConfigEntry {
     @Retention(RetentionPolicy.RUNTIME)
     @interface Dropdown {
 
+        /**
+         * Specifies whether to make the value editable and show suggestions only.
+         *
+         * @return whether to enable suggestions
+         */
         boolean suggestionMode() default false;
 
     }

+ 0 - 3
lib/src/main/java/me/lortseam/completeconfig/api/ConfigGroup.java

@@ -2,9 +2,6 @@ package me.lortseam.completeconfig.api;
 
 import com.google.common.base.CaseFormat;
 
-/**
- * A group of config entries.
- */
 public interface ConfigGroup extends ConfigContainer {
 
     /**

+ 49 - 0
lib/src/main/java/me/lortseam/completeconfig/data/transform/Transformation.java

@@ -15,11 +15,21 @@ import java.util.Set;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
+/**
+ * A transformation is used to transform a field to an {@link me.lortseam.completeconfig.data.Entry}. This class stores
+ * a predicate, which a field has to fulfill, and a {@link Transformer}, which performs the actual transformation
+ * process.
+ */
 @RequiredArgsConstructor(access = AccessLevel.PRIVATE)
 public final class Transformation {
 
     private static final Set<Class<? extends Annotation>> registeredAnnotations = new HashSet<>();
 
+    /**
+     * Creates a new transformation builder.
+     *
+     * @return a new transformation builder
+     */
     public static Transformation.Builder builder() {
         return new Transformation.Builder();
     }
@@ -48,24 +58,57 @@ public final class Transformation {
             return this;
         }
 
+        /**
+         * Filters by field type.
+         *
+         * @param types the valid field types
+         * @return this builder
+         */
         public Builder byType(Type... types) {
             return byType(type -> ArrayUtils.contains(types, type));
         }
 
+        /**
+         * Filters by a predicate based on the field type.
+         *
+         * @param typePredicate a predicate returning {@code true} for valid types
+         * @return this builder
+         */
         public Builder byType(Predicate<Type> typePredicate) {
             return by(origin -> typePredicate.test(origin.getType()));
         }
 
+        /**
+         * Filters by an annotation type. The annotation may be required or optional.
+         *
+         * @param annotation the annotation type
+         * @param optional whether the annotation is optional
+         * @return this builder
+         */
         public Builder byAnnotation(Class<? extends Annotation> annotation, boolean optional) {
             registeredAnnotations.add(annotation);
             (optional ? optionalAnnotations : requiredAnnotations).add(annotation);
             return this;
         }
 
+        /**
+         * Filters by an annotation type. The annotation is required.
+         *
+         * @param annotation the annotation type
+         * @return this builder
+         *
+         * @see Transformation.Builder#byAnnotation(Class, boolean)
+         */
         public Builder byAnnotation(Class<? extends Annotation> annotation) {
             return byAnnotation(annotation, false);
         }
 
+        /**
+         * Filters by multiple annotation types. All annotations are required.
+         *
+         * @param annotations the annotation types
+         * @return this builder
+         */
         public Builder byAnnotation(Iterable<Class<? extends Annotation>> annotations) {
             for (Class<? extends Annotation> annotation : annotations) {
                 byAnnotation(annotation);
@@ -73,6 +116,12 @@ public final class Transformation {
             return this;
         }
 
+        /**
+         * Sets the transformer and creates the {@link Transformation} object.
+         *
+         * @param transformer the transformer
+         * @return the created transformation
+         */
         public Transformation transforms(Transformer transformer) {
             if (predicate == null && requiredAnnotations.isEmpty()) {
                 throw new IllegalStateException("Missing transformation filter");

+ 15 - 0
lib/src/main/java/me/lortseam/completeconfig/extensions/CompleteConfigExtension.java

@@ -3,12 +3,27 @@ package me.lortseam.completeconfig.extensions;
 import me.lortseam.completeconfig.data.transform.Transformation;
 import org.spongepowered.configurate.serialize.TypeSerializerCollection;
 
+/**
+ * The main CompleteConfig extension type. Used for the {@code completeconfig-extension} entrypoint.
+ */
 public interface CompleteConfigExtension extends Extension {
 
+    /**
+     * Used to register custom type serializers for config entries.
+     *
+     * @return a collection of custom type serializers
+     */
     default TypeSerializerCollection getTypeSerializers() {
         return null;
     }
 
+    /**
+     * Used to register custom entry transformations.
+     *
+     * @return an array of custom transformations
+     *
+     * @see Transformation
+     */
     default Transformation[] getTransformations() {
         return null;
     }

+ 8 - 0
lib/src/main/java/me/lortseam/completeconfig/extensions/Extension.java

@@ -2,8 +2,16 @@ package me.lortseam.completeconfig.extensions;
 
 import java.util.Set;
 
+/**
+ * The base type for CompleteConfig extensions. Every extension type must extend this interface.
+ */
 public interface Extension {
 
+    /**
+     * Used to register child extensions of this extension.
+     *
+     * @return child extensions of this extension
+     */
     default Set<Class<? extends Extension>> children() {
         return null;
     }

+ 12 - 0
lib/src/main/java/me/lortseam/completeconfig/extensions/GuiExtension.java

@@ -2,8 +2,20 @@ package me.lortseam.completeconfig.extensions;
 
 import me.lortseam.completeconfig.gui.cloth.GuiProvider;
 
+/**
+ * The main extension type for extending the Cloth Config screen building process.
+ *
+ * @see me.lortseam.completeconfig.gui.cloth.ClothConfigScreenBuilder
+ */
 public interface GuiExtension extends Extension {
 
+    /**
+     * Used to register custom {@link GuiProvider}s.
+     *
+     * @return an array of custom {@link GuiProvider}s
+     *
+     * @see GuiProvider
+     */
     default GuiProvider[] getProviders() {
         return null;
     }

+ 38 - 0
lib/src/main/java/me/lortseam/completeconfig/gui/cloth/GuiProvider.java

@@ -11,10 +11,24 @@ import org.apache.commons.lang3.ArrayUtils;
 import java.lang.reflect.Type;
 import java.util.function.Predicate;
 
+/**
+ * A GUI provider is used to generate a GUI for an {@link Entry}. This class stores a predicate, which an entry has to
+ * fulfill, and an {@link EntryBuilder}, which performs the actual GUI generation.
+ */
 @Environment(EnvType.CLIENT)
 @RequiredArgsConstructor(access = AccessLevel.PRIVATE)
 public final class GuiProvider {
 
+    /**
+     * Creates a new GUI provider for a custom entry type, filtered by a predicate and value types.
+     *
+     * @param entryType the custom entry class
+     * @param builder the entry builder
+     * @param predicate a predicate which the entry has to fulfill
+     * @param types the valid value types
+     * @param <E> the custom entry type
+     * @return the created GUI provider
+     */
     public static <E extends Entry<?>> GuiProvider create(Class<E> entryType, EntryBuilder<? extends E> builder, Predicate<E> predicate, Type... types) {
         return new GuiProvider(entry -> {
             if (entry.getClass() != (entryType != null ? entryType : Entry.class)) return false;
@@ -23,14 +37,38 @@ public final class GuiProvider {
         }, builder);
     }
 
+    /**
+     * Creates a new GUI provider for a custom entry type, filtered by value types.
+     *
+     * @param entryType the custom entry class
+     * @param builder the entry builder
+     * @param types the valid value types
+     * @param <E> the custom entry type
+     * @return the created GUI provider
+     */
     public static <E extends Entry<?>> GuiProvider create(Class<E> entryType, EntryBuilder<? extends E> builder, Type... types) {
         return create(entryType, builder, entry -> true, types);
     }
 
+    /**
+     * Creates a new GUI provider for the default entry type, filtered by a predicate and value types.
+     *
+     * @param builder the entry builder
+     * @param predicate a predicate which the entry has to fulfill
+     * @param types the valid value types
+     * @return the created GUI provider
+     */
     public static GuiProvider create(EntryBuilder<?> builder, Predicate<Entry<?>> predicate, Type... types) {
         return create(null, builder, predicate, types);
     }
 
+    /**
+     * Creates a new GUI provider for the default entry type, filtered by value types.
+     *
+     * @param builder the entry builder
+     * @param types the valid value types
+     * @return the created GUI provider
+     */
     public static GuiProvider create(EntryBuilder<?> builder, Type... types) {
         if (types.length == 0) {
             throw new IllegalArgumentException("Types must not be empty");

+ 8 - 0
lib/src/main/java/me/lortseam/completeconfig/gui/cloth/GuiProviderRegistry.java

@@ -15,6 +15,9 @@ import net.minecraft.text.TextColor;
 import java.util.*;
 import java.util.stream.Stream;
 
+/**
+ * Stores global and screen builder specific GUI providers.
+ */
 @Environment(EnvType.CLIENT)
 public final class GuiProviderRegistry {
 
@@ -204,6 +207,11 @@ public final class GuiProviderRegistry {
 
     private final List<GuiProvider> providers = new ArrayList<>();
 
+    /**
+     * Registers one or more custom GUI providers.
+     *
+     * @param providers the custom GUI providers
+     */
     public void add(GuiProvider... providers) {
         Collections.addAll(this.providers, providers);
     }