Logger.logInfo("Checking/Downloading " + assets.size() + " assets, this may take a while...");
final ProgressMonitor prog = new ProgressMonitor(LaunchFrame.getInstance(), "Downloading Files...", "", 0, 100);
prog.setMaximum(assets.size() * 100);
final AssetDownloader downloader = new AssetDownloader(prog, assets) {
@Override
public void done () {
try {
prog.close();
if (get()) {
Logger.logInfo("Asset downloading complete");
launchMinecraft(installPath, pack, RESPONSE, isLegacy);
} else {
ErrorUtils.tossError("Error occurred during downloading the assets");
}
} catch (CancellationException e) {
Logger.logInfo("Asset download interrupted by user");
} catch (Exception e) {
ErrorUtils.tossError("Failed to download files.", e);
} finally {
Main.getEventBus().post(new EnableObjectsEvent());
}
}
};
downloader.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange (PropertyChangeEvent evt) {
if (prog.isCanceled()) {
downloader.cancel(false);
prog.close();
} else if (!downloader.isCancelled()) {
if ("ready".equals(evt.getPropertyName())) {
prog.setProgress(downloader.getReady());
}
if ("status".equals(evt.getPropertyName())) {
prog.setNote(downloader.getStatus());
}
}
}
});
downloader.execute();
} else if (assets == null) {
Main.getEventBus().post(new EnableObjectsEvent());
} else {
launchMinecraft(installPath, pack, RESPONSE, isLegacy);
}