use of ch.jalu.configme.SettingsManager in project AuthMeReloaded by AuthMe.
the class GenerateCommandsYml method executeDefault.
@Override
public void executeDefault() {
File file = new File(COMMANDS_YML_FILE);
// Get the default
CommandConfig commandConfig = CommandSettingsHolder.COMMANDS.getDefaultValue();
// Export the value to the file
SettingsManager settingsManager = SettingsManagerBuilder.withYamlFile(file).configurationData(CommandSettingsHolder.class).create();
settingsManager.setProperty(CommandSettingsHolder.COMMANDS, commandConfig);
settingsManager.save();
System.out.println("Updated " + COMMANDS_YML_FILE);
}
use of ch.jalu.configme.SettingsManager in project AuthMeReloaded by AuthMe.
the class CommandManager method reload.
@Override
public void reload() {
File file = new File(dataFolder, "commands.yml");
FileUtils.copyFileFromResource(file, "commands.yml");
SettingsManager settingsManager = SettingsManagerBuilder.withResource(YamlFileResourceProvider.loadFromFile(file)).configurationData(CommandSettingsHolder.class).migrationService(commandMigrationService).create();
CommandConfig commandConfig = settingsManager.getProperty(CommandSettingsHolder.COMMANDS);
onJoinCommands = newReplacer(commandConfig.getOnJoin());
onLoginCommands = newOnLoginCmdReplacer(commandConfig.getOnLogin());
onFirstLoginCommands = newOnLoginCmdReplacer(commandConfig.getOnFirstLogin());
onSessionLoginCommands = newReplacer(commandConfig.getOnSessionLogin());
onRegisterCommands = newReplacer(commandConfig.getOnRegister());
onUnregisterCommands = newReplacer(commandConfig.getOnUnregister());
onLogoutCommands = newReplacer(commandConfig.getOnLogout());
}
use of ch.jalu.configme.SettingsManager in project AuthMeReloaded by AuthMe.
the class UpdateConfigPageTask method executeDefault.
@Override
public void executeDefault() {
File config = null;
try {
// Create empty temporary .yml file and save the config to it
config = File.createTempFile("authme-config-", ".yml");
SettingsManager settingsManager = SettingsManagerBuilder.withYamlFile(config).configurationData(AuthMeSettingsRetriever.buildConfigurationData()).create();
settingsManager.save();
// Get the contents and generate template file
TagValueHolder tagValueHolder = TagValueHolder.create().put("config", FileIoUtils.readFromFile(config.toPath()));
FileIoUtils.generateFileFromTemplate(TEMPLATE_FILE, OUTPUT_FILE, tagValueHolder);
System.out.println("Wrote to '" + OUTPUT_FILE + "'");
} catch (IOException e) {
throw new IllegalStateException(e);
} finally {
FileUtils.delete(config);
}
}
Aggregations