2014-02-03 20:48:43 +01:00
|
|
|
package com.gmail.nossr50.config.mods;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import com.gmail.nossr50.util.ModManager;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
public class ToolConfigManager {
|
|
|
|
public ToolConfigManager(mcMMO plugin) {
|
2014-02-04 13:53:54 +01:00
|
|
|
Pattern middlePattern = Pattern.compile("tools\\.(?:.+)\\.yml");
|
|
|
|
Pattern startPattern = Pattern.compile("(?:.+)\\.tools\\.yml");
|
2014-02-03 20:48:43 +01:00
|
|
|
File dataFolder = new File(mcMMO.getModDirectory());
|
|
|
|
File vanilla = new File(dataFolder, "tools.default.yml");
|
|
|
|
ModManager modManager = mcMMO.getModManager();
|
|
|
|
|
|
|
|
if (!vanilla.exists()) {
|
|
|
|
plugin.saveResource(plugin.getDataFolder().getName() + File.separator + "tools.default.yml", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (String fileName : dataFolder.list()) {
|
2014-02-04 13:53:54 +01:00
|
|
|
if (!middlePattern.matcher(fileName).matches() && !startPattern.matcher(fileName).matches()) {
|
2014-02-03 20:48:43 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
File file = new File(dataFolder, fileName);
|
|
|
|
|
|
|
|
if (file.isDirectory()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
modManager.registerCustomTools(new CustomToolConfig(fileName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|