ActuallyAdditions/src/main/java/ellpeck/actuallyadditions/config/ConfigurationHandler.java

52 lines
1.5 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
* This file ("ConfigurationHandler.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* <EFBFBD> 2015 Ellpeck
*/
2015-03-07 12:51:28 +01:00
package ellpeck.actuallyadditions.config;
2015-07-17 11:17:55 +02:00
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
2015-07-01 21:32:48 +02:00
import ellpeck.actuallyadditions.util.ModUtil;
2015-07-17 11:17:55 +02:00
import ellpeck.actuallyadditions.util.Util;
import net.minecraftforge.common.config.Configuration;
import java.io.File;
public class ConfigurationHandler{
2015-06-18 13:14:57 +02:00
public static final String ISSUES_WARNING = " [THIS COULD CAUSE ISSUES, CHANGE AT YOUR OWN RISK!]";
2015-07-17 11:17:55 +02:00
public static Configuration config;
public ConfigurationHandler(File configFile){
2015-07-01 21:32:48 +02:00
ModUtil.LOGGER.info("Grabbing Configurations...");
2015-07-17 11:17:55 +02:00
Util.registerEvent(this);
if(config == null){
config = new Configuration(configFile);
loadConfig();
}
2015-07-17 11:17:55 +02:00
}
private static void loadConfig(){
ConfigValues.defineConfigValues(config);
if(config.hasChanged()){
config.save();
}
2015-07-17 11:17:55 +02:00
}
2015-07-17 11:17:55 +02:00
@SubscribeEvent
public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event){
if (event.modID.equalsIgnoreCase(ModUtil.MOD_ID)){
loadConfig();
}
}
2015-03-30 15:08:19 +02:00
}