Lortseam 4 роки тому
батько
коміт
4811acddb4

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

@@ -2,8 +2,16 @@ 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.
+ */
 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.
+     * @return the ID of this config category
+     */
     default String getConfigCategoryID() {
         return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, getClass().getSimpleName());
     }

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

@@ -9,77 +9,167 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 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
+ * miscellaneous options.
+ */
 @Target(ElementType.FIELD)
 @Retention(RetentionPolicy.RUNTIME)
 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 "";
 
+    /**
+     * 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 {};
 
+    /**
+     * 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
+     * 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;
 
     @NoArgsConstructor(access = AccessLevel.PRIVATE)
     class Bounded {
 
+        /**
+         * Applies bounds to an entry of type Integer.
+         */
         @Target(ElementType.FIELD)
         @Retention(RetentionPolicy.RUNTIME)
         public @interface Integer {
 
+            /**
+             * 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;
 
         }
 
+        /**
+         * Applies bounds to an entry of type Long.
+         */
         @Target(ElementType.FIELD)
         @Retention(RetentionPolicy.RUNTIME)
         public @interface Long {
 
+            /**
+             * 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;
 
         }
 
+        /**
+         * Applies bounds to an entry of type Float.
+         */
         @Target(ElementType.FIELD)
         @Retention(RetentionPolicy.RUNTIME)
         public @interface Float {
 
+            /**
+             * 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;
 
         }
 
+        /**
+         * Applies bounds to an entry of type Double.
+         */
         @Target(ElementType.FIELD)
         @Retention(RetentionPolicy.RUNTIME)
         public @interface Double {
 
+            /**
+             * 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;
 
         }
 
     }
 
+    /**
+     * Applied to an entry of type Enum to change the render behaviour.
+     */
     @Target(ElementType.FIELD)
     @Retention(RetentionPolicy.RUNTIME)
     @interface EnumOptions {
 
+        /**
+         * Specifies how the entry should be rendered.
+         * @return the desired {@link DisplayType}
+         */
         DisplayType displayType() default DisplayType.BUTTON;
 
         //TODO: Add gui suggestionMode option
 
     }
 
+    /**
+     * Can be applied to a field inside a POJO {@link ConfigEntryContainer} class to declare that the field should not
+     * be considered as config entry.
+     */
     @Target(ElementType.FIELD)
     @Retention(RetentionPolicy.RUNTIME)
     @interface Ignore {

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

@@ -9,6 +9,9 @@ import java.lang.annotation.Target;
 import java.util.ArrayList;
 import java.util.List;
 
+/**
+ * A container of config entries.
+ */
 public interface ConfigEntryContainer {
 
     default ConfigEntryContainer[] getTransitiveConfigEntryContainers() {

+ 15 - 0
src/main/java/me/lortseam/completeconfig/api/ConfigEntryListener.java

@@ -5,12 +5,27 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 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
+ * entry's field. This parameter contains the updated value which then can be used to modify the field itself.
+ */
 @Target(ElementType.METHOD)
 @Retention(RetentionPolicy.RUNTIME)
 public @interface ConfigEntryListener {
 
+    /**
+     * Specifies the name of the field.
+     * @return the entry's field name
+     */
     String value() default "";
 
+    /**
+     * 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;
 
 }

+ 3 - 0
src/main/java/me/lortseam/completeconfig/exception/IllegalAnnotationParameterException.java

@@ -1,5 +1,8 @@
 package me.lortseam.completeconfig.exception;
 
+/**
+ * Thrown to indicate that an annotation has been passed an illegal or inappropriate parameter.
+ */
 public class IllegalAnnotationParameterException extends RuntimeException {
 
     public IllegalAnnotationParameterException(String message) {

+ 3 - 0
src/main/java/me/lortseam/completeconfig/exception/IllegalAnnotationTargetException.java

@@ -1,5 +1,8 @@
 package me.lortseam.completeconfig.exception;
 
+/**
+ * Thrown to indicate that an annotation targets an illegal or inappropriate member.
+ */
 public class IllegalAnnotationTargetException extends RuntimeException {
 
     public IllegalAnnotationTargetException(String message) {

+ 3 - 0
src/main/java/me/lortseam/completeconfig/exception/IllegalModifierException.java

@@ -1,5 +1,8 @@
 package me.lortseam.completeconfig.exception;
 
+/**
+ * Thrown to indicate that an illegal or inappropriate modifier was applied to a member.
+ */
 public class IllegalModifierException extends RuntimeException {
 
     public IllegalModifierException(String message) {

+ 3 - 0
src/main/java/me/lortseam/completeconfig/exception/IllegalReturnValueException.java

@@ -1,5 +1,8 @@
 package me.lortseam.completeconfig.exception;
 
+/**
+ * Thrown to indicate that a method returns an illegal or inappropriate type.
+ */
 public class IllegalReturnValueException extends RuntimeException {
 
     public IllegalReturnValueException(String message) {