From 78f0a42ec154bf579a757894d9e4706872737b9a Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 12 Feb 2019 01:31:51 -0800 Subject: [PATCH] new config system part 4 --- src/main/java/com/gmail/nossr50/DefaultKeys.java | 5 ----- .../com/gmail/nossr50/config/AdvancedConfig.java | 12 ++++-------- .../nossr50/config/ConfigLoaderConfigurable.java | 16 ++++++++++++++-- .../com/gmail/nossr50/config/DefaultKeys.java | 7 +++++++ src/main/resources/advanced.yml | 1 - src/main/resources/child.yml | 1 - src/main/resources/config.yml | 1 - src/main/resources/experience.yml | 1 - src/main/resources/potions.yml | 1 - src/main/resources/repair.vanilla.yml | 1 - src/main/resources/salvage.vanilla.yml | 1 - src/main/resources/treasures.yml | 1 - 12 files changed, 25 insertions(+), 23 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/DefaultKeys.java create mode 100644 src/main/java/com/gmail/nossr50/config/DefaultKeys.java diff --git a/src/main/java/com/gmail/nossr50/DefaultKeys.java b/src/main/java/com/gmail/nossr50/DefaultKeys.java deleted file mode 100644 index 4925b9185..000000000 --- a/src/main/java/com/gmail/nossr50/DefaultKeys.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.gmail.nossr50; - -public interface DefaultKeys { - boolean validateKeys(); -} diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 42aeaf730..27214c69a 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/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 validateKeys() { // Validate all the settings! List reason = new ArrayList(); @@ -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); } diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java b/src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java index 25df5e50a..4ec5c8bc6 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java +++ b/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 validKeyErrors = validateKeys(); // Validate Keys + + if(validKeyErrors.size() > 0) + { + for(String error : validKeyErrors) + { + mcMMO.p.getLogger().severe(error); + } + } } /** diff --git a/src/main/java/com/gmail/nossr50/config/DefaultKeys.java b/src/main/java/com/gmail/nossr50/config/DefaultKeys.java new file mode 100644 index 000000000..95aaca0e5 --- /dev/null +++ b/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 validateKeys(); +} diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index fb9c99f4c..c27706424 100644 --- a/src/main/resources/advanced.yml +++ b/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. # diff --git a/src/main/resources/child.yml b/src/main/resources/child.yml index 685a6ce71..8261d3a14 100644 --- a/src/main/resources/child.yml +++ b/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 # diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4c616b22d..2b7522312 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,6 +1,5 @@ # # mcMMO configuration -# Last updated on ${project.version}-b${BUILD_NUMBER} # ##### diff --git a/src/main/resources/experience.yml b/src/main/resources/experience.yml index 0e2f41b6b..d0823c41e 100644 --- a/src/main/resources/experience.yml +++ b/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. # diff --git a/src/main/resources/potions.yml b/src/main/resources/potions.yml index b85bd9739..a33d68402 100644 --- a/src/main/resources/potions.yml +++ b/src/main/resources/potions.yml @@ -1,6 +1,5 @@ # # Settings for Concoctions -# Last updated on ${project.version}-b${BUILD_NUMBER} ### Concoctions: Tier_One_Ingredients: diff --git a/src/main/resources/repair.vanilla.yml b/src/main/resources/repair.vanilla.yml index f228633c8..2039e19df 100644 --- a/src/main/resources/repair.vanilla.yml +++ b/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" diff --git a/src/main/resources/salvage.vanilla.yml b/src/main/resources/salvage.vanilla.yml index 73a853ecc..ebaddb978 100644 --- a/src/main/resources/salvage.vanilla.yml +++ b/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" diff --git a/src/main/resources/treasures.yml b/src/main/resources/treasures.yml index 315b5f6b4..f288c2252 100755 --- a/src/main/resources/treasures.yml +++ b/src/main/resources/treasures.yml @@ -1,6 +1,5 @@ # # Settings for Fishing -# Last updated on ${project.version}-b${BUILD_NUMBER} ### Fishing: LEATHER_BOOTS: