package com.gmail.nossr50.config; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.repair.Repairable; public class RepairConfigManager { private List repairables; public RepairConfigManager(mcMMO plugin) { repairables = new ArrayList(); Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml"); File dataFolder = plugin.getDataFolder(); File vanilla = new File(dataFolder, "repair.vanilla.yml"); if (!vanilla.exists()) { plugin.saveResource("repair.vanilla.yml", false); } for (String location : dataFolder.list()) { if (!pattern.matcher(location).matches()) { continue; } plugin.getLogger().info("Loading " + location + " repair config file..."); File file = new File(dataFolder, location); if (file.isDirectory()) { continue; } RepairConfig rConfig = new RepairConfig(plugin, location); rConfig.load(); List rConfigRepairables = rConfig.getLoadedRepairables(); if (rConfigRepairables != null) { repairables.addAll(rConfigRepairables); } } } public List getLoadedRepairables() { if (repairables == null) { return new ArrayList(); } return repairables; } }