use of io.github.wysohn.triggerreactor.bukkit.tools.migration.InvTriggerMigrationHelper in project TriggerReactor by wysohn.
the class AbstractJavaPlugin method migrateOldConfig.
private void migrateOldConfig() {
new ContinuingTasks.Builder().append(() -> {
if (core.getPluginConfigManager().isMigrationNeeded()) {
core.getPluginConfigManager().migrate(new NaiveMigrationHelper(getConfig(), new File(getDataFolder(), "config.yml")));
}
}).append(() -> {
if (core.getVariableManager().isMigrationNeeded()) {
File file = new File(getDataFolder(), "var.yml");
FileConfiguration conf = new Utf8YamlConfiguration();
try {
conf.load(file);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
core.getVariableManager().migrate(new NaiveMigrationHelper(conf, file));
}
}).append(() -> {
Optional.of(core.getInvManager()).map(AbstractTriggerManager::getTriggerInfos).ifPresent(triggerInfos -> Arrays.stream(triggerInfos).filter(TriggerInfo::isMigrationNeeded).forEach(triggerInfo -> {
File folder = triggerInfo.getSourceCodeFile().getParentFile();
File oldFile = new File(folder, triggerInfo.getTriggerName() + ".yml");
FileConfiguration oldFileConfig = YamlConfiguration.loadConfiguration(oldFile);
triggerInfo.migrate(new InvTriggerMigrationHelper(oldFile, oldFileConfig));
}));
}).append(() -> {
Manager.getManagers().stream().filter(AbstractTriggerManager.class::isInstance).map(AbstractTriggerManager.class::cast).map(AbstractTriggerManager::getTriggerInfos).forEach(triggerInfos -> Arrays.stream(triggerInfos).filter(TriggerInfo::isMigrationNeeded).forEach(triggerInfo -> {
File folder = triggerInfo.getSourceCodeFile().getParentFile();
File oldFile = new File(folder, triggerInfo.getTriggerName() + ".yml");
FileConfiguration oldFileConfig = YamlConfiguration.loadConfiguration(oldFile);
triggerInfo.migrate(new NaiveMigrationHelper(oldFileConfig, oldFile));
}));
}).run();
}
Aggregations