3
0
KCauldronX/src/main/java/kcauldron/KCauldronConfig.java

86 lines
3.0 KiB
Java
Raw Normal View History

2015-05-31 11:21:26 +00:00
package kcauldron;
import org.bukkit.configuration.file.YamlConfiguration;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.cauldron.configuration.BoolSetting;
import net.minecraftforge.cauldron.configuration.ConfigBase;
import net.minecraftforge.cauldron.configuration.Setting;
import net.minecraftforge.cauldron.configuration.StringSetting;
public class KCauldronConfig extends ConfigBase {
public BoolSetting commandEnable = new BoolSetting(this, "command.enable",
true, "Enable KCauldron command");
public BoolSetting updatecheckerEnable = new BoolSetting(this,
"updatechecker.enable", true, "Enable KCauldron update checker");
public BoolSetting updatecheckerDeleteOld = new BoolSetting(this,
"updatechecker.deleteOld", true, "Delete old version after update");
public StringSetting updatecheckerSymlinks = new StringSetting(this,
"updatechecker.symlinks", "", "(Re)create symlinks after update");
public BoolSetting updatecheckerAutoinstall = new BoolSetting(this,
"updatechecker.autoinstall", false, "Install updates without confirming");
2015-06-14 12:50:18 +00:00
public BoolSetting updatecheckerAutorestart = new BoolSetting(this,
"updatechecker.autorestart", false, "Restart server after updating without confirming (set restart script in spigot.yml)");
2015-05-31 11:21:26 +00:00
public BoolSetting updatecheckerQuite = new BoolSetting(this,
"updatechecker.quite", false, "Print less info during update");
public StringSetting updatecheckerInstallAs = new StringSetting(this,
"updatechecker.installAs", "", "Install new version with specified name");
public BoolSetting loggingMaterialInjection = new BoolSetting(this,
2015-06-14 12:50:18 +00:00
"logging.materialInjection", false, "Log material injection event");
2015-05-31 11:21:26 +00:00
public KCauldronConfig() {
super("kcauldron.yml", "kc");
register(commandEnable);
register(updatecheckerEnable);
register(updatecheckerDeleteOld);
register(updatecheckerSymlinks);
register(updatecheckerAutoinstall);
2015-06-14 12:50:18 +00:00
register(updatecheckerAutorestart);
2015-05-31 11:21:26 +00:00
register(updatecheckerQuite);
register(updatecheckerInstallAs);
register(loggingMaterialInjection);
2015-05-31 11:21:26 +00:00
load();
}
private void register(Setting<?> setting) {
settings.put(setting.path, setting);
}
@Override
public void registerCommands() {
if (commandEnable.getValue()) {
super.registerCommands();
}
}
@Override
protected void addCommands() {
commands.put(commandName, new KCauldronCommand());
}
@Override
protected void load() {
try {
config = YamlConfiguration.loadConfiguration(configFile);
String header = "";
for (Setting<?> toggle : settings.values()) {
if (!toggle.description.equals(""))
header += "Setting: " + toggle.path + " Default: "
+ toggle.def + " # " + toggle.description + "\n";
config.addDefault(toggle.path, toggle.def);
settings.get(toggle.path).setValue(
config.getString(toggle.path));
}
config.options().header(header);
config.options().copyDefaults(true);
save();
} catch (Exception ex) {
MinecraftServer.getServer().logSevere(
"Could not load " + this.configFile);
ex.printStackTrace();
}
}
}