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;
|
2015-02-09 17:25:05 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
import java.io.File;
|
|
|
|
|
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;
|
2015-02-09 17:25:05 +01:00
|
|
|
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;
|
2015-02-09 17:25:05 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class ConfigurationHandler {
|
2015-02-09 17:25:05 +01:00
|
|
|
|
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...");
|
2015-02-09 17:25:05 +01:00
|
|
|
|
2016-07-03 20:57:00 +02:00
|
|
|
MinecraftForge.EVENT_BUS.register(this);
|
2015-07-17 11:17:55 +02:00
|
|
|
|
2016-06-05 12:15:02 +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-02-09 17:25:05 +01:00
|
|
|
}
|
2015-07-17 11:17:55 +02:00
|
|
|
}
|
2015-02-09 17:25:05 +01: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)) {
|
2016-06-05 12:15:02 +02:00
|
|
|
redefineConfigs();
|
2015-07-17 11:17:55 +02:00
|
|
|
}
|
2015-02-09 17:25:05 +01:00
|
|
|
}
|
2015-03-30 15:08:19 +02:00
|
|
|
}
|