2021-11-03 16:42:12 +01:00
|
|
|
package com.myname.mymodid;
|
|
|
|
|
|
2022-06-23 20:53:03 +01:00
|
|
|
import java.io.File;
|
2021-11-03 16:42:12 +01:00
|
|
|
import net.minecraftforge.common.config.Configuration;
|
|
|
|
|
import net.minecraftforge.common.config.Property;
|
|
|
|
|
|
|
|
|
|
public class Config {
|
2022-02-14 15:44:40 -06:00
|
|
|
|
2021-11-03 16:42:12 +01:00
|
|
|
private static class Defaults {
|
|
|
|
|
public static final String greeting = "Hello World";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class Categories {
|
|
|
|
|
public static final String general = "general";
|
|
|
|
|
}
|
2022-02-14 15:44:40 -06:00
|
|
|
|
2021-11-03 16:42:12 +01:00
|
|
|
public static String greeting = Defaults.greeting;
|
|
|
|
|
|
|
|
|
|
public static void syncronizeConfiguration(File configFile) {
|
|
|
|
|
Configuration configuration = new Configuration(configFile);
|
|
|
|
|
configuration.load();
|
2022-02-14 15:44:40 -06:00
|
|
|
|
2022-06-23 20:53:03 +01:00
|
|
|
Property greetingProperty =
|
|
|
|
|
configuration.get(Categories.general, "greeting", Defaults.greeting, "How shall I greet?");
|
2021-11-03 16:42:12 +01:00
|
|
|
greeting = greetingProperty.getString();
|
|
|
|
|
|
2022-06-23 20:53:03 +01:00
|
|
|
if (configuration.hasChanged()) {
|
2021-11-03 16:42:12 +01:00
|
|
|
configuration.save();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-23 20:53:03 +01:00
|
|
|
}
|