Thread: Someone Help me Pleas. With Ruse

Results 1 to 2 of 2
  1. #1 Someone Help me Pleas. With Ruse 
    Registered Member
    Join Date
    Nov 2015
    Posts
    11
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Well Guys i Did Everything That Whas updated on the Ruse Release Thread. But Now i got This. And only Some Files of The Cache Are Downloaded In The Cache
    https://gyazo.com/41e41c30f381c33ef6233d6376a72313
    Spoiler for CacheDownloader.java:

    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipInputStream;


    /**
    * Enchanced cache downloader
    * Handles cache downloading & unzipping
    * @author Gabriel Hannason
    */
    public class CacheDownloader {

    public static void init() {
    try {
    for(CACHE_DOWNLOAD_FILES cacheFile : CACHE_DOWNLOAD_FILES.values()) {
    boolean exists = new File(signlink.findcachedir() + cacheFile.identifier).exists();
    if(!exists) {
    int total = cacheFile.file.length;
    int current = 1;
    for(String file : cacheFile.file) {
    downloadFile(cacheFile, file, current, total);
    if(file.endsWith(".zip")) {
    unzip(new File(signlink.findcachedir() + file));
    }
    current ++;
    }
    new File(signlink.findcachedir() + cacheFile.identifier).createNewFile();
    }
    }
    } catch(Exception e) {
    e.printStackTrace();
    }
    }

    public static void downloadFile(CACHE_DOWNLOAD_FILES cacheFile, String file, int current, int total) throws IOException {
    String fileURL = cacheFile.link;
    String downloadingText = Client.optimizeText(cacheFile.toString().toLowerCa se());
    URL url = new URL(fileURL);
    HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
    httpConn.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0");
    int responseCode = httpConn.getResponseCode();

    // always check HTTP response code first
    if (responseCode == HttpURLConnection.HTTP_OK) {
    // opens input stream from the HTTP connection
    InputStream inputStream = httpConn.getInputStream();
    String saveFilePath = signlink.findcachedir() + file;
    // opens an output stream to save into file
    FileOutputStream outputStream = new FileOutputStream(saveFilePath);

    int bytesRead = -1;
    byte[] buffer = new byte[4096];
    long startTime = System.currentTimeMillis();
    int downloaded = 0;
    long numWritten = 0;
    int length = httpConn.getContentLength();
    while ((bytesRead = inputStream.read(buffer)) != -1) {
    outputStream.write(buffer, 0, bytesRead);
    numWritten += bytesRead;
    downloaded += bytesRead;
    int percentage = (int)(((double)numWritten / (double)length) * 100D);
    int downloadSpeed = (int) ((downloaded / 1024) / (1 + ((System.currentTimeMillis() - startTime) / 1000)));
    String s = total > 1 ? "("+current+"/"+total+")" : "";
    drawLoadingText(percentage, (new StringBuilder()).append("Downloading "+downloadingText+""+s+": "+percentage+"% ").append("@ "+downloadSpeed+"Kb/s").toString());
    }


    outputStream.close();
    inputStream.close();

    } else {
    System.out.println("download link replied HTTP code: " + responseCode);
    }
    httpConn.disconnect();
    }


    private static void drawLoadingText(int amount, String text) {
    Client.loadingPercentage = amount;
    Client.loadingText = text;
    }

    private static void unzip(final File file) {
    try {
    InputStream in = new BufferedInputStream(new FileInputStream(file));
    ZipInputStream zin = new ZipInputStream(in);
    ZipEntry e;
    while((e=zin.getNextEntry()) != null) {
    if(e.isDirectory()) {
    (new File(signlink.findcachedir() + e.getName())).mkdir();
    } else {
    if (e.getName().equals(file.getName())) {
    unzipPartlyArchive(zin, file.getName());
    break;
    }
    unzipPartlyArchive(zin, signlink.findcachedir() + e.getName());
    }
    }
    zin.close();
    file.delete();
    } catch(Exception e) {}
    }

    /**
    * Unzips a partly archive
    * @param zin The zip inputstream
    * @param s The location of the zip file
    * @throws IOException The method can throw an IOException.
    */
    private static void unzipPartlyArchive(ZipInputStream zin, String s) throws Exception {
    FileOutputStream out = new FileOutputStream(s);
    drawLoadingText(100, "Unpacking data..");
    byte [] b = new byte[1024];
    int len = 0;

    while ((len = zin.read(b)) != -1) {
    out.write(b,0,len);
    }
    out.close();
    }

    enum CACHE_DOWNLOAD_FILES {

    IMAGES(new String[]{"images.zip"}, "cache1loaded", "https://dl.dropboxusercontent.com/u/220769637/images.zip"),
    CACHE(new String[]{"RuseTraced.zip"}, "cache2loaded", "https://dl.dropboxusercontent.com/u/220769637/RuseTraced.zip"),
    DATA(new String[]{"data.zip"}, "cache3loaded", "https://dl.dropboxusercontent.com/u/220769637/data.zip"),
    ;

    CACHE_DOWNLOAD_FILES(String[] file, String identifier, String link) {
    this.file = file;
    this.identifier = identifier;
    this.link = https://dl.dropboxusercontent.com/u/...useTraced.zip;
    }

    private String[] file;
    private String identifier;
    private String link;
    }
    }


    Spoiler for Client.Java:
    /** DOWNLOADING LOADING IMAGES **/
    try {
    for(int i = 1; i <= 3; i++) {
    if(!new File(signlink.findcachedir() + "load"+i+".png").exists()) {
    String url = "";
    switch(i) {
    case 1:
    url = "http://s29.postimg.org/gmrgzf207/load1.png";
    break;
    case 2:
    url = "http://s29.postimg.org/vu7gjrtuv/load2.png";
    break;
    case 3:
    url = "http://s29.postimg.org/jr24w7isn/load3.png";
    break;
    }
    HttpDownloadUtility.downloadFile(url, signlink.findcachedir());
    }
    loadingSprites[i - 1] = Toolkit.getDefaultToolkit().getImage(signlink.find cachedir() + "load"+i+".png");
    }
    super.graphics.drawImage(loadingSprites[0], 0, 0, null);
    super.graphics.drawImage(loadingSprites[1], 5, clientHeight - 35, null);
    } catch(Exception e) {
    e.printStackTrace();
    }


    Swiffy Pleas Tell Me What i did wrong or someone else

    guys pleassss help me man...
    Reply With Quote  
     

  2. #2  
    Donator
    Dunpk's Avatar
    Join Date
    Apr 2014
    Posts
    146
    Thanks given
    26
    Thanks received
    13
    Rep Power
    15
    there something messing in ur cache , download fully one here Download fullcache.zip @ UppIT
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 0
    Last Post: 10-31-2015, 06:55 AM
  2. Replies: 2
    Last Post: 10-28-2015, 08:05 PM
  3. Replies: 5
    Last Post: 05-26-2015, 06:07 AM
  4. Replies: 4
    Last Post: 11-24-2013, 04:20 PM
  5. Replies: 0
    Last Post: 10-10-2013, 08:50 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •