-
Notifications
You must be signed in to change notification settings - Fork 11
/
ConfigurationHandler.java
38 lines (31 loc) · 1.38 KB
/
ConfigurationHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.girafi.waddles.utils;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.io.File;
public class ConfigurationHandler {
public static Configuration config;
public static final String CATEGORY_PENGUIN_SPAWNS = "spawn chances";
public static boolean dropFish;
public static boolean dropExp;
public static void init(File configFile) {
if (config == null) {
config = new Configuration(configFile);
loadConfiguration();
}
}
private static void loadConfiguration() {
config.addCustomCategoryComment(CATEGORY_PENGUIN_SPAWNS, "Configure penguins spawn weight & min/max group size. Set weight to 0 to disable.");
dropFish = config.get(Configuration.CATEGORY_GENERAL, "Enable that penguins drop fish (0 - 2 Raw fish)", false).getBoolean(false);
dropExp = config.get(Configuration.CATEGORY_GENERAL, "Penguins should drop experience?", true).getBoolean(true);
if (config.hasChanged()) {
config.save();
}
}
@SubscribeEvent
public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equalsIgnoreCase(Reference.MOD_ID)) {
loadConfiguration();
}
}
}