1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-21 11:13:00 +01:00

new config system pt 5

This commit is contained in:
nossr50
2019-02-12 06:17:27 -08:00
parent e7b91f57ea
commit bf63ce33c5
4 changed files with 29 additions and 13 deletions

View File

@@ -3,6 +3,8 @@ package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import com.google.common.io.Files;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
@@ -37,6 +39,10 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
private ConfigurationNode userRootNode = null;
private ConfigurationNode defaultRootNode = null;
private CommentedConfigurationNode userCommentedRootNode = null;
/* CONFIG MANAGER */
private ConfigurationLoader<CommentedConfigurationNode> configManager;
//TODO: Needed?
//private ConfigurationLoader<CommentedConfigurationNode> configManager;
@@ -105,6 +111,9 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
final ConfigurationNode userConfig = this.userCopyLoader.load();
userRootNode = userConfig;
//TESTING THIS
userCommentedRootNode = configManager.load();
} catch (IOException e) {
e.printStackTrace();
}
@@ -282,28 +291,23 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
return userRootNode;
}
/**
* Attempts to get an int value from the config
* @param path path the node from the root node
* @return int value of the node
*/
int getIntValue(String path)
{
return userRootNode.getNode(path).getInt();
return userRootNode.getNode(path.split(".")).getInt();
}
double getDoubleValue(String path)
{
return userRootNode.getNode(path).getDouble();
return userRootNode.getNode(path.split(".")).getDouble();
}
boolean getBooleanValue(String path)
{
return userRootNode.getNode(path).getBoolean();
return userRootNode.getNode(path.split(".")).getBoolean();
}
String getStringValue(String path)
{
return userRootNode.getNode(path).getString();
return userRootNode.getNode(path.split(".")).getString();
}
}