From b81ca84a99b6d9e8fc4aaee621677a5cd2059f79 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 20 Feb 2019 19:14:21 -0800 Subject: [PATCH] don't always copy defaults --- .../java/com/gmail/nossr50/config/Config.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index e5e931f7c..f5891fdf8 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -46,18 +46,19 @@ public abstract class Config implements VersionedConfig, Unload { private CommentedConfigurationNode defaultRootNode = null; /* CONFIG MANAGER */ - private ConfigurationLoader configManager; + //private ConfigurationLoader configManager; - public Config(String pathToParentFolder, String relativePath, boolean mergeNewKeys) { + public Config(String pathToParentFolder, String relativePath, boolean mergeNewKeys, boolean copyDefaults) { //TODO: Check if this works... - this(new File(pathToParentFolder), relativePath, mergeNewKeys); + this(new File(pathToParentFolder), relativePath, mergeNewKeys, copyDefaults); System.out.println("mcMMO Debug: Don't forget to check if loading config file by string instead of File works..."); } - public Config(File pathToParentFolder, String relativePath, boolean mergeNewKeys) { + public Config(File pathToParentFolder, String relativePath, boolean mergeNewKeys, boolean copyDefaults) { /* * These must be at the top */ + this.copyDefaults = copyDefaults; this.mergeNewKeys = mergeNewKeys; //Whether or not we add new keys when they are found mkdirDefaults(); // Make our default config dir DIRECTORY_DATA_FOLDER = pathToParentFolder; //Data Folder for our plugin @@ -157,7 +158,14 @@ public abstract class Config implements VersionedConfig, Unload { { //If it's gone we copy default files //Note that we don't copy the values from the default copy put in /defaults/ that file exists only as a reference to admins and is unreliable - return copyDefaultFromJar(FILE_RELATIVE_PATH, false); + if(copyDefaults) + return copyDefaultFromJar(FILE_RELATIVE_PATH, false); + else + { + //Make a new empty file + userCopy.createNewFile(); + return userCopy; + } } }