mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
new config system pt 5
This commit is contained in:
parent
e7b91f57ea
commit
bf63ce33c5
@ -5,10 +5,13 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
public class AdvancedConfig extends ConfigLoaderConfigurable {
|
public class AdvancedConfig extends ConfigLoaderConfigurable {
|
||||||
private static AdvancedConfig instance;
|
private static AdvancedConfig instance;
|
||||||
|
|
||||||
@ -24,6 +27,9 @@ public class AdvancedConfig extends ConfigLoaderConfigurable {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Setting(value = "Skills.General.StartingLevel", comment = "The starting level for players on your server.\nHistorically this has been 0.\nRecently is has changed to 1.")
|
||||||
|
private int startingLevel = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> validateKeys() {
|
public List<String> validateKeys() {
|
||||||
// Validate all the settings!
|
// Validate all the settings!
|
||||||
@ -369,7 +375,7 @@ public class AdvancedConfig extends ConfigLoaderConfigurable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GENERAL */
|
/* GENERAL */
|
||||||
public int getStartingLevel() { return getIntValue("Skills.General.StartingLevel"); }
|
public int getStartingLevel() { return startingLevel; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns the maximum level at which superabilities will stop lengthening from scaling alongside skill level.
|
* This returns the maximum level at which superabilities will stop lengthening from scaling alongside skill level.
|
||||||
|
@ -3,6 +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 ninja.leaping.configurate.ConfigurationNode;
|
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.objectmapping.serialize.ConfigSerializable;
|
||||||
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||||
|
|
||||||
@ -37,6 +39,10 @@ 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 */
|
||||||
|
private ConfigurationLoader<CommentedConfigurationNode> configManager;
|
||||||
|
|
||||||
//TODO: Needed?
|
//TODO: Needed?
|
||||||
//private ConfigurationLoader<CommentedConfigurationNode> configManager;
|
//private ConfigurationLoader<CommentedConfigurationNode> configManager;
|
||||||
@ -105,6 +111,9 @@ 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();
|
||||||
}
|
}
|
||||||
@ -282,28 +291,23 @@ public abstract class ConfigLoaderConfigurable implements DefaultKeys {
|
|||||||
return userRootNode;
|
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)
|
int getIntValue(String path)
|
||||||
{
|
{
|
||||||
return userRootNode.getNode(path).getInt();
|
return userRootNode.getNode(path.split(".")).getInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
double getDoubleValue(String path)
|
double getDoubleValue(String path)
|
||||||
{
|
{
|
||||||
return userRootNode.getNode(path).getDouble();
|
return userRootNode.getNode(path.split(".")).getDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean getBooleanValue(String path)
|
boolean getBooleanValue(String path)
|
||||||
{
|
{
|
||||||
return userRootNode.getNode(path).getBoolean();
|
return userRootNode.getNode(path.split(".")).getBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getStringValue(String path)
|
String getStringValue(String path)
|
||||||
{
|
{
|
||||||
return userRootNode.getNode(path).getString();
|
return userRootNode.getNode(path.split(".")).getString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import ninja.leaping.configurate.objectmapping.Setting;
|
||||||
|
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
public class ConfigurableTest extends ConfigLoaderConfigurable {
|
public class ConfigurableTest extends ConfigLoaderConfigurable {
|
||||||
|
|
||||||
public final static String relativePath = "configurabletest.yml";
|
public final static String relativePath = "configurabletest.yml";
|
||||||
private static ConfigurableTest instance;
|
private static ConfigurableTest instance;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ConfigurableTest() {
|
public ConfigurableTest() {
|
||||||
super(mcMMO.p.getDataFolder(), relativePath);
|
super(mcMMO.p.getDataFolder(), relativePath);
|
||||||
|
|
||||||
|
mcMMO.p.getLogger().severe("The value of bone "+boneValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigurableTest getInstance() {
|
public static ConfigurableTest getInstance() {
|
||||||
@ -22,6 +25,9 @@ public class ConfigurableTest extends ConfigLoaderConfigurable {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Setting(value = "woof.bone", comment = "Finally we have found the value of bone")
|
||||||
|
double boneValue = 9.4447;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> validateKeys() {
|
public List<String> validateKeys() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -6,4 +6,4 @@ TheBidoofNotation:
|
|||||||
Woof:
|
Woof:
|
||||||
Bark:
|
Bark:
|
||||||
Meow: "Reeeee"
|
Meow: "Reeeee"
|
||||||
Bone: 8.3827
|
Bone: 9.4447
|
Loading…
Reference in New Issue
Block a user