package net.mc_pandacraft.java.plugin.pandacraftutils.config;

import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import net.mc_pandacraft.java.plugin.pandacraftutils.config.elements.MultiCommandConfigEntry;

public class MultiCommandConfig extends AbstractConfig {
	
	private final Map<String, MultiCommandConfigEntry> config;
	
	public MultiCommandConfig() throws Exception {
		super("multicommands", FileType.DIR);
		
		List<File> files = getFileList();
		
		config = new HashMap<String, MultiCommandConfigEntry>();
		
		for (File f : files) {
			
			String name = f.getName().split("\\.")[0];
			
			if (name == null || name.trim().equals(""))
			{
				warning("nom de fichier '"+f.getName()+"' invalide");
				continue;
			}
			
			List<String> lines = getFileLines(true, true, false, f);
			
			
			
			config.put(name, new MultiCommandConfigEntry(name, lines));
			
		}
		
		
		
		
	}
	
	public Set<String> getList() {
		return Collections.unmodifiableSet(config.keySet());
	}
	
	public MultiCommandConfigEntry getEntry(String name) {
		return config.get(name);
	}
	
}
