Ver código fonte

Added warning when config is empty

Lortseam 4 anos atrás
pai
commit
dd388cbbbb

+ 4 - 0
src/main/java/me/lortseam/completeconfig/data/Collection.java

@@ -95,4 +95,8 @@ public class Collection implements FlatDataPart<ConfigMap> {
         return Arrays.asList(entries, collections);
     }
 
+    boolean isEmpty() {
+        return entries.isEmpty() && collections.isEmpty();
+    }
+
 }

+ 1 - 1
src/main/java/me/lortseam/completeconfig/data/CollectionMap.java

@@ -15,7 +15,7 @@ public class CollectionMap extends ConfigMap<Collection> {
         String groupID = group.getGroupID();
         Collection collection = new Collection(translation.append(groupID));
         collection.resolve(group);
-        if (collection.getEntries().isEmpty() && collection.getCollections().isEmpty()) {
+        if (collection.isEmpty()) {
             logger.warn("[CompleteConfig] Group " + groupID + " is empty!");
             return;
         }

+ 4 - 0
src/main/java/me/lortseam/completeconfig/data/Config.java

@@ -15,6 +15,7 @@ import java.util.Arrays;
 import java.util.LinkedHashSet;
 import java.util.Objects;
 
+@Log4j2
 public class Config extends Collection {
 
     /**
@@ -35,6 +36,9 @@ public class Config extends Collection {
         super(new TranslationIdentifier(source.getModID()));
         this.source = source;
         resolve(children);
+        if (isEmpty()) {
+            logger.warn("[CompleteConfig] Config " + source + " is empty!");
+        }
     }
 
     public String getModID() {

+ 4 - 0
src/main/java/me/lortseam/completeconfig/io/ConfigSource.java

@@ -2,6 +2,7 @@ package me.lortseam.completeconfig.io;
 
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
+import lombok.ToString;
 import lombok.extern.log4j.Log4j2;
 import me.lortseam.completeconfig.CompleteConfig;
 import me.lortseam.completeconfig.data.Config;
@@ -22,6 +23,7 @@ import java.util.Set;
 
 @Log4j2
 @EqualsAndHashCode(onlyExplicitlyIncluded = true)
+@ToString(onlyExplicitlyIncluded = true)
 public final class ConfigSource {
 
     private static final TypeSerializerCollection GLOBAL_TYPE_SERIALIZERS = TypeSerializerCollection.builder()
@@ -30,9 +32,11 @@ public final class ConfigSource {
     private static final Set<ConfigSource> sources = new HashSet<>();
 
     @EqualsAndHashCode.Include
+    @ToString.Include
     @Getter
     private final String modID;
     @EqualsAndHashCode.Include
+    @ToString.Include
     private final String[] branch;
     private final HoconConfigurationLoader loader;