fixing NPE and IO errors

This commit is contained in:
nossr50 2019-02-13 13:35:27 -08:00
parent bf63ce33c5
commit fb2eddd432
3 changed files with 5 additions and 6 deletions

View File

@ -16,7 +16,7 @@ public class AdvancedConfig extends ConfigLoaderConfigurable {
private static AdvancedConfig instance; private static AdvancedConfig instance;
private AdvancedConfig() { private AdvancedConfig() {
super(mcMMO.p.getDataFolder(), "advanced.yml"); super(mcMMO.p.getDataFolder().getAbsoluteFile(), "advanced.yml");
} }
public static AdvancedConfig getInstance() { public static AdvancedConfig getInstance() {

View File

@ -39,7 +39,6 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
private ConfigurationNode userRootNode = null; private ConfigurationNode userRootNode = null;
private ConfigurationNode defaultRootNode = null; private ConfigurationNode defaultRootNode = null;
private CommentedConfigurationNode userCommentedRootNode = null;
/* CONFIG MANAGER */ /* CONFIG MANAGER */
private ConfigurationLoader<CommentedConfigurationNode> configManager; private ConfigurationLoader<CommentedConfigurationNode> configManager;
@ -111,9 +110,6 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
final ConfigurationNode userConfig = this.userCopyLoader.load(); final ConfigurationNode userConfig = this.userCopyLoader.load();
userRootNode = userConfig; userRootNode = userConfig;
//TESTING THIS
userCommentedRootNode = configManager.load();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -188,7 +184,10 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
} }
if(!targetFile.exists()) if(!targetFile.exists())
{
targetFile.getParentFile().mkdirs();
targetFile.createNewFile(); //New File Boys targetFile.createNewFile(); //New File Boys
}
Files.write(buffer, targetFile); Files.write(buffer, targetFile);
mcMMO.p.getLogger().info("Created config file - " + relativeOutputPath); mcMMO.p.getLogger().info("Created config file - " + relativeOutputPath);

View File

@ -13,7 +13,7 @@ public class ConfigurableTest extends ConfigLoaderConfigurable {
private static ConfigurableTest instance; private static ConfigurableTest instance;
public ConfigurableTest() { public ConfigurableTest() {
super(mcMMO.p.getDataFolder(), relativePath); super(mcMMO.p.getDataFolder().getAbsoluteFile(), relativePath);
mcMMO.p.getLogger().severe("The value of bone "+boneValue); mcMMO.p.getLogger().severe("The value of bone "+boneValue);
} }