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
*
2017-01-01 16:23:26 +01:00
* © 2015-2017 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.config;
2018-05-10 11:38:58 +02:00
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
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){
2018-05-10 11:38:58 +02:00
ActuallyAdditions.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
}
public 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){
2018-05-10 11:38:58 +02:00
if(event.getModID().equalsIgnoreCase(ActuallyAdditions.MODID)){
redefineConfigs();
2015-07-17 11:17:55 +02:00
}
}
2015-03-30 15:08:19 +02:00
}