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

50 lines
1.4 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
2016-05-16 22:52:27 +02:00
* This file ("ConfigurationHandler.java") is part of the Actually Additions mod for Minecraft.
2015-08-29 14:33:25 +02:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.config;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
2016-07-03 20:57:00 +02:00
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
2016-01-07 18:20:59 +01:00
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.io.File;
public class ConfigurationHandler{
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...");
2016-07-03 20:57:00 +02:00
MinecraftForge.EVENT_BUS.register(this);
2015-07-17 11:17:55 +02:00
config = new Configuration(configFile);
config.load();
redefineConfigs();
2015-07-17 11:17:55 +02:00
}
private static void redefineConfigs(){
2015-07-17 11:17:55 +02:00
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){
2016-04-20 21:39:03 +02:00
if(event.getModID().equalsIgnoreCase(ModUtil.MOD_ID)){
redefineConfigs();
2015-07-17 11:17:55 +02:00
}
}
2015-03-30 15:08:19 +02:00
}