Thread: Exotic client help!!!

Results 1 to 3 of 3
  1. #1 Exotic client help!!! 
    Registered Member
    Join Date
    Jan 2018
    Posts
    36
    Thanks given
    6
    Thanks received
    2
    Rep Power
    11
    Why is the cache downloader so screwed up has anyone else expiereced this?


    i have tryed 3 different cachedownloaders

    has trouble unloading sprites folder


    filedownloader
    [SPOIL]


    package com.client;

    import java.net.URL;
    import java.net.URLConnection;
    import java.util.zip.*;
    import java.io.*;

    import javax.swing.JOptionPane;

    import com.client.sign.Signlink;


    public class FileDownloader {

    private Client client;

    private static final int BUFFER_SIZE = 1024;
    public static final String VERSION_URL = "https://stylescape/file-server/cacheVersion.txt";
    public static final String VERSION_FILE = Signlink.findcachedir()+"/Saves/cacheVersion.dat";

    public FileDownloader(Client client) {
    this.client = client;
    }

    public enum FileType {
    CACHE(Signlink.findcachedir(), Configuration.NEW_CACHE_LINK, 1);

    private String url;
    private int version;
    private String directory;

    FileType(String directory, String url, int version) {
    this.directory = directory;
    this.url = url;
    this.version = version;
    }

    public int getVersion() {
    return version;
    }

    public String getURL() {
    return url;
    }

    public String getDirectory() {
    return directory;
    }

    @Override
    public String toString() {
    return name().toLowerCase();
    }
    }


    private static void deleteZIP(String fileName, FileType type) {
    // A File object to represent the filename
    File f = new File(type.getDirectory(), fileName);

    // Make sure the file or directory exists and isn't write protected
    if (!f.exists()) {
    throw new IllegalArgumentException("Delete: no such file or directory: " + fileName);
    }

    if (!f.canWrite()) {
    throw new IllegalArgumentException("Delete: write protected: " + fileName);
    }

    // If it is a directory, make sure it is empty
    if (f.isDirectory()) {
    String[] files = f.list();

    if (files.length > 0) {
    throw new IllegalArgumentException("Delete: directory not empty: " + fileName);
    }
    }

    // Attempt to delete it
    boolean success = f.delete();

    if (!success) {
    throw new IllegalArgumentException("Delete: deletion failed");
    }
    }

    private static void downloadFile(Client client, FileType type, String localFileName) {
    try {
    URL url = new URL(type.getURL());
    URLConnection conn = url.openConnection();
    try (OutputStream out = new BufferedOutputStream(new FileOutputStream(type.getDirectory() + "/" + localFileName)); InputStream in = conn.getInputStream()) {
    byte[] data = new byte[BUFFER_SIZE];
    int numRead;
    long numWritten = 0;
    int length = conn.getContentLength();
    long startTime = System.currentTimeMillis();
    while ((numRead = in.read(data)) != -1) {
    out.write(data, 0, numRead);
    numWritten += numRead;

    int percentage = (int) (((double) numWritten / (double) length) * 100D);
    long elapsedTime = System.currentTimeMillis() - startTime;
    int downloadSpeed = (int) ((numWritten / 1024) / (1 + (elapsedTime / 1000)));

    float speedInBytes = 1000f * numWritten / elapsedTime;
    int timeRemaining = (int) ((length - numWritten) / speedInBytes);

    client.drawLoadingText(percentage, "OS-Arraw - Downloading cache...", downloadSpeed, timeRemaining);
    }
    client.drawLoadingText(100, "OS-Arraw - Unzipping...", -1, -1);
    }
    } catch (IOException ex) {
    ex.printStackTrace();
    }
    }

    private static String getArchivedName(FileType type) {
    int lastSlashIndex = type.getURL().lastIndexOf('/');

    if ((lastSlashIndex >= 0) && (lastSlashIndex < (type.getURL().length() - 1))) {
    return type.getURL().substring(lastSlashIndex + 1);
    } else {
    }

    return "";
    }

    /**
    * Starts the unzipping process
    *
    * @param zin
    * @param s
    * @throws IOException
    */
    private static void unzip(ZipInputStream zin, String s) throws IOException {
    try (FileOutputStream out = new FileOutputStream(s)) {
    byte[] buf = new byte[BUFFER_SIZE];
    int len = 0;

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

    /**
    * Attempts to unzip the archive
    *
    * @param type
    */
    private static void unZip(FileType type) {
    String archive = type.getDirectory() + File.separator + getArchivedName(type);
    try (ZipInputStream zin = new ZipInputStream(new BufferedInputStream(new FileInputStream(archive)))) {
    ZipEntry e;
    while ((e = zin.getNextEntry()) != null) {
    if (e.isDirectory()) {
    (new File(type.getDirectory() + File.separator + e.getName())).mkdir();
    } else {
    if (e.getName().equals(archive)) {
    unzip(zin, archive);
    break;
    }

    unzip(zin, type.getDirectory() + File.separator + e.getName());
    }
    }
    } catch (Exception ex) {
    ex.printStackTrace();
    }
    }

    public static double getCurrentVersion(){
    try {
    @SuppressWarnings("resource")
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(VERSION_FILE)));
    return Double.parseDouble(br.readLine());
    } catch (Exception e) {
    return 0.1;
    }
    }

    public static double getNewestVersion(){
    try {
    URL tmp = new URL(VERSION_URL);
    BufferedReader br = new BufferedReader(new InputStreamReader(tmp.openStream()));
    return Double.parseDouble(br.readLine());
    } catch (Exception e) {
    handleException(e);
    return -1;
    }
    }

    private static void handleException(Exception e){
    StringBuilder strBuff = new StringBuilder();
    strBuff.append("Please Screenshot this message, and send it to an admin!\r\n\r\n");
    strBuff.append(e.getClass().getName()).append(" \"").append(e.getMessage()).append("\"\r\n");
    for(StackTraceElement s : e.getStackTrace())
    strBuff.append(s.toString()).append("\r\n");
    alert("Exception [" + e.getClass().getSimpleName() + "]",strBuff.toString(),true);
    }

    private static void alert(String title,String msg,boolean error){
    JOptionPane.showMessageDialog(null,
    msg,
    title,
    (error ? JOptionPane.ERROR_MESSAGE : JOptionPane.PLAIN_MESSAGE));
    }

    private static void alert(String msg){
    alert("Message", msg, false);
    }

    public static void start(Client client, FileType type) {
    try {
    double newest = getNewestVersion();
    if (newest > getCurrentVersion()) {
    downloadFile(client, type, getArchivedName(type));
    unZip(type);
    deleteZIP(getArchivedName(type), type);
    @SuppressWarnings("resource")
    OutputStream out = new FileOutputStream(VERSION_FILE);
    alert("Cache has been updated, please restart the client!");
    out.write(String.valueOf(newest).getBytes());;
    System.exit(0);
    }
    } catch (Exception e) {
    handleException(e);
    }
    }

    }






    [/SPOIL]
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Registered Member

    Join Date
    Oct 2011
    Posts
    2,102
    Thanks given
    0
    Thanks received
    1,041
    Rep Power
    3608
    Quote Originally Posted by matt2283 View Post
    Why is the cache downloader so screwed up has anyone else expiereced this?
    it's not but prob is to other leechers.

    can't say much since you're not posting code.
    Reply With Quote  
     

  4. #3  
    Registered Member
    Join Date
    Jan 2018
    Posts
    36
    Thanks given
    6
    Thanks received
    2
    Rep Power
    11
    I changed it 3 times bro 3 different cache downloaders I try it will not unzip the sprites folder
    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. need client ? help plz
    By kcinnay str in forum Requests
    Replies: 0
    Last Post: 08-10-2008, 07:49 PM
  2. Silab client help
    By Nathan R in forum RS2 Client
    Replies: 3
    Last Post: 03-10-2008, 04:13 PM
  3. for silabs client help
    By bye i will never c u in forum RS2 Client
    Replies: 6
    Last Post: 10-04-2007, 11:25 PM
  4. Need some client help plz
    By woofdawg23 in forum Requests
    Replies: 2
    Last Post: 10-01-2007, 05:41 AM
  5. Web-Client Help
    By kylemartin in forum RS2 Client
    Replies: 1
    Last Post: 07-29-2007, 11:55 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
  •