Package net.ftb.download.workers

Examples of net.ftb.download.workers.AssetDownloader


            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);
        }
View Full Code Here

TOP

Related Classes of net.ftb.download.workers.AssetDownloader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.