Search in sources :

Example 1 with MultiFileDownloader

use of org.terasology.engine.utilities.download.MultiFileDownloader in project Terasology by MovingBlocks.

the class ModuleInstaller method call.

@Override
public List<Module> call() throws Exception {
    Map<URI, 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());
    for (Path filePath : downloadedModulesPaths) {
        try {
            Module module = moduleManager.registerArchiveModule(filePath);
            newInstalledModules.add(module);
        } catch (IOException e) {
            logger.warn("Could not load module {}", filePath.getFileName(), e);
        }
    }
    logger.info("Finished loading the downloaded modules");
    return newInstalledModules;
}
Also used : Path(java.nio.file.Path) MultiFileDownloader(org.terasology.engine.utilities.download.MultiFileDownloader) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Module(org.terasology.gestalt.module.Module) URI(java.net.URI)

Aggregations

IOException (java.io.IOException)1 URI (java.net.URI)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 MultiFileDownloader (org.terasology.engine.utilities.download.MultiFileDownloader)1 Module (org.terasology.gestalt.module.Module)1