Examples of Downloadable


Examples of com.atlauncher.data.Downloadable

        }
        return result;
    }

    public static String getUUID(String username) {
        Downloadable downloadable = new Downloadable("https://api.mojang.com/users/profiles/minecraft/" + username,
                false);

        ProfileResponse profile = Gsons.DEFAULT.fromJson(downloadable.getContents(), ProfileResponse.class);

        return profile.getId();
    }
View Full Code Here

Examples of com.atlauncher.data.Downloadable

            }
        }

        for (Mod mod : this.selectedMods) {
            if (mod.isServerDownload()) {
                Downloadable downloadable;
                int size = -1;
                if (fileSizes.containsKey(mod.getURL())) {
                    size = fileSizes.get(mod.getURL());
                }
                if (mod.hasMD5()) {
                    downloadable = new Downloadable(mod.getURL(), new File(App.settings.getDownloadsDir(),
                            mod.getFile()), mod.getMD5(), size, this, true);
                } else {
                    downloadable = new Downloadable(mod.getURL(), new File(App.settings.getDownloadsDir(),
                            mod.getFile()), null, size, this, true);
                }
                mods.add(downloadable);
            }
        }
View Full Code Here

Examples of com.atlauncher.data.Downloadable

            }
        }

        for (com.atlauncher.data.json.Mod mod : this.selectedJsonMods) {
            if (mod.getDownload() == DownloadType.server) {
                Downloadable downloadable;
                int size = -1;
                if (fileSizes.containsKey(mod.getUrl())) {
                    size = fileSizes.get(mod.getUrl());
                }
                if (mod.hasMD5()) {
                    downloadable = new Downloadable(mod.getUrl(), new File(App.settings.getDownloadsDir(),
                            mod.getFile()), mod.getMD5(), size, this, true);
                } else {
                    downloadable = new Downloadable(mod.getUrl(), new File(App.settings.getDownloadsDir(),
                            mod.getFile()), null, size, this, true);
                }
                mods.add(downloadable);
            }
        }
View Full Code Here

Examples of com.atlauncher.data.Downloadable

        File indexFile = new File(indexesFolder, assetVersion + ".json");
        objectsFolder.mkdirs();
        indexesFolder.mkdirs();
        virtualFolder.mkdirs();
        try {
            new Downloadable(MojangConstants.DOWNLOAD_BASE.getURL("indexes/" + assetVersion + ".json"), indexFile,
                    null, this, false).download(false);
            AssetIndex index = (AssetIndex) this.gson.fromJson(new FileReader(indexFile), AssetIndex.class);

            if (index.isVirtual()) {
                virtualRoot.mkdirs();
            }

            for (Map.Entry<String, AssetObject> entry : index.getObjects().entrySet()) {
                AssetObject object = entry.getValue();
                String filename = object.getHash().substring(0, 2) + "/" + object.getHash();
                File file = new File(objectsFolder, filename);
                File virtualFile = new File(virtualRoot, entry.getKey());
                if (object.needToDownload(file)) {
                    downloads.add(new Downloadable(MojangConstants.RESOURCES_BASE.getURL(filename), file,
                            object.getHash(), (int) object.getSize(), this, false, virtualFile, index.isVirtual()));
                } else {
                    if (index.isVirtual()) {
                        virtualFile.mkdirs();
                        Utils.copyFile(file, virtualFile, true);
View Full Code Here

Examples of com.atlauncher.data.Downloadable

                                    element.getAttribute("server").substring(element.getAttribute("server")
                                            .lastIndexOf('/'), element.getAttribute("server").length())));
                        }
                        downloadTo = new File(App.settings.getLibrariesDir(), file);
                        if (download == Download.server) {
                            libraries.add(new Downloadable(App.settings.getFileURL(url), downloadTo, md5, this, false));
                        } else {
                            libraries.add(new Downloadable(url, downloadTo, md5, this, false));
                        }
                        libraryNamesAdded.add(file.substring(0, file.lastIndexOf("-")));
                    }
                }
            } catch (SAXException e) {
                App.settings.logStackTrace(e);
            } catch (ParserConfigurationException e) {
                App.settings.logStackTrace(e);
            } catch (IOException e) {
                App.settings.logStackTrace(e);
            }
        } else {
            for (com.atlauncher.data.json.Library library : this.jsonVersion.getLibraries()) {
                if (library.hasDepends()) {
                    boolean found = false;
                    for (com.atlauncher.data.json.Mod mod : selectedJsonMods) {
                        if (library.getDepends().equalsIgnoreCase(mod.getName())) {
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        continue;
                    }
                } else if (library.hasDependsGroup()) {
                    boolean found = false;
                    for (com.atlauncher.data.json.Mod mod : selectedJsonMods) {
                        if (library.getDependsGroup().equalsIgnoreCase(mod.getGroup())) {
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        continue;
                    }
                }
                if (librariesNeeded == null) {
                    this.librariesNeeded = library.getFile();
                } else {
                    this.librariesNeeded += "," + library.getFile();
                }
                forgeLibraries.add(library.getFile());
                File downloadTo = null;
                if (this.isServer) {
                    if (!library.forServer()) {
                        continue;
                    }
                    serverLibraries.add(new File(getLibrariesDirectory(), library.getServer()));
                }
                downloadTo = new File(App.settings.getLibrariesDir(), library.getFile());
                if (library.getDownloadType() == DownloadType.server) {
                    libraries.add(new Downloadable(App.settings.getFileURL(library.getUrl()), downloadTo,
                            library.getMD5(), this, false));
                } else if (library.getDownloadType() == DownloadType.direct) {
                    libraries.add(new Downloadable(library.getUrl(), downloadTo, library.getMD5(), this, false));
                } else {
                    LogManager.error("DownloadType for server library " + library.getFile() + " is invalid with a " +
                            "value of " + library.getDownloadType());
                    this.cancel(true);
                    return null;
                }
                if (library.getFile().contains("-")) {
                    libraryNamesAdded.add(library.getFile().substring(0, library.getFile().lastIndexOf("-")));
                } else {
                    libraryNamesAdded.add(library.getFile());
                }
            }
        }
        // Now read in the library jars needed from Mojang
        if (!this.isServer) {
            for (Library library : this.version.getMinecraftVersion().getMojangVersion().getLibraries()) {
                if (library.shouldInstall()) {
                    if (libraryNamesAdded.contains(library.getFile().getName().substring(0,
                            library.getFile().getName().lastIndexOf("-")))) {
                        LogManager.debug("Not adding library " + library.getName() + " as it's been overwritten " +
                                "already by the packs libraries!");
                        continue;
                    }
                    if (!library.shouldExtract()) {
                        if (librariesNeeded == null) {
                            this.librariesNeeded = library.getFile().getName();
                        } else {
                            this.librariesNeeded += "," + library.getFile().getName();
                        }
                    }
                    libraries.add(new Downloadable(library.getURL(), library.getFile(), null, this, false));
                }
            }
        }

        // Add Minecraft.jar

        if (isServer) {
            libraries.add(new Downloadable(MojangConstants.DOWNLOAD_BASE.getURL("versions/" + this.version
                    .getMinecraftVersion().getVersion() + "/minecraft_server." + this.version.getMinecraftVersion()
                    .getVersion() + ".jar"), new File(App.settings.getJarsDir(), "minecraft_server." + this.version
                    .getMinecraftVersion().getVersion() + ".jar"), null, this, false));
        } else {
            libraries.add(new Downloadable(MojangConstants.DOWNLOAD_BASE.getURL("versions/" + this.version
                    .getMinecraftVersion().getVersion() + "/" + this.version.getMinecraftVersion().getVersion() + "" +
                    ".jar"), new File(App.settings.getJarsDir(), this.version.getMinecraftVersion().getVersion() + "" +
                    ".jar"), null, this, false));
        }
        return libraries;
View Full Code Here

Examples of com.atlauncher.data.Downloadable

    public void configurePack() {
        // Download the configs zip file
        fireTask(Language.INSTANCE.localize("instance.downloadingconfigs"));
        File configs = new File(App.settings.getTempDir(), "Configs.zip");
        String path = "packs/" + pack.getSafeName() + "/versions/" + version.getVersion() + "/Configs.zip";
        Downloadable configsDownload = new Downloadable(path, configs, null, this, true);
        this.totalBytes = configsDownload.getFilesize();
        this.downloadedBytes = 0;
        configsDownload.download(true); // Download the file

        // Extract the configs zip file
        fireSubProgressUnknown();
        fireTask(Language.INSTANCE.localize("instance.extractingconfigs"));
        Utils.unzip(configs, getRootDirectory());
View Full Code Here

Examples of com.atlauncher.data.Downloadable

                        }
                    }
                }
            }
        } else if (this.serverDownload == DownloadType.direct) {
            Downloadable download = new Downloadable(this.serverUrl, fileLocation, this.serverMD5, installer, false);
            if (download.needToDownload()) {
                download.download(false);
            }
        } else if (this.serverDownload == DownloadType.server) {
            Downloadable download = new Downloadable(this.serverUrl, fileLocation, this.serverMD5, installer, true);
            if (download.needToDownload()) {
                download.download(false);
            }
        }
        if (hasServerMD5()) {
            if (Utils.getMD5(fileLocation).equalsIgnoreCase(this.serverMD5)) {
                return; // MD5 hash matches
View Full Code Here

Examples of com.atlauncher.data.Downloadable

                        }
                    }
                }
                break;
            case direct:
                Downloadable download1 = new Downloadable(this.getUrl(), fileLocation, this.md5, installer, false);
                if (download1.needToDownload()) {
                    installer.resetDownloadedBytes(download1.getFilesize());
                    download1.download(true);
                }
                break;
            case server:
                Downloadable download2 = new Downloadable(this.getUrl(), fileLocation, this.md5, installer, true);
                if (download2.needToDownload()) {
                    download2.download(false);
                }
                break;
        }
        if (hasMD5()) {
            if (Utils.getMD5(fileLocation).equalsIgnoreCase(this.md5)) {
View Full Code Here

Examples of com.atlauncher.data.Downloadable

                        dialog.doneTask();
                    }

                    // Response Code Test
                    for (Server server : App.settings.getServers()) {
                        Downloadable download = new Downloadable(server.getFileURL("launcher/json/hashes.json"), false);
                        results.append(String.format("Response code to %s was %d\n\n----------------\n\n",
                                server.getHost(), download.getResponseCode()));
                        dialog.doneTask();
                    }

                    // Ping Pong Test
                    for (Server server : App.settings.getServers()) {
                        Downloadable download = new Downloadable(server.getFileURL("ping"), false);
                        results.append(String.format("Response to ping on %s was %s\n\n----------------\n\n",
                                server.getHost(), download.getContents()));
                        dialog.doneTask();
                    }

                    // Speed Test
                    for (Server server : App.settings.getServers()) {
                        File file = new File(App.settings.getTempDir(), "20MB.test");
                        if (file.exists()) {
                            Utils.delete(file);
                        }
                        long started = System.currentTimeMillis();

                        Downloadable download = new Downloadable(server.getFileURL("20MB.test"), file);
                        download.download(false);

                        long timeTaken = System.currentTimeMillis() - started;
                        float bps = file.length() / (timeTaken / 1000);
                        float kbps = bps / 1024;
                        float mbps = kbps / 1024;
View Full Code Here

Examples of hudson.model.DownloadService.Downloadable

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        // this object receives the submission.
        // to bypass the URL restriction, we'll trigger downloadService.download ourselves
        job = new Downloadable("test", "UNUSED");
        Downloadable.all().add(job);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.