mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Configs rework, fixed mod config files not loading, fixed comment blocks not being copied
This commit is contained in:
parent
5ee440d9a5
commit
b80a29ca04
@ -5,21 +5,26 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
|
|
||||||
public class Config extends ConfigLoader {
|
public class Config extends ConfigLoader {
|
||||||
public int xpGainMultiplier = 1;
|
|
||||||
private static Config instance;
|
private static Config instance;
|
||||||
|
public int xpGainMultiplier = 1;
|
||||||
|
|
||||||
|
private Config() {
|
||||||
|
super("config.yml");
|
||||||
|
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
||||||
|
}
|
||||||
|
|
||||||
public static Config getInstance() {
|
public static Config getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new Config(mcMMO.p);
|
instance = new Config();
|
||||||
instance.load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadKeys() {}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GENERAL SETTINGS
|
* GENERAL SETTINGS
|
||||||
*/
|
*/
|
||||||
@ -370,19 +375,4 @@ public class Config extends ConfigLoader {
|
|||||||
public double getFormulaMultiplierAxes() { return config.getDouble("Experience.Formula.Multiplier.Axes", 1.0); }
|
public double getFormulaMultiplierAxes() { return config.getDouble("Experience.Formula.Multiplier.Axes", 1.0); }
|
||||||
public double getFormulaMultiplierAcrobatics() { return config.getDouble("Experience.Formula.Multiplier.Acrobatics", 1.0); }
|
public double getFormulaMultiplierAcrobatics() { return config.getDouble("Experience.Formula.Multiplier.Acrobatics", 1.0); }
|
||||||
public double getFormulaMultiplierFishing() { return config.getDouble("Experience.Formula.Multiplier.Fishing", 1.0); }
|
public double getFormulaMultiplierFishing() { return config.getDouble("Experience.Formula.Multiplier.Fishing", 1.0); }
|
||||||
|
|
||||||
/*
|
|
||||||
* CONFIG LOADING
|
|
||||||
*/
|
|
||||||
|
|
||||||
private Config(mcMMO plugin) {
|
|
||||||
super(plugin, "config.yml");
|
|
||||||
saveIfNotExist();
|
|
||||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadKeys() {
|
|
||||||
plugin.getLogger().info("Loading mcMMO config.yml File...");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -9,69 +11,69 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
public abstract class ConfigLoader {
|
public abstract class ConfigLoader {
|
||||||
|
protected static final mcMMO plugin = mcMMO.p;
|
||||||
protected String fileName;
|
protected String fileName;
|
||||||
protected File configFile;
|
protected File configFile;
|
||||||
protected File dataFolder;
|
|
||||||
protected final mcMMO plugin;
|
|
||||||
protected FileConfiguration config;
|
protected FileConfiguration config;
|
||||||
|
|
||||||
public ConfigLoader(mcMMO plugin, String fileName){
|
public ConfigLoader(String relativePath, String fileName){
|
||||||
this.plugin = plugin;
|
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
dataFolder = plugin.getDataFolder();
|
configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName);
|
||||||
configFile = new File(dataFolder, File.separator + fileName);
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigLoader(String fileName){
|
||||||
|
this.fileName = fileName;
|
||||||
|
configFile = new File(plugin.getDataFolder(), fileName);
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void load() {
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
plugin.getLogger().info("Creating mcMMO " + fileName + " File...");
|
||||||
|
createFile();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugin.getLogger().info("Loading mcMMO " + fileName + " File...");
|
||||||
|
}
|
||||||
|
|
||||||
config = YamlConfiguration.loadConfiguration(configFile);
|
config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load this config file.
|
|
||||||
*/
|
|
||||||
public void load() {
|
|
||||||
if (!configFile.exists()) {
|
|
||||||
dataFolder.mkdir();
|
|
||||||
saveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
addDefaults();
|
|
||||||
loadKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save this config file.
|
|
||||||
*/
|
|
||||||
private void saveConfig() {
|
|
||||||
try {
|
|
||||||
config.save(configFile);
|
|
||||||
}
|
|
||||||
catch (IOException ex) {
|
|
||||||
plugin.getLogger().severe("Could not save config to " + configFile + ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void saveIfNotExist() {
|
|
||||||
if (!configFile.exists()) {
|
|
||||||
if (plugin.getResource(fileName) != null) {
|
|
||||||
plugin.saveResource(fileName, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rereadFromDisk();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void rereadFromDisk() {
|
|
||||||
config = YamlConfiguration.loadConfiguration(configFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the defaults to this config file.
|
|
||||||
*/
|
|
||||||
protected void addDefaults() {
|
|
||||||
config.options().copyDefaults(true);
|
|
||||||
saveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the keys from this config file.
|
|
||||||
*/
|
|
||||||
protected abstract void loadKeys();
|
protected abstract void loadKeys();
|
||||||
|
|
||||||
|
protected void createFile() {
|
||||||
|
if (configFile.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
configFile.getParentFile().mkdirs();
|
||||||
|
|
||||||
|
InputStream inputStream = plugin.getResource(fileName);
|
||||||
|
|
||||||
|
if (inputStream != null) {
|
||||||
|
try {
|
||||||
|
copyStreamToFile(inputStream, configFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugin.getLogger().severe("Missing ressource file: '" + configFile.getName() + "' please notify the plugin authors");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void copyStreamToFile(InputStream inputStream, File file) throws Exception {
|
||||||
|
OutputStream outputStream = new FileOutputStream(file);
|
||||||
|
|
||||||
|
int read = 0;
|
||||||
|
byte[] bytes = new byte[1024];
|
||||||
|
|
||||||
|
while ((read = inputStream.read(bytes)) != -1) {
|
||||||
|
outputStream.write(bytes, 0, read);
|
||||||
|
}
|
||||||
|
|
||||||
|
inputStream.close();
|
||||||
|
outputStream.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,41 +4,31 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
public class HiddenConfig extends ConfigLoader {
|
public class HiddenConfig {
|
||||||
private static String fileName;
|
|
||||||
private static HiddenConfig instance;
|
private static HiddenConfig instance;
|
||||||
|
private static String fileName;
|
||||||
private static YamlConfiguration config;
|
private static YamlConfiguration config;
|
||||||
|
|
||||||
private static boolean chunkletsEnabled;
|
private static boolean chunkletsEnabled;
|
||||||
|
|
||||||
public HiddenConfig(mcMMO plugin, String fileName) {
|
public HiddenConfig(String fileName) {
|
||||||
super(plugin, fileName);
|
|
||||||
HiddenConfig.fileName = fileName;
|
HiddenConfig.fileName = fileName;
|
||||||
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static HiddenConfig getInstance() {
|
public static HiddenConfig getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new HiddenConfig(mcMMO.p, "hidden.yml");
|
instance = new HiddenConfig("hidden.yml");
|
||||||
instance.load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
public void load() {
|
||||||
if (plugin.getResource(fileName) != null) {
|
if (mcMMO.p.getResource(fileName) != null) {
|
||||||
loadKeys();
|
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadKeys() {
|
|
||||||
config = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
|
|
||||||
|
|
||||||
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getChunkletsEnabled() {
|
public boolean getChunkletsEnabled() {
|
||||||
return chunkletsEnabled;
|
return chunkletsEnabled;
|
||||||
|
@ -1,25 +1,38 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.datatypes.HudType;
|
import com.gmail.nossr50.datatypes.HudType;
|
||||||
|
|
||||||
public class SpoutConfig extends ConfigLoader {
|
public class SpoutConfig extends ConfigLoader {
|
||||||
private static SpoutConfig instance;
|
private static SpoutConfig instance;
|
||||||
|
public HudType defaultHudType;
|
||||||
|
|
||||||
|
private SpoutConfig() {
|
||||||
|
super("spout.yml");
|
||||||
|
}
|
||||||
|
|
||||||
public static SpoutConfig getInstance() {
|
public static SpoutConfig getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new SpoutConfig(mcMMO.p);
|
instance = new SpoutConfig();
|
||||||
instance.load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HudType defaultHudType;
|
@Override
|
||||||
|
protected void loadKeys() {
|
||||||
|
// Setup default HUD
|
||||||
|
String temp = config.getString("Spout.HUD.Default", "STANDARD");
|
||||||
|
|
||||||
private SpoutConfig(mcMMO plugin) {
|
for (HudType hudType : HudType.values()) {
|
||||||
super(plugin, "spout.yml");
|
if (hudType.toString().equalsIgnoreCase(temp.toString())) {
|
||||||
saveIfNotExist();
|
defaultHudType = hudType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defaultHudType == null) {
|
||||||
|
defaultHudType = HudType.STANDARD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
||||||
@ -77,23 +90,4 @@ public class SpoutConfig extends ConfigLoader {
|
|||||||
public double getRetroHUDFishingRed() { return config.getDouble("HUD.Retro.Colors.Fishing.RED", 0.3); }
|
public double getRetroHUDFishingRed() { return config.getDouble("HUD.Retro.Colors.Fishing.RED", 0.3); }
|
||||||
public double getRetroHUDFishingGreen() { return config.getDouble("HUD.Retro.Colors.Fishing.GREEN", 0.3); }
|
public double getRetroHUDFishingGreen() { return config.getDouble("HUD.Retro.Colors.Fishing.GREEN", 0.3); }
|
||||||
public double getRetroHUDFishingBlue() { return config.getDouble("HUD.Retro.Colors.Fishing.BLUE", 0.75); }
|
public double getRetroHUDFishingBlue() { return config.getDouble("HUD.Retro.Colors.Fishing.BLUE", 0.75); }
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadKeys() {
|
|
||||||
plugin.getLogger().info("Loading mcMMO spout.yml File...");
|
|
||||||
|
|
||||||
// Setup default HUD
|
|
||||||
String temp = config.getString("Spout.HUD.Default", "STANDARD");
|
|
||||||
|
|
||||||
for (HudType hudType : HudType.values()) {
|
|
||||||
if (hudType.toString().equalsIgnoreCase(temp.toString())) {
|
|
||||||
defaultHudType = hudType;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defaultHudType == null) {
|
|
||||||
defaultHudType = HudType.STANDARD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,23 +11,12 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||||
|
|
||||||
public class TreasuresConfig extends ConfigLoader{
|
public class TreasuresConfig extends ConfigLoader{
|
||||||
private static TreasuresConfig instance;
|
private static TreasuresConfig instance;
|
||||||
|
|
||||||
public static TreasuresConfig getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new TreasuresConfig(mcMMO.p);
|
|
||||||
instance.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
||||||
@ -41,15 +30,20 @@ public class TreasuresConfig extends ConfigLoader{
|
|||||||
public List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
|
public List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
|
||||||
public List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
|
public List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
|
||||||
|
|
||||||
private TreasuresConfig(mcMMO plugin) {
|
private TreasuresConfig() {
|
||||||
super(plugin, "treasures.yml");
|
super("treasures.yml");
|
||||||
saveIfNotExist();
|
}
|
||||||
|
|
||||||
|
public static TreasuresConfig getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new TreasuresConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
plugin.getLogger().info("Loading mcMMO treasures.yml File...");
|
|
||||||
|
|
||||||
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
||||||
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
||||||
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
||||||
|
@ -8,40 +8,36 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||||
import com.gmail.nossr50.skills.repair.Repairable;
|
import com.gmail.nossr50.skills.repair.Repairable;
|
||||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||||
|
|
||||||
public class CustomArmorConfig extends ModConfigLoader{
|
public class CustomArmorConfig extends ConfigLoader{
|
||||||
private static CustomArmorConfig instance;
|
private static CustomArmorConfig instance;
|
||||||
|
private List<Repairable> repairables;
|
||||||
|
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
||||||
|
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
||||||
|
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
||||||
|
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
||||||
|
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||||
|
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
||||||
|
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
||||||
|
|
||||||
|
public CustomArmorConfig() {
|
||||||
|
super("ModConfigs", "armor.yml");
|
||||||
|
}
|
||||||
|
|
||||||
public static CustomArmorConfig getInstance() {
|
public static CustomArmorConfig getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new CustomArmorConfig(mcMMO.p);
|
instance = new CustomArmorConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Repairable> repairables;
|
|
||||||
|
|
||||||
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
|
||||||
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
|
||||||
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
|
||||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
|
||||||
|
|
||||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
|
||||||
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
|
||||||
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
|
||||||
|
|
||||||
public CustomArmorConfig(mcMMO plugin) {
|
|
||||||
super(plugin, "armor.yml");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
plugin.getLogger().info("Loading mcMMO armor.yml File...");
|
|
||||||
repairables = new ArrayList<Repairable>();
|
repairables = new ArrayList<Repairable>();
|
||||||
|
|
||||||
loadArmor("Boots", customBootIDs);
|
loadArmor("Boots", customBootIDs);
|
||||||
|
@ -8,41 +8,36 @@ import java.util.Set;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
|
|
||||||
public class CustomBlocksConfig extends ModConfigLoader{
|
public class CustomBlocksConfig extends ConfigLoader {
|
||||||
private static CustomBlocksConfig instance;
|
private static CustomBlocksConfig instance;
|
||||||
|
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
||||||
|
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
||||||
|
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
||||||
|
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
|
||||||
|
public List<ItemStack> customOres = new ArrayList<ItemStack>();
|
||||||
|
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
|
||||||
|
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
|
||||||
|
public List<ItemStack> customAbilityBlocks = new ArrayList<ItemStack>();
|
||||||
|
public List<ItemStack> customItems = new ArrayList<ItemStack>();
|
||||||
|
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
|
||||||
|
|
||||||
|
public CustomBlocksConfig() {
|
||||||
|
super("ModConfigs", "blocks.yml");
|
||||||
|
}
|
||||||
|
|
||||||
public static CustomBlocksConfig getInstance() {
|
public static CustomBlocksConfig getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new CustomBlocksConfig(mcMMO.p);
|
instance = new CustomBlocksConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
|
|
||||||
|
|
||||||
public List<ItemStack> customOres = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
|
|
||||||
public List<ItemStack> customAbilityBlocks = new ArrayList<ItemStack>();
|
|
||||||
|
|
||||||
public List<ItemStack> customItems = new ArrayList<ItemStack>();
|
|
||||||
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
|
|
||||||
|
|
||||||
public CustomBlocksConfig(mcMMO plugin) {
|
|
||||||
super(plugin, "blocks.yml");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
plugin.getLogger().info("Loading mcMMO blocks.yml File...");
|
|
||||||
|
|
||||||
loadBlocks("Excavation", customExcavationBlocks);
|
loadBlocks("Excavation", customExcavationBlocks);
|
||||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||||
loadBlocks("Mining", customMiningBlocks);
|
loadBlocks("Mining", customMiningBlocks);
|
||||||
|
@ -8,42 +8,38 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||||
import com.gmail.nossr50.skills.repair.Repairable;
|
import com.gmail.nossr50.skills.repair.Repairable;
|
||||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||||
|
|
||||||
public class CustomToolsConfig extends ModConfigLoader {
|
public class CustomToolsConfig extends ConfigLoader {
|
||||||
private static CustomToolsConfig instance;
|
private static CustomToolsConfig instance;
|
||||||
|
|
||||||
public static CustomToolsConfig getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new CustomToolsConfig(mcMMO.p);
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Repairable> repairables;
|
private List<Repairable> repairables;
|
||||||
|
|
||||||
public List<Integer> customAxeIDs = new ArrayList<Integer>();
|
public List<Integer> customAxeIDs = new ArrayList<Integer>();
|
||||||
public List<Integer> customBowIDs = new ArrayList<Integer>();
|
public List<Integer> customBowIDs = new ArrayList<Integer>();
|
||||||
public List<Integer> customHoeIDs = new ArrayList<Integer>();
|
public List<Integer> customHoeIDs = new ArrayList<Integer>();
|
||||||
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
|
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
|
||||||
public List<Integer> customShovelIDs = new ArrayList<Integer>();
|
public List<Integer> customShovelIDs = new ArrayList<Integer>();
|
||||||
public List<Integer> customSwordIDs = new ArrayList<Integer>();
|
public List<Integer> customSwordIDs = new ArrayList<Integer>();
|
||||||
|
|
||||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||||
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
|
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
|
||||||
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
|
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
|
||||||
|
|
||||||
private CustomToolsConfig(mcMMO plugin) {
|
private CustomToolsConfig() {
|
||||||
super(plugin, "tools.yml");
|
super("ModConfigs", "tools.yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CustomToolsConfig getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new CustomToolsConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
plugin.getLogger().info("Loading mcMMO tools.yml File...");
|
|
||||||
repairables = new ArrayList<Repairable>();
|
repairables = new ArrayList<Repairable>();
|
||||||
|
|
||||||
loadTool("Axes", customAxeIDs);
|
loadTool("Axes", customAxeIDs);
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
package com.gmail.nossr50.config.mods;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
|
||||||
|
|
||||||
public abstract class ModConfigLoader extends ConfigLoader{
|
|
||||||
|
|
||||||
public ModConfigLoader(mcMMO plugin, String fileName) {
|
|
||||||
super(plugin, "ModConfigs" + File.separator + fileName);
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,6 @@ import java.util.Set;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.skills.repair.RepairItemType;
|
import com.gmail.nossr50.skills.repair.RepairItemType;
|
||||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||||
@ -17,16 +16,11 @@ import com.gmail.nossr50.skills.repair.RepairableFactory;
|
|||||||
public class RepairConfig extends ConfigLoader {
|
public class RepairConfig extends ConfigLoader {
|
||||||
private List<Repairable> repairables;
|
private List<Repairable> repairables;
|
||||||
|
|
||||||
public RepairConfig(mcMMO plugin, String fileName) {
|
public RepairConfig(String fileName) {
|
||||||
super(plugin, fileName);
|
super(fileName);
|
||||||
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
loadKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
repairables = new ArrayList<Repairable>();
|
repairables = new ArrayList<Repairable>();
|
||||||
|
@ -22,22 +22,18 @@ public class RepairConfigManager {
|
|||||||
plugin.saveResource("repair.vanilla.yml", false);
|
plugin.saveResource("repair.vanilla.yml", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String location : dataFolder.list()) {
|
for (String fileName : dataFolder.list()) {
|
||||||
if (!pattern.matcher(location).matches()) {
|
if (!pattern.matcher(fileName).matches()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getLogger().info("Loading " + location + " repair config file...");
|
File file = new File(dataFolder, fileName);
|
||||||
|
|
||||||
File file = new File(dataFolder, location);
|
|
||||||
|
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RepairConfig rConfig = new RepairConfig(plugin, location);
|
RepairConfig rConfig = new RepairConfig(fileName);
|
||||||
rConfig.load();
|
|
||||||
|
|
||||||
List<Repairable> rConfigRepairables = rConfig.getLoadedRepairables();
|
List<Repairable> rConfigRepairables = rConfig.getLoadedRepairables();
|
||||||
|
|
||||||
if (rConfigRepairables != null) {
|
if (rConfigRepairables != null) {
|
||||||
|
@ -127,17 +127,15 @@ public class mcMMO extends JavaPlugin {
|
|||||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||||
|
|
||||||
if (configInstance.getToolModsEnabled()) {
|
if (configInstance.getToolModsEnabled()) {
|
||||||
CustomToolsConfig.getInstance().load();
|
|
||||||
repairables.addAll(CustomToolsConfig.getInstance().getLoadedRepairables());
|
repairables.addAll(CustomToolsConfig.getInstance().getLoadedRepairables());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configInstance.getArmorModsEnabled()) {
|
if (configInstance.getArmorModsEnabled()) {
|
||||||
CustomArmorConfig.getInstance().load();
|
|
||||||
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
|
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configInstance.getBlockModsEnabled()) {
|
if (configInstance.getBlockModsEnabled()) {
|
||||||
CustomBlocksConfig.getInstance().load();
|
CustomBlocksConfig.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load repair configs, make manager, and register them at this time
|
//Load repair configs, make manager, and register them at this time
|
||||||
|
Loading…
Reference in New Issue
Block a user