package com.pahimar.ee.reference;
import com.pahimar.ee.EquivalentExchange;
import com.pahimar.ee.blacklist.BlacklistRegistry;
import com.pahimar.ee.exchange.EnergyValueRegistry;
import com.pahimar.ee.knowledge.PlayerKnowledgeRegistry;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import java.io.File;
public class Files {
private static File globalDataDirectory;
public static File globalTestDirectory;
public static File playerDataDirectory;
private static final String ENERGY_VALUES_JSON_FILENAME = "energy-values.json";
private static final String PRE_CALCULATION_ENERGY_VALUES_FILENAME = "pre-calculation-energy-values.json";
private static final String POST_CALCULATION_ENERGY_VALUES_FILENAME = "post-calculation-energy-values.json";
public static final String TEMPLATE_PLAYER_KNOWLEDGE_FILENAME = "template-player-knowledge.json";
public static final String KNOWLEDGE_BLACKLIST_FILENAME = "knowledge-blacklist.json";
public static final String EXCHANGE_BLACKLIST_FILENAME = "exchange-blacklist.json";
public static void init(FMLPreInitializationEvent event) {
globalDataDirectory = new File(event.getModConfigurationDirectory().getParentFile(), "data" + File.separator + EquivalentExchange.MOD_ID);
globalTestDirectory = new File(globalDataDirectory, "tests");
globalTestDirectory.mkdirs();
EnergyValueRegistry.energyValuesDirectory = new File(globalDataDirectory, "energy-values");
EnergyValueRegistry.energyValuesDirectory.mkdirs();
EnergyValueRegistry.energyValuesFile = new File(EnergyValueRegistry.energyValuesDirectory, ENERGY_VALUES_JSON_FILENAME);
EnergyValueRegistry.preCalculationValuesFile = new File(EnergyValueRegistry.energyValuesDirectory, PRE_CALCULATION_ENERGY_VALUES_FILENAME);
EnergyValueRegistry.postCalculationValuesFile = new File(EnergyValueRegistry.energyValuesDirectory, POST_CALCULATION_ENERGY_VALUES_FILENAME);
File templatePlayerKnowledgeDirectory = new File(globalDataDirectory, "knowledge" + File.separator + "transmutation");
templatePlayerKnowledgeDirectory.mkdirs();
PlayerKnowledgeRegistry.templatePlayerKnowledgeFile = new File(templatePlayerKnowledgeDirectory, TEMPLATE_PLAYER_KNOWLEDGE_FILENAME);
BlacklistRegistry.knowledgeBlacklistFile = new File(globalDataDirectory, "blacklist" + File.separator + KNOWLEDGE_BLACKLIST_FILENAME);
BlacklistRegistry.exchangeBlacklistFile = new File(globalDataDirectory, "blacklist" + File.separator + EXCHANGE_BLACKLIST_FILENAME);
}
/**
* Updates the references to the instance specific EE data directories, creating them if they don't already exist
*/
public static void updateFileReferences() {
playerDataDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "playerdata" + File.separator + EquivalentExchange.MOD_ID);
playerDataDirectory.mkdirs();
}
}