mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-03 13:05:30 +02:00
Updates to config loading.
This commit is contained in:
@@ -389,274 +389,4 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
getCommand("mchud").setExecutor(new MchudCommand(this));
|
||||
}
|
||||
|
||||
/*
|
||||
* Boilerplate Custom Config Stuff (Treasures)
|
||||
*/
|
||||
|
||||
private FileConfiguration treasuresConfig = null;
|
||||
private File treasuresConfigFile = null;
|
||||
|
||||
/**
|
||||
* Reload the Treasures.yml file.
|
||||
*/
|
||||
public void reloadTreasuresConfig() {
|
||||
if (treasuresConfigFile == null) {
|
||||
treasuresConfigFile = new File(getDataFolder(), "treasures.yml");
|
||||
}
|
||||
|
||||
treasuresConfig = YamlConfiguration.loadConfiguration(treasuresConfigFile);
|
||||
|
||||
if (isInJar("treasures.yml")) {
|
||||
InputStream defConfigStream = getResource("treasures.yml");
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
treasuresConfig.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Treasures config information.
|
||||
*
|
||||
* @return the configuration object for treasures.yml
|
||||
*/
|
||||
public FileConfiguration getTreasuresConfig() {
|
||||
if (treasuresConfig == null) {
|
||||
reloadTreasuresConfig();
|
||||
}
|
||||
|
||||
return treasuresConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Treasures config informtion.
|
||||
*/
|
||||
public void saveTreasuresConfig() {
|
||||
if (treasuresConfig == null || treasuresConfigFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
treasuresConfig.save(treasuresConfigFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
getLogger().severe("Could not save config to " + treasuresConfigFile + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Boilerplate Custom Config Stuff (Tools)
|
||||
*/
|
||||
|
||||
private FileConfiguration toolsConfig = null;
|
||||
private File toolsConfigFile = null;
|
||||
|
||||
/**
|
||||
* Reload the Tools.yml file.
|
||||
*/
|
||||
public void reloadToolsConfig() {
|
||||
if (toolsConfigFile == null) {
|
||||
toolsConfigFile = new File(modDirectory, "tools.yml");
|
||||
}
|
||||
|
||||
toolsConfig = YamlConfiguration.loadConfiguration(toolsConfigFile);
|
||||
|
||||
if (isInJar("tools.yml")) {
|
||||
InputStream defConfigStream = getResource("tools.yml");
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
toolsConfig.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Tools config information.
|
||||
*
|
||||
* @return the configuration object for tools.yml
|
||||
*/
|
||||
public FileConfiguration getToolsConfig() {
|
||||
if (toolsConfig == null) {
|
||||
reloadToolsConfig();
|
||||
}
|
||||
|
||||
return toolsConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Tools config informtion.
|
||||
*/
|
||||
public void saveToolsConfig() {
|
||||
if (toolsConfig == null || toolsConfigFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
toolsConfig.save(toolsConfigFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
getLogger().severe("Could not save config to " + toolsConfigFile + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Boilerplate Custom Config Stuff (Armor)
|
||||
*/
|
||||
|
||||
private FileConfiguration armorConfig = null;
|
||||
private File armorConfigFile = null;
|
||||
|
||||
/**
|
||||
* Reload the Armor.yml file.
|
||||
*/
|
||||
public void reloadArmorConfig() {
|
||||
if (armorConfigFile == null) {
|
||||
armorConfigFile = new File(modDirectory, "armor.yml");
|
||||
}
|
||||
|
||||
armorConfig = YamlConfiguration.loadConfiguration(armorConfigFile);
|
||||
|
||||
if (isInJar("armor.yml")) {
|
||||
InputStream defConfigStream = getResource("armor.yml");
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
armorConfig.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Armor config information.
|
||||
*
|
||||
* @return the configuration object for armor.yml
|
||||
*/
|
||||
public FileConfiguration getArmorConfig() {
|
||||
if (armorConfig == null) {
|
||||
reloadArmorConfig();
|
||||
}
|
||||
|
||||
return armorConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Armor config informtion.
|
||||
*/
|
||||
public void saveArmorConfig() {
|
||||
if (armorConfig == null || armorConfigFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
armorConfig.save(armorConfigFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
getLogger().severe("Could not save config to " + armorConfigFile + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Boilerplate Custom Config Stuff (Blocks)
|
||||
*/
|
||||
|
||||
private FileConfiguration blocksConfig = null;
|
||||
private File blocksConfigFile = null;
|
||||
|
||||
/**
|
||||
* Reload the Blocks.yml file.
|
||||
*/
|
||||
public void reloadBlocksConfig() {
|
||||
if (blocksConfigFile == null) {
|
||||
blocksConfigFile = new File(modDirectory, "blocks.yml");
|
||||
}
|
||||
|
||||
blocksConfig = YamlConfiguration.loadConfiguration(blocksConfigFile);
|
||||
|
||||
if (isInJar("blocks.yml")) {
|
||||
InputStream defConfigStream = getResource("blocks.yml");
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
blocksConfig.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Blocks config information.
|
||||
*
|
||||
* @return the configuration object for blocks.yml
|
||||
*/
|
||||
public FileConfiguration getBlocksConfig() {
|
||||
if (blocksConfig == null) {
|
||||
reloadBlocksConfig();
|
||||
}
|
||||
|
||||
return blocksConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Blocks config informtion.
|
||||
*/
|
||||
public void saveBlocksConfig() {
|
||||
if (blocksConfig == null || blocksConfigFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
blocksConfig.save(blocksConfigFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
getLogger().severe("Could not save config to " + blocksConfigFile + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Boilerplate Custom Config Stuff (Spout)
|
||||
*/
|
||||
|
||||
private FileConfiguration spoutConfig = null;
|
||||
private File spoutConfigFile = null;
|
||||
|
||||
/**
|
||||
* Reload the Spout.yml file.
|
||||
*/
|
||||
public void reloadSpoutConfig() {
|
||||
if (spoutConfigFile == null) {
|
||||
spoutConfigFile = new File(modDirectory, "spout.yml");
|
||||
}
|
||||
|
||||
spoutConfig = YamlConfiguration.loadConfiguration(spoutConfigFile);
|
||||
|
||||
if (isInJar("spout.yml")) {
|
||||
InputStream defConfigStream = getResource("spout.yml");
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
spoutConfig.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Spout config information.
|
||||
*
|
||||
* @return the configuration object for spout.yml
|
||||
*/
|
||||
public FileConfiguration getSpoutConfig() {
|
||||
if (spoutConfig == null) {
|
||||
reloadSpoutConfig();
|
||||
}
|
||||
|
||||
return spoutConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Spout config informtion.
|
||||
*/
|
||||
public void saveSpoutConfig() {
|
||||
if (spoutConfig == null || spoutConfigFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
spoutConfig.save(spoutConfigFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
getLogger().severe("Could not save config to " + spoutConfigFile + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInJar(String resource) {
|
||||
InputStream iStream = getResource(resource);
|
||||
return iStream != null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user