use of org.terasology.utilities.download.MultiFileDownloader in project Terasology by MovingBlocks.
the class ModuleInstaller method call.
@Override
public List<Module> call() throws Exception {
Map<URL, Path> filesToDownload = getDownloadUrls(moduleList);
logger.info("Started downloading {} modules", filesToDownload.size());
MultiFileDownloader downloader = new MultiFileDownloader(filesToDownload, downloadProgressListener);
List<Path> downloadedModulesPaths = downloader.call();
logger.info("Module download completed, loading the new modules...");
List<Module> newInstalledModules = new ArrayList<>(downloadedModulesPaths.size());
ModuleLoader loader = new ModuleLoader(moduleManager.getModuleMetadataReader());
loader.setModuleInfoPath(TerasologyConstants.MODULE_INFO_FILENAME);
for (Path filePath : downloadedModulesPaths) {
try {
Module module = loader.load(filePath);
moduleManager.getRegistry().add(module);
newInstalledModules.add(module);
} catch (IOException e) {
logger.warn("Could not load module {}", filePath.getFileName(), e);
}
}
logger.info("Finished loading the downloaded modules");
return newInstalledModules;
}
Aggregations