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

40 lines
1.1 KiB
Java
Raw Normal View History

2020-09-09 16:49:01 +02:00
package de.ellpeck.actuallyadditions.common.config;
2019-05-02 09:10:29 +02:00
import java.io.File;
2020-09-09 16:49:01 +02:00
import de.ellpeck.actuallyadditions.common.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;
2019-05-02 09:10:29 +02:00
public class ConfigurationHandler {
2015-07-17 11:17:55 +02:00
public static Configuration config;
2019-05-02 09:10:29 +02:00
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
}
2019-05-02 09:10:29 +02:00
public static void redefineConfigs() {
2015-07-17 11:17:55 +02:00
ConfigValues.defineConfigValues(config);
2019-05-02 09:10:29 +02:00
if (config.hasChanged()) {
2015-07-17 11:17:55 +02:00
config.save();
}
2015-07-17 11:17:55 +02:00
}
2015-07-17 11:17:55 +02:00
@SubscribeEvent
2019-05-02 09:10:29 +02:00
public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equalsIgnoreCase(ActuallyAdditions.MODID)) {
redefineConfigs();
2015-07-17 11:17:55 +02:00
}
}
2015-03-30 15:08:19 +02:00
}