Lortseam 4 éve
szülő
commit
1461131264

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

@@ -26,6 +26,16 @@ public @interface ConfigEntry {
      */
     String value() default "";
 
+    /**
+     * Specifies a comment which describes the purpose of this entry. The comment will only be visible in the config
+     * save file.
+     *
+     * <p>If blank, no comment will be applied to the entry.
+     *
+     * @return a comment
+     */
+    String comment() default "";
+
     /**
      * Specifies a custom translation key for this entry. If empty, the default key for this entry will be used.
      *

+ 8 - 0
src/main/java/me/lortseam/completeconfig/data/Entry.java

@@ -48,6 +48,7 @@ public class Entry<T> extends EntryBase<T> implements DataPart {
     private boolean requiresRestart;
     @Getter
     private final Extras<T> extras = new Extras<>(this);
+    private String comment;
     private final List<Listener<T>> listeners = new ArrayList<>();
 
     private Entry(Field field, ConfigEntryContainer parentObject, TranslationIdentifier parentTranslation) {
@@ -176,6 +177,10 @@ public class Entry<T> extends EntryBase<T> implements DataPart {
             }
             forceUpdate = annotation.forceUpdate();
             requiresRestart = annotation.requiresRestart();
+            String comment = annotation.comment();
+            if (!StringUtils.isBlank(comment)) {
+                this.comment = comment;
+            }
         }
         if (field.isAnnotationPresent(ConfigEntry.Bounded.Integer.class)) {
             if (field.getType() != int.class && field.getType() != Integer.class) {
@@ -229,6 +234,9 @@ public class Entry<T> extends EntryBase<T> implements DataPart {
     public void fetch(CommentedConfigurationNode node) {
         try {
             node.set(type, getValue());
+            if (comment != null) {
+                node.comment(comment);
+            }
         } catch (SerializationException e) {
             LOGGER.error("[CompleteConfig] Failed to fetch value from entry!", e);
         }