diff --git a/pom.xml b/pom.xml
index 70e6f096a..381c6a7a6 100755
--- a/pom.xml
+++ b/pom.xml
@@ -101,6 +101,7 @@
org.bstats:bstats-bukkit
org.spongepowered:configurate-yaml
org.spongepowered:configurate-core
+
@@ -120,6 +121,14 @@
org.bstats
com.gmail.nossr50.metrics.bstat
+
+
+ ninja.leaping
+ com.gmail.nossr50.configurable
+
@@ -145,6 +154,10 @@
sponge
https://repo.spongepowered.org/maven
+
+ flow
+ https://oss.sonatype.org/content/groups/public/
+
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
@@ -159,6 +172,11 @@
+
org.spongepowered
diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java b/src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java
index 081f6c52a..25df5e50a 100644
--- a/src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java
+++ b/src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java
@@ -35,7 +35,7 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
/* ROOT NODES */
- private ConfigurationNode rootNode = null;
+ private ConfigurationNode userRootNode = null;
private ConfigurationNode defaultRootNode = null;
//TODO: Needed?
@@ -91,7 +91,7 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
defaultRootNode = defaultConfig;
final ConfigurationNode userConfig = this.userCopyLoader.load();
- rootNode = userConfig;
+ userRootNode = userConfig;
} catch (IOException e) {
e.printStackTrace();
@@ -214,7 +214,7 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
public void readConfig() {
mcMMO.p.getLogger().info("Attempting to read " + FILE_RELATIVE_PATH + ".");
- int version = this.rootNode.getNode("ConfigVersion").getInt();
+ int version = this.userRootNode.getNode("ConfigVersion").getInt();
mcMMO.p.getLogger().info(FILE_RELATIVE_PATH + " version is " + version);
//Update our config
@@ -226,18 +226,31 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
*/
private void updateConfig()
{
- boolean addedValues = false;
-
mcMMO.p.getLogger().info(defaultRootNode.getChildrenMap().size() +" items in default children map");
- mcMMO.p.getLogger().info(rootNode.getChildrenMap().size() +" items in default root map");
+ mcMMO.p.getLogger().info(userRootNode.getChildrenMap().size() +" items in default root map");
- if(addedValues)
- {
- System.out.println("[mcMMO INFO] New config options were added, edit "+FILE_RELATIVE_PATH+" to customize!");
- }
+ // Merge Values from default
+ userRootNode = userRootNode.mergeValuesFrom(defaultRootNode);
// Update config version
updateConfigVersion();
+
+ //Attempt to save
+ try {
+ saveUserCopy();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Saves the current state information of the config to the users copy (which they may edit)
+ * @throws IOException
+ */
+ private void saveUserCopy() throws IOException
+ {
+ mcMMO.p.getLogger().info("Saving new node");
+ userCopyLoader.save(userRootNode);
}
/**
@@ -245,7 +258,7 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
*/
private void updateConfigVersion() {
// Set a version for our config
- this.rootNode.getNode("ConfigVersion").setValue(getConfigVersion());
+ this.userRootNode.getNode("ConfigVersion").setValue(getConfigVersion());
mcMMO.p.getLogger().info("Updated config to ["+getConfigVersion()+"] - " + FILE_RELATIVE_PATH);
}
@@ -253,7 +266,7 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
* Returns the root node of this config
* @return the root node of this config
*/
- protected ConfigurationNode getRootNode() {
- return rootNode;
+ protected ConfigurationNode getUserRootNode() {
+ return userRootNode;
}
}