new config system part 4

This commit is contained in:
nossr50 2019-02-12 01:31:51 -08:00
parent fd8e44ef47
commit 78f0a42ec1
12 changed files with 25 additions and 23 deletions

View File

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

View File

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

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.config; package com.gmail.nossr50.config;
import com.gmail.nossr50.DefaultKeys;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.google.common.io.Files; import com.google.common.io.Files;
import ninja.leaping.configurate.ConfigurationNode; import ninja.leaping.configurate.ConfigurationNode;
@ -10,6 +9,7 @@ import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List;
/** /**
* Handles loading and cacheing configuration settings from a configurable compatible config file * Handles loading and cacheing configuration settings from a configurable compatible config file
@ -66,7 +66,19 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
e.printStackTrace(); 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);
}
}
} }
/** /**

View File

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

View File

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

View File

@ -1,6 +1,5 @@
# #
# mcMMO child skill configuration # 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 # You do not need to modify this file except to change parents of child skills
# #

View File

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

View File

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

View File

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

View File

@ -1,6 +1,5 @@
# #
# Repair configuration # 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 # 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" # All repair configs have a main section titled "Repairables"

View File

@ -1,6 +1,5 @@
# #
# Salvage configuration # 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 # 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" # All salvage configs have a main section titled "Salvageables"

View File

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