Lortseam 4 年之前
父節點
當前提交
704b5e42eb

+ 11 - 0
src/main/java/me/lortseam/completeconfig/ConfigBuilder.java

@@ -22,11 +22,22 @@ public final class ConfigBuilder {
         this.owner = owner;
     }
 
+    /**
+     * Adds one or multiple top-level categories to the config.
+     *
+     * @param categories the top-level categories
+     * @return this config builder
+     */
     public ConfigBuilder add(ConfigCategory... categories) {
         topLevelCategories.addAll(Arrays.asList(categories));
         return this;
     }
 
+    /**
+     * Completes the config creation and registers the config.
+     *
+     * @return the handler associated with the created config
+     */
     public ConfigHandler finish() {
         handler.register(owner, topLevelCategories);
         return handler;

+ 5 - 2
src/main/java/me/lortseam/completeconfig/ConfigHandler.java

@@ -52,7 +52,7 @@ public final class ConfigHandler {
      * Gets the {@link ConfigHandler} for the specified owner if that owner created a config before.
      *
      * @param owner The owner class of the config
-     * @return The {@link ConfigHandler} if one was found or else an empty result
+     * @return The handler if one was found or else an empty result
      */
     public static Optional<ConfigHandler> of(Class<? extends ConfigOwner> owner) {
         return Optional.ofNullable(HANDLERS.get(owner));
@@ -87,10 +87,12 @@ public final class ConfigHandler {
     }
 
     /**
-     * Sets a custom GUI builder.
+     * Sets a custom client GUI builder.
+     *
      * @param guiBuilder The GUI builder for the mod's config
      */
     @Environment(EnvType.CLIENT)
+    //TODO: Move to ConfigBuilder
     public void setGuiBuilder(GuiBuilder guiBuilder) {
         Objects.requireNonNull(guiBuilder);
         this.guiBuilder = guiBuilder;
@@ -98,6 +100,7 @@ public final class ConfigHandler {
 
     /**
      * Generates the configuration GUI.
+     *
      * @param parentScreen The parent screen
      * @return The generated configuration screen
      */

+ 3 - 3
src/main/java/me/lortseam/completeconfig/api/ConfigCategory.java

@@ -3,13 +3,13 @@ package me.lortseam.completeconfig.api;
 import com.google.common.base.CaseFormat;
 
 /**
- * A container of config entries which is rendered as category or subcategory in the config GUI.
+ * A container of config entries which has an identifier additionally.
  */
 public interface ConfigCategory extends ConfigEntryContainer {
 
     /**
-     * Used to get the ID of the config category created with this class. Defaults to the class name.
-     * Override this method to set a custom ID.
+     * Used to modify the ID of this category. Defaults to the class name. Override this method to set a custom ID.
+     *
      * @return the ID of this config category
      */
     default String getConfigCategoryID() {

+ 17 - 2
src/main/java/me/lortseam/completeconfig/api/ConfigEntry.java

@@ -13,7 +13,7 @@ import java.lang.annotation.Target;
  * Applied to declare that a field is an entry inside the mod's config. Only required if
  * the {@link ConfigEntryContainer} is not a POJO class.
  *
- * This is also used to change the behaviour of the entry regarding translations, bounds and other
+ * <p>This is also used to change the behaviour of the entry regarding translations, bounds and other
  * miscellaneous options.
  */
 @Target(ElementType.FIELD)
@@ -22,6 +22,7 @@ public @interface ConfigEntry {
 
     /**
      * Specifies a custom translation key for this entry. If empty, the default key will be used.
+     *
      * @return a custom translation key
      */
     String customTranslationKey() default "";
@@ -29,6 +30,7 @@ public @interface ConfigEntry {
     /**
      * Specifies one or more custom translation keys for this entry's tooltip. If empty, the default single-line or
      * multi-line keys will be used, depending on which are declared in the language file(s).
+     *
      * @return an array of custom tooltip translation keys
      */
     String[] customTooltipKeys() default {};
@@ -36,14 +38,16 @@ public @interface ConfigEntry {
     /**
      * Specifies if the entry's field should get updated while at least one listener exists in the entry's class.
      *
-     * By default the entry's field will not get modified when the config is saved, but all listeners will be called
+     * <p>By default the entry's field will not get modified when the config is saved, but all listeners will be called
      * with the updated value. Set this to true to always update the field when saving.
+     *
      * @return true if the field should get updated, else false
      */
     boolean forceUpdate() default false;
 
     /**
      * Specifies whether the game needs to be restarted after modifying this entry.
+     *
      * @return whether the game needs to be restarted after modifying this field's entry
      */
     boolean requiresRestart() default false;
@@ -60,18 +64,21 @@ public @interface ConfigEntry {
 
             /**
              * The minimum bound.
+             *
              * @return the minimum bound
              */
             int min() default java.lang.Integer.MIN_VALUE;
 
             /**
              * The maximum bound.
+             *
              * @return the maximum bound
              */
             int max() default java.lang.Integer.MAX_VALUE;
 
             /**
              * Specifies whether the entry should be rendered as slider.
+             *
              * @return whether the entry should be rendered as slider
              */
             boolean slider() default true;
@@ -87,18 +94,21 @@ public @interface ConfigEntry {
 
             /**
              * The minimum bound.
+             *
              * @return the minimum bound
              */
             long min() default java.lang.Long.MIN_VALUE;
 
             /**
              * The maximum bound.
+             *
              * @return the maximum bound
              */
             long max() default java.lang.Long.MAX_VALUE;
 
             /**
              * Specifies whether the entry should be rendered as slider.
+             *
              * @return whether the entry should be rendered as slider
              */
             boolean slider() default true;
@@ -114,12 +124,14 @@ public @interface ConfigEntry {
 
             /**
              * The minimum bound.
+             *
              * @return the minimum bound
              */
             float min() default -java.lang.Float.MAX_VALUE;
 
             /**
              * The maximum bound.
+             *
              * @return the maximum bound
              */
             float max() default java.lang.Float.MAX_VALUE;
@@ -135,12 +147,14 @@ public @interface ConfigEntry {
 
             /**
              * The minimum bound.
+             *
              * @return the minimum bound
              */
             double min() default -java.lang.Double.MAX_VALUE;
 
             /**
              * The maximum bound.
+             *
              * @return the maximum bound
              */
             double max() default java.lang.Double.MAX_VALUE;
@@ -158,6 +172,7 @@ public @interface ConfigEntry {
 
         /**
          * Specifies how the entry should be rendered.
+         *
          * @return the desired {@link DisplayType}
          */
         DisplayType displayType() default DisplayType.BUTTON;

+ 0 - 1
src/main/java/me/lortseam/completeconfig/api/ConfigEntryContainer.java

@@ -18,7 +18,6 @@ public interface ConfigEntryContainer {
      * Used to register other containers. They will be located on the same level.
      *
      * @return an array of other containers
-     *
      * @see Transitive
      */
     default ConfigEntryContainer[] getTransitiveConfigEntryContainers() {

+ 3 - 1
src/main/java/me/lortseam/completeconfig/api/ConfigEntryListener.java

@@ -8,7 +8,7 @@ import java.lang.annotation.Target;
 /**
  * Applied to declare that a method is a listener for a config entry.
  *
- * A listener method gets called every time the config is saved. It requires a parameter of the same type as the
+ * <p>A listener method gets called every time the config is saved. It requires a parameter of the same type as the
  * entry's field. This parameter contains the updated value which then can be used to modify the field itself.
  */
 @Target(ElementType.METHOD)
@@ -17,6 +17,7 @@ public @interface ConfigEntryListener {
 
     /**
      * Specifies the name of the field.
+     *
      * @return the entry's field name
      */
     String value() default "";
@@ -24,6 +25,7 @@ public @interface ConfigEntryListener {
     /**
      * Specifies the class in which the entry's field is declared in. Only required if the listener is not declared
      * in the same class.
+     *
      * @return the entry's class
      */
     Class<? extends ConfigEntryContainer> container() default ConfigEntryContainer.class;

+ 27 - 0
src/main/java/me/lortseam/completeconfig/api/ConfigOwner.java

@@ -2,18 +2,45 @@ package me.lortseam.completeconfig.api;
 
 import me.lortseam.completeconfig.ConfigBuilder;
 
+/**
+ * This entrypoint is called to create a config in a specific environment or in both environments.
+ *
+ * <p>In {@code fabric.mod.json}, the entrypoint is defined with {@code completeconfig} key.</p>
+ */
 public interface ConfigOwner {
 
+    /**
+     * Called on the client side and server side to initialize a config associated with this entrypoint's mod.
+     *
+     * @param builder The config builder
+     */
     default void onInitializeConfig(ConfigBuilder builder) {}
 
+    /**
+     * Called on the client side to initialize a config associated with this entrypoint's mod.
+     *
+     * @param builder The config builder
+     */
     default void onInitializeClientConfig(ConfigBuilder builder) {
         onInitializeConfig(builder);
     }
 
+    /**
+     * Called on the server side to initialize a config associated with this entrypoint's mod.
+     *
+     * @param builder The config builder
+     */
     default void onInitializeServerConfig(ConfigBuilder builder) {
         onInitializeConfig(builder);
     }
 
+    /**
+     * Used to set a specific branch for the configuration(s) created by this entrypoint.
+     *
+     * <p>A config branch defines the location of the config's save file. The root of this branch is always the mod ID.
+     *
+     * @return the config branch
+     */
     default String[] getConfigBranch() {
         return new String[0];
     }