From fb2eddd43255036e06d445f6a3a2788a5dc9a04a Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 13 Feb 2019 13:35:27 -0800 Subject: [PATCH] fixing NPE and IO errors --- src/main/java/com/gmail/nossr50/config/AdvancedConfig.java | 2 +- .../com/gmail/nossr50/config/ConfigLoaderConfigurable.java | 7 +++---- .../java/com/gmail/nossr50/config/ConfigurableTest.java | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index c34067ead..f77e9de49 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -16,7 +16,7 @@ public class AdvancedConfig extends ConfigLoaderConfigurable { private static AdvancedConfig instance; private AdvancedConfig() { - super(mcMMO.p.getDataFolder(), "advanced.yml"); + super(mcMMO.p.getDataFolder().getAbsoluteFile(), "advanced.yml"); } public static AdvancedConfig getInstance() { diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java b/src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java index c3e5c59cb..b21e8c7b4 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigLoaderConfigurable.java @@ -39,7 +39,6 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys { private ConfigurationNode userRootNode = null; private ConfigurationNode defaultRootNode = null; - private CommentedConfigurationNode userCommentedRootNode = null; /* CONFIG MANAGER */ private ConfigurationLoader configManager; @@ -111,9 +110,6 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys { final ConfigurationNode userConfig = this.userCopyLoader.load(); userRootNode = userConfig; - //TESTING THIS - userCommentedRootNode = configManager.load(); - } catch (IOException e) { e.printStackTrace(); } @@ -188,7 +184,10 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys { } if(!targetFile.exists()) + { + targetFile.getParentFile().mkdirs(); targetFile.createNewFile(); //New File Boys + } Files.write(buffer, targetFile); mcMMO.p.getLogger().info("Created config file - " + relativeOutputPath); diff --git a/src/main/java/com/gmail/nossr50/config/ConfigurableTest.java b/src/main/java/com/gmail/nossr50/config/ConfigurableTest.java index a20ebb9e3..8e5244ac4 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigurableTest.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigurableTest.java @@ -13,7 +13,7 @@ public class ConfigurableTest extends ConfigLoaderConfigurable { private static ConfigurableTest instance; public ConfigurableTest() { - super(mcMMO.p.getDataFolder(), relativePath); + super(mcMMO.p.getDataFolder().getAbsoluteFile(), relativePath); mcMMO.p.getLogger().severe("The value of bone "+boneValue); }