mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 00:26:45 +01:00
added hocon configurate libs to maven
This commit is contained in:
parent
f772b39eda
commit
d5ea196840
6
pom.xml
6
pom.xml
@ -99,6 +99,7 @@
|
|||||||
<include>org.apache.tomcat:tomcat-jdbc</include>
|
<include>org.apache.tomcat:tomcat-jdbc</include>
|
||||||
<include>org.apache.tomcat:tomcat-juli</include>
|
<include>org.apache.tomcat:tomcat-juli</include>
|
||||||
<include>org.bstats:bstats-bukkit</include>
|
<include>org.bstats:bstats-bukkit</include>
|
||||||
|
<include>org.spongepowered:configurate-hocon</include>
|
||||||
<include>org.spongepowered:configurate-yaml</include>
|
<include>org.spongepowered:configurate-yaml</include>
|
||||||
<include>org.spongepowered:configurate-core</include>
|
<include>org.spongepowered:configurate-core</include>
|
||||||
<!--<include>com.flowpowered:flow-math</include>-->
|
<!--<include>com.flowpowered:flow-math</include>-->
|
||||||
@ -183,6 +184,11 @@
|
|||||||
<artifactId>configurate-yaml</artifactId>
|
<artifactId>configurate-yaml</artifactId>
|
||||||
<version>3.6</version>
|
<version>3.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spongepowered</groupId>
|
||||||
|
<artifactId>configurate-hocon</artifactId>
|
||||||
|
<version>3.6</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.scm</groupId>
|
<groupId>org.apache.maven.scm</groupId>
|
||||||
<artifactId>maven-scm-provider-gitexe</artifactId>
|
<artifactId>maven-scm-provider-gitexe</artifactId>
|
||||||
|
@ -3,7 +3,8 @@ package com.gmail.nossr50.config;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import ninja.leaping.configurate.ConfigurationNode;
|
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
|
||||||
|
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
|
||||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||||
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||||
import org.yaml.snakeyaml.DumperOptions;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
@ -32,11 +33,11 @@ public abstract class Config implements VersionedConfig, Unload {
|
|||||||
|
|
||||||
/* LOADERS */
|
/* LOADERS */
|
||||||
|
|
||||||
private YAMLConfigurationLoader defaultCopyLoader;
|
private HoconConfigurationLoader defaultCopyLoader;
|
||||||
private YAMLConfigurationLoader userCopyLoader;
|
private HoconConfigurationLoader userCopyLoader;
|
||||||
|
|
||||||
//private ConfigurationLoader<CommentedConfigurationNode> defaultCopyLoader;
|
//private ConfigurationLoader<CommentedCommentedConfigurationNode> defaultCopyLoader;
|
||||||
//private ConfigurationLoader<CommentedConfigurationNode> userCopyLoader;
|
//private ConfigurationLoader<CommentedCommentedConfigurationNode> userCopyLoader;
|
||||||
|
|
||||||
/* CONFIG FILES */
|
/* CONFIG FILES */
|
||||||
|
|
||||||
@ -45,11 +46,11 @@ public abstract class Config implements VersionedConfig, Unload {
|
|||||||
|
|
||||||
/* ROOT NODES */
|
/* ROOT NODES */
|
||||||
|
|
||||||
private ConfigurationNode userRootNode = null;
|
private CommentedConfigurationNode userRootNode = null;
|
||||||
private ConfigurationNode defaultRootNode = null;
|
private CommentedConfigurationNode defaultRootNode = null;
|
||||||
|
|
||||||
/* CONFIG MANAGER */
|
/* CONFIG MANAGER */
|
||||||
//private ConfigurationLoader<CommentedConfigurationNode> configManager;
|
//private ConfigurationLoader<CommentedCommentedConfigurationNode> configManager;
|
||||||
|
|
||||||
public Config(String pathToParentFolder, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
|
public Config(String pathToParentFolder, String relativePath, boolean mergeNewKeys, boolean copyDefaults, boolean removeOldKeys) {
|
||||||
//TODO: Check if this works...
|
//TODO: Check if this works...
|
||||||
@ -126,10 +127,10 @@ public abstract class Config implements VersionedConfig, Unload {
|
|||||||
private void loadConfig()
|
private void loadConfig()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
final ConfigurationNode defaultConfig = this.defaultCopyLoader.load();
|
final CommentedConfigurationNode defaultConfig = this.defaultCopyLoader.load();
|
||||||
defaultRootNode = defaultConfig;
|
defaultRootNode = defaultConfig;
|
||||||
|
|
||||||
final ConfigurationNode userConfig = this.userCopyLoader.load();
|
final CommentedConfigurationNode userConfig = this.userCopyLoader.load();
|
||||||
userRootNode = userConfig;
|
userRootNode = userConfig;
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -138,12 +139,12 @@ public abstract class Config implements VersionedConfig, Unload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the YAMLConfigurationLoaders for this config
|
* Initializes the Configuration Loaders for this config
|
||||||
*/
|
*/
|
||||||
private void initConfigLoaders()
|
private void initConfigLoaders()
|
||||||
{
|
{
|
||||||
this.defaultCopyLoader = YAMLConfigurationLoader.builder().setPath(resourceConfigCopy.toPath()).setFlowStyle(DumperOptions.FlowStyle.BLOCK).build();
|
this.defaultCopyLoader = HoconConfigurationLoader.builder().setPath(resourceConfigCopy.toPath()).build();
|
||||||
this.userCopyLoader = YAMLConfigurationLoader.builder().setPath(resourceUserCopy.toPath()).setFlowStyle(DumperOptions.FlowStyle.BLOCK).build();
|
this.userCopyLoader = HoconConfigurationLoader.builder().setPath(resourceUserCopy.toPath()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -313,7 +314,7 @@ public abstract class Config implements VersionedConfig, Unload {
|
|||||||
if(!removeOldKeys)
|
if(!removeOldKeys)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(ConfigurationNode configurationNode : defaultRootNode.getChildrenList())
|
for(CommentedConfigurationNode CommentedConfigurationNode : defaultRootNode.getChildrenList())
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -342,7 +343,7 @@ public abstract class Config implements VersionedConfig, Unload {
|
|||||||
* Returns the root node of this config
|
* Returns the root node of this config
|
||||||
* @return the root node of this config
|
* @return the root node of this config
|
||||||
*/
|
*/
|
||||||
protected ConfigurationNode getUserRootNode() {
|
protected CommentedConfigurationNode getUserRootNode() {
|
||||||
return userRootNode;
|
return userRootNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,7 +418,7 @@ public abstract class Config implements VersionedConfig, Unload {
|
|||||||
* @param path the path to the parent node
|
* @param path the path to the parent node
|
||||||
* @return the list of children for the target parent node
|
* @return the list of children for the target parent node
|
||||||
*/
|
*/
|
||||||
public List<? extends ConfigurationNode> getChildren(String... path) {
|
public List<? extends CommentedConfigurationNode> getChildren(String... path) {
|
||||||
return userRootNode.getNode(path).getChildrenList();
|
return userRootNode.getNode(path).getChildrenList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user