use of org.terasology.engine.config.ModuleConfig in project Terasology by MovingBlocks.
the class NewGameScreen method setSelectedGameplayModule.
private void setSelectedGameplayModule(Module module) {
ModuleConfig moduleConfig = config.getDefaultModSelection();
if (moduleConfig.getDefaultGameplayModuleName().equals(module.getId().toString())) {
// same as before -> we're done
return;
}
moduleConfig.setDefaultGameplayModuleName(module.getId().toString());
moduleConfig.clear();
moduleConfig.addModule(module.getId());
// Set the default generator of the selected gameplay module
setDefaultGeneratorOfGameplayModule(module);
config.save();
}
use of org.terasology.engine.config.ModuleConfig in project Terasology by MovingBlocks.
the class AdvancedGameSetupScreen method saveConfiguration.
private void saveConfiguration() {
// moduleConfig passes the module collection to other screens
ModuleConfig moduleConfig = config.getDefaultModSelection();
moduleConfig.clear();
// Fetch all the selected/activated modules using allSortedModules
// instead of fetching only selected/activated modules from filtered collection
// of modules using sortedModules
allSortedModules.stream().filter(info -> info.isSelected() && info.isExplicitSelection()).forEach(info -> moduleConfig.addModule(info.getMetadata().getId()));
SimpleUri defaultGenerator = config.getWorldGeneration().getDefaultGenerator();
ModuleSelectionInfo info = modulesLookup.get(defaultGenerator.getModuleName());
if (info != null && !info.isSelected()) {
config.getWorldGeneration().setDefaultGenerator(new SimpleUri());
}
worldGenManager.refresh();
config.save();
}
Aggregations