Browse Source

new config system part 4

nossr50 6 năm trước cách đây
mục cha
commit
78f0a42ec1

+ 0 - 5
src/main/java/com/gmail/nossr50/DefaultKeys.java

@@ -1,5 +0,0 @@
-package com.gmail.nossr50;
-
-public interface DefaultKeys {
-    boolean validateKeys();
-}

+ 4 - 8
src/main/java/com/gmail/nossr50/config/AdvancedConfig.java

@@ -9,12 +9,11 @@ import net.md_5.bungee.api.ChatColor;
 import java.util.ArrayList;
 import java.util.List;
 
-public class AdvancedConfig extends AutoUpdateConfigLoader {
+public class AdvancedConfig extends ConfigLoaderConfigurable {
     private static AdvancedConfig instance;
 
     private AdvancedConfig() {
-        super("advanced.yml");
-        validate();
+        super(mcMMO.p.getDataFolder(), "advanced.yml");
     }
 
     public static AdvancedConfig getInstance() {
@@ -26,7 +25,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
     }
 
     @Override
-    protected boolean validateKeys() {
+    public List<String> validateKeys() {
         // Validate all the settings!
         List<String> reason = new ArrayList<String>();
 
@@ -637,12 +636,9 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
             reason.add("Kraken.Attack_Damage should be at least 1!");
         }
 
-        return noErrorsInConfig(reason);
+        return reason;
     }
 
-    @Override
-    protected void loadKeys() {}
-
     /* GENERAL */
     public int getStartingLevel() { return config.getInt("Skills.General.StartingLevel", 1); }
 

+ 14 - 2
src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java

@@ -1,6 +1,5 @@
 package com.gmail.nossr50.config;
 
-import com.gmail.nossr50.DefaultKeys;
 import com.gmail.nossr50.mcMMO;
 import com.google.common.io.Files;
 import ninja.leaping.configurate.ConfigurationNode;
@@ -10,6 +9,7 @@ import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.List;
 
 /**
  * Handles loading and cacheing configuration settings from a configurable compatible config file
@@ -66,7 +66,19 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
             e.printStackTrace();
         }
 
-        validateKeys(); // Validate Keys
+        /*
+         * Print Errors about Keys
+         */
+
+        List<String> validKeyErrors = validateKeys(); // Validate Keys
+
+        if(validKeyErrors.size() > 0)
+        {
+            for(String error : validKeyErrors)
+            {
+                mcMMO.p.getLogger().severe(error);
+            }
+        }
     }
 
     /**

+ 7 - 0
src/main/java/com/gmail/nossr50/config/DefaultKeys.java

@@ -0,0 +1,7 @@
+package com.gmail.nossr50.config;
+
+import java.util.List;
+
+public interface DefaultKeys {
+    List<String> validateKeys();
+}

+ 0 - 1
src/main/resources/advanced.yml

@@ -1,6 +1,5 @@
 #
 #  Advanced configuration
-#  Last updated on ${project.version}-b${BUILD_NUMBER}
 #
 #  For advanced users only! There is no need to change anything here.
 #

+ 0 - 1
src/main/resources/child.yml

@@ -1,6 +1,5 @@
 #
 #  mcMMO child skill configuration
-#  Last updated on ${project.version}-b${BUILD_NUMBER}
 #
 #  You do not need to modify this file except to change parents of child skills
 #

+ 0 - 1
src/main/resources/config.yml

@@ -1,6 +1,5 @@
 #
 #  mcMMO configuration
-#  Last updated on ${project.version}-b${BUILD_NUMBER}
 #
 #####
 

+ 0 - 1
src/main/resources/experience.yml

@@ -1,6 +1,5 @@
 #
 #  Experience configuration
-#  Last updated on ${project.version}-b${BUILD_NUMBER}
 #
 #  Configure the experience formula and experience settings here.
 #

+ 0 - 1
src/main/resources/potions.yml

@@ -1,6 +1,5 @@
 #
 #  Settings for Concoctions
-#  Last updated on ${project.version}-b${BUILD_NUMBER}
 ###
 Concoctions:
     Tier_One_Ingredients:

+ 0 - 1
src/main/resources/repair.vanilla.yml

@@ -1,6 +1,5 @@
 #
 #  Repair configuration
-#  Last updated on ${project.version}-b${BUILD_NUMBER}
 #
 # Any file named repair.*.yml in the mcmmmo folder will be loaded as a repair config
 # All repair configs have a main section titled "Repairables"

+ 0 - 1
src/main/resources/salvage.vanilla.yml

@@ -1,6 +1,5 @@
 #
 #  Salvage configuration
-#  Last updated on ${project.version}-b${BUILD_NUMBER}
 #
 # Any file named salvage.*.yml in the mcmmmo folder will be loaded as a salvage config
 # All salvage configs have a main section titled "Salvageables"

+ 0 - 1
src/main/resources/treasures.yml

@@ -1,6 +1,5 @@
 #
 #  Settings for Fishing
-#  Last updated on ${project.version}-b${BUILD_NUMBER}
 ###
 Fishing:
     LEATHER_BOOTS: