Package org.spoutcraft.launcher.async

Examples of org.spoutcraft.launcher.async.Download


          }
        } else {
          url = SPLASH_URL;
        }

        Download download = new Download(url, backgroundImage.getPath());
        download.run();

      }
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here


      } else {
        String mirrorURL = "mods/" + name + "/" + filename;
        String fallbackURL = fallbackModsURL + name + "/" + filename;
        String url = MirrorUtils.getMirrorUrl(mirrorURL, fallbackURL, this);
        String fileMD5 = MD5Utils.getMD5FromList(mirrorURL);
        Download download = DownloadUtils.downloadFile(url, downloadedFile.getPath(), filename, fileMD5, this);
        return download.isSuccess();
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    return false;
View Full Code Here

    File outputFile = null;
    String requiredMinecraftVersion = build.getMinecraftVersion();
    while (tries > 0) {
      Util.logi("Starting download of minecraft, with %s trie(s) remaining", tries);
      tries--;
      Download download = new Download(build.getMinecraftURL(user), output);
      download.setListener(listener);
      download.run();
      if (!download.isSuccess()) {
        if (download.getOutFile() != null) {
          download.getOutFile().delete();
        }
        System.err.println("Download of minecraft failed!");
        listener.stateChanged("Download Failed, retries remaining: " + tries, 0F);
      } else {
        // String minecraftMD5 = MD5Utils.getMD5(FileType.minecraft,
        // build.getLatestMinecraftVersion());
        String resultMD5 = MD5Utils.getMD5(download.getOutFile());

        String minecraftVersion = MD5Utils.getMinecraftMD5(resultMD5);
        if (minecraftVersion != null) {
          Util.log("Downloaded 'minecraft.jar' matches MD5 of version '%s'.", minecraftVersion);
        } else {
          Util.log("Downloaded 'minecraft.jar' does not matche MD5 of any known minecraft version!");
          continue;
        }

        // Util.log("Expected MD5: " + minecraftMD5 + " Result MD5: " +
        // resultMD5);
        //
        // if (!resultMD5.equals(minecraftMD5)) {
        // continue;
        // }

        if (!minecraftVersion.equals(requiredMinecraftVersion)) {
          File patch = new File(GameUpdater.tempDir, "mc.patch");
          String patchURL = build.getPatchURL(minecraftVersion, requiredMinecraftVersion);
          Download patchDownload = DownloadUtils.downloadFile(patchURL, patch.getPath(), null, null, listener);
          if (patchDownload.isSuccess()) {
            File patchedMinecraft = new File(GameUpdater.tempDir, "patched_minecraft.jar");
            patchedMinecraft.delete();
            listener.stateChanged(String.format("Patching Minecraft to '%s'.", requiredMinecraftVersion), 0F);
            JBPatch.bspatch(download.getOutFile(), patchedMinecraft, patch);
            listener.stateChanged(String.format("Patched Minecraft to '%s'.", requiredMinecraftVersion), 100F);
View Full Code Here

    if (Main.isOffline) return null;
    int tries = SettingsUtil.getLoginTries();
    File outputFile = new File(output);
    File tempfile = File.createTempFile("file", null, GameUpdater.tempDir);
    tempfile.mkdirs();
    Download download = null;
    boolean areFilesIdentical = tempfile.getPath().equalsIgnoreCase(outputFile.getPath());
    while (tries > 0) {
      Util.logi("Starting download of '%s', with %s trie(s) remaining", url, tries);
      tries--;
      download = new Download(url, tempfile.getPath());
      download.setListener(listener);
      download.run();
      if (!download.isSuccess()) {
        if (download.getOutFile() != null) {
          download.getOutFile().delete();
        }
        Util.log("Download of " + url + " Failed!");
        if (listener != null) {
          listener.stateChanged("Download Failed, retries remaining: " + tries, 0F);
        }
      } else {
        String fileMD5 = MD5Utils.getMD5(download.getOutFile());
        if (md5 == null || fileMD5.equals(md5)) {
          Util.logi("Copying: %s to: %s", tempfile, outputFile);
          if (!areFilesIdentical) {
            GameUpdater.copy(tempfile, outputFile);
          }
View Full Code Here

    for (final Map.Entry<String, String> file : downloadFileList.entrySet()) {
      es.execute(new Runnable() {

        @Override
        public void run() {
          Download downloadFile = null;
          try {
            downloadFile = downloadFile(file.getKey(), file.getValue());
            if (downloadFile != null && downloadFile.isSuccess()) {
              filesDownloaded++;
              return;
            }
          } catch (IOException e) {
            e.printStackTrace();
          }
          Util.log("File '%s' failed to download.", downloadFile.getOutFile());
        }
      });
    }
    es.shutdown();
    try {
View Full Code Here

        if (!libraryFile.exists()) {
          String mirrorURL = "Libraries/" + lib.getKey() + "/" + name + ".jar";
          String fallbackURL = "http://spouty.org/Libraries/" + lib.getKey() + "/" + name + ".jar";
          String url = MirrorUtils.getMirrorUrl(mirrorURL, fallbackURL, this);
          Download download = DownloadUtils.downloadFile(url, libraryFile.getPath(), lib.getKey() + ".jar", MD5, this);
        }
      }
    }
    build.install();
View Full Code Here

TOP

Related Classes of org.spoutcraft.launcher.async.Download

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.