Lortseam 4 years ago
parent
commit
624f9aeb21

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

@@ -9,7 +9,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
- * A container for config entries.
+ * A container for config entries. Entries are added by declaring fields or registering transitive containers.
  */
  */
 public interface ConfigContainer {
 public interface ConfigContainer {
 
 
@@ -28,7 +28,7 @@ public interface ConfigContainer {
     }
     }
 
 
     /**
     /**
-     * Used to register transitive containers, located at the level of this container.
+     * Used to register transitive containers dynamically.
      *
      *
      * @return an array of containers
      * @return an array of containers
      * @see Transitive
      * @see Transitive
@@ -38,8 +38,7 @@ public interface ConfigContainer {
     }
     }
 
 
     /**
     /**
-     * Applied to declare that a field or a nested class of type {@link ConfigContainer} is transitive. Transitive
-     * containers will be registered at the level of this container.
+     * Applied to declare that a field or a nested class of type {@link ConfigContainer} is transitive.
      *
      *
      * @see #getTransitives()
      * @see #getTransitives()
      */
      */

+ 32 - 21
lib/src/main/java/me/lortseam/completeconfig/api/ConfigEntry.java

@@ -9,6 +9,8 @@ import java.lang.annotation.Target;
 
 
 /**
 /**
  * Applied to declare that a field should be resolved as config entry.
  * Applied to declare that a field should be resolved as config entry.
+ *
+ * @see ConfigEntries
  */
  */
 @Target(ElementType.FIELD)
 @Target(ElementType.FIELD)
 @Retention(RetentionPolicy.RUNTIME)
 @Retention(RetentionPolicy.RUNTIME)
@@ -63,14 +65,14 @@ public @interface ConfigEntry {
         /**
         /**
          * A custom translation key for the value {@code true}. If empty, the default key will be used.
          * A custom translation key for the value {@code true}. If empty, the default key will be used.
          *
          *
-         * @return a custom translation key
+         * @return a custom value translation key
          */
          */
         String trueTranslationKey() default "";
         String trueTranslationKey() default "";
 
 
         /**
         /**
          * A custom translation key for the value {@code false}. If empty, the default key will be used.
          * A custom translation key for the value {@code false}. If empty, the default key will be used.
          *
          *
-         * @return a custom translation key
+         * @return a custom value translation key
          */
          */
         String falseTranslationKey() default "";
         String falseTranslationKey() default "";
         
         
@@ -84,16 +86,16 @@ public @interface ConfigEntry {
     @interface BoundedInteger {
     @interface BoundedInteger {
 
 
         /**
         /**
-         * The minimum bound.
+         * The lower bound (minimum).
          *
          *
-         * @return the minimum bound
+         * @return the lower bound
          */
          */
         int min() default java.lang.Integer.MIN_VALUE;
         int min() default java.lang.Integer.MIN_VALUE;
 
 
         /**
         /**
-         * The maximum bound.
+         * The upper bound (maximum).
          *
          *
-         * @return the maximum bound
+         * @return the upper bound
          */
          */
         int max() default java.lang.Integer.MAX_VALUE;
         int max() default java.lang.Integer.MAX_VALUE;
 
 
@@ -107,16 +109,16 @@ public @interface ConfigEntry {
     @interface BoundedLong {
     @interface BoundedLong {
 
 
         /**
         /**
-         * The minimum bound.
+         * The lower bound (minimum).
          *
          *
-         * @return the minimum bound
+         * @return the lower bound
          */
          */
         long min() default java.lang.Long.MIN_VALUE;
         long min() default java.lang.Long.MIN_VALUE;
 
 
         /**
         /**
-         * The maximum bound.
+         * The upper bound (maximum).
          *
          *
-         * @return the maximum bound
+         * @return the upper bound
          */
          */
         long max() default java.lang.Long.MAX_VALUE;
         long max() default java.lang.Long.MAX_VALUE;
 
 
@@ -130,16 +132,16 @@ public @interface ConfigEntry {
     @interface BoundedFloat {
     @interface BoundedFloat {
 
 
         /**
         /**
-         * The minimum bound.
+         * The lower bound (minimum).
          *
          *
-         * @return the minimum bound
+         * @return the lower bound
          */
          */
         float min() default -java.lang.Float.MAX_VALUE;
         float min() default -java.lang.Float.MAX_VALUE;
 
 
         /**
         /**
-         * The maximum bound.
+         * The upper bound (maximum).
          *
          *
-         * @return the maximum bound
+         * @return the upper bound
          */
          */
         float max() default java.lang.Float.MAX_VALUE;
         float max() default java.lang.Float.MAX_VALUE;
 
 
@@ -153,40 +155,49 @@ public @interface ConfigEntry {
     @interface BoundedDouble {
     @interface BoundedDouble {
 
 
         /**
         /**
-         * The minimum bound.
+         * The lower bound (minimum).
          *
          *
-         * @return the minimum bound
+         * @return the lower bound
          */
          */
         double min() default -java.lang.Double.MAX_VALUE;
         double min() default -java.lang.Double.MAX_VALUE;
 
 
         /**
         /**
-         * The maximum bound.
+         * The upper bound (maximum).
          *
          *
-         * @return the maximum bound
+         * @return the upper bound
          */
          */
         double max() default java.lang.Double.MAX_VALUE;
         double max() default java.lang.Double.MAX_VALUE;
 
 
     }
     }
 
 
+    /**
+     * If applied, renders a slider for this entry. Usually used together with a bounding annotation.
+     */
     @Target({ElementType.FIELD})
     @Target({ElementType.FIELD})
     @Retention(RetentionPolicy.RUNTIME)
     @Retention(RetentionPolicy.RUNTIME)
     @interface Slider {
     @interface Slider {
 
 
+        /**
+         * Specifies a custom translation key for this entry's value. If empty, the default key will be used.
+         *
+         * <p>The translation must contain a single format specifier of the entry's type, which will be replaced by the
+         * actual value.
+         *
+         * @return a custom value translation key
+         */
         String valueTranslationKey() default "";
         String valueTranslationKey() default "";
 
 
     }
     }
 
 
     /**
     /**
      * Applied to an entry of type Enum.
      * Applied to an entry of type Enum.
-     *
-     * <p>This annotation is optional.
      */
      */
     @Target(ElementType.FIELD)
     @Target(ElementType.FIELD)
     @Retention(RetentionPolicy.RUNTIME)
     @Retention(RetentionPolicy.RUNTIME)
     @interface Enum {
     @interface Enum {
 
 
         /**
         /**
-         * Specifies how the entry should be rendered.
+         * Specifies how to render the entry.
          *
          *
          * @return the desired display type
          * @return the desired display type
          */
          */

+ 11 - 1
lib/src/main/java/me/lortseam/completeconfig/data/Config.java

@@ -112,18 +112,28 @@ public final class Config extends BaseCollection {
             return this;
             return this;
         }
         }
 
 
+        /**
+         * Sets a flag to save the config when the game closes.
+         *
+         * @return this builder
+         */
         public Builder saveOnExit() {
         public Builder saveOnExit() {
             saveOnExit = true;
             saveOnExit = true;
             return this;
             return this;
         }
         }
 
 
+        /**
+         * Registers the config as main mod config.
+         *
+         * @return this builder
+         */
         public Builder main() {
         public Builder main() {
             main = true;
             main = true;
             return this;
             return this;
         }
         }
 
 
         /**
         /**
-         * Completes the config creation.
+         * Creates and loads the config.
          *
          *
          * @return the created config
          * @return the created config
          */
          */

+ 15 - 0
lib/src/main/java/me/lortseam/completeconfig/gui/ConfigScreenBuilder.java

@@ -16,6 +16,13 @@ public abstract class ConfigScreenBuilder {
     private static final ConfigScreenBuilder fallback = FabricLoader.getInstance().isModLoaded("cloth-config2") ? new ClothConfigScreenBuilder() : null;
     private static final ConfigScreenBuilder fallback = FabricLoader.getInstance().isModLoaded("cloth-config2") ? new ClothConfigScreenBuilder() : null;
     private static final Map<String, ConfigScreenBuilder> mainBuilders = new HashMap<>();
     private static final Map<String, ConfigScreenBuilder> mainBuilders = new HashMap<>();
 
 
+    /**
+     * Sets the main screen builder for a mod. The main screen builder will be used to build the config screen if no
+     * custom builder was specified.
+     *
+     * @param modID the mod's ID
+     * @param screenBuilder the screen builder
+     */
     public static void setMain(String modID, ConfigScreenBuilder screenBuilder) {
     public static void setMain(String modID, ConfigScreenBuilder screenBuilder) {
         mainBuilders.put(modID, screenBuilder);
         mainBuilders.put(modID, screenBuilder);
     }
     }
@@ -30,6 +37,14 @@ public abstract class ConfigScreenBuilder {
         return Optional.empty();
         return Optional.empty();
     }
     }
 
 
+    /**
+     * Tries to build a screen based on a config. Fails if no main screen builder was specified for the mod and no
+     * fallback builder exists.
+     *
+     * @param parentScreen the parent screen
+     * @param config the config to build the screen of
+     * @return the built screen, if successful
+     */
     public static Optional<Screen> tryBuild(Screen parentScreen, Config config) {
     public static Optional<Screen> tryBuild(Screen parentScreen, Config config) {
         return getMain(config.getMod().getId()).map(builder -> builder.build(parentScreen, config));
         return getMain(config.getMod().getId()).map(builder -> builder.build(parentScreen, config));
     }
     }