Thread: Cache Version Removal!!!!

Results 1 to 3 of 3
  1. #1 Cache Version Removal!!!! 
    Registered Member
    Join Date
    Sep 2013
    Posts
    3
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    How do I remove the version updating cache thing.. This is based on Hyperion #474

    Error:
    Spoiler for Error:
    java.io.FileNotFoundException: http://www.simplex07.org/cache.txt
    at sun.net.http://www.protocol.http.HttpURLConn...Stream(Unknown So
    urce)
    at java.net.URL.openStream(Unknown Source)
    at CacheDownloader.getCacheVersion(CacheDownloader.ja va:39)
    at CacheDownloader.downloadCache(CacheDownloader.java :71)
    at client.main(client.java:262)
    error_game_js5connect_outofdate


    Spoiler for Code:
    Code:
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipInputStream;
    import javax.swing.*;
    import java.net.*;
    import java.io.*;
    
    public class CacheDownloader {
    
        private client client;
        client frame;
        private final int BUFFER = 1024;
        private final int VERSION = 7;
        private final int pauseHandlerDelay = 1000;
        private String cacheLink = "https://dl.dropboxusercontent.com/s/qbiehryvw3c049e/cache.zip";
        private String cacheDir = System.getProperty("user.home") + "/simplex_474/";
        private String fileToExtract = getCacheDir() + getArchivedName();
        private static JLabel label1 = new JLabel();
        private static JProgressBar progressBar;
        private static JFrame progress = new JFrame("Cache Updater");
    
        public CacheDownloader(client client) {
            this.client = client;
        }
    
        private String getCacheLink() {
            return cacheLink;
        }
    
        private String getCacheDir() {
            return cacheDir;
        }
    
        private int getCacheVersion() {
            try {
                URL url = new URL("http://www.simplex07.org/cache.txt");
                BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                String str = in.readLine();
                in.close();
                return Integer.parseInt(str);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return VERSION;
        }
    
        private int pauseHandlerDelay1000Equals1Second() {
            return pauseHandlerDelay;
        }
    
        private String localCacheFile() {
            return getCacheDir() + getArchivedName();
        }
    
        public static void addComponentsToPane(Container pane) {
            pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
            label1.setAlignmentX(Component.CENTER_ALIGNMENT);
            pane.add(label1);
            progressBar = new JProgressBar(0, 100);
            progressBar.setValue(0);
            progressBar.setStringPainted(true);
            progressBar.setAlignmentX(Component.CENTER_ALIGNMENT);
            pane.add(progressBar);
        }
    
        public CacheDownloader downloadCache() {
            try {
                File location = new File(getCacheDir());
                File version = new File(getCacheDir() + "/cacheVersion" + getCacheVersion() + ".dat");
                if (!location.exists()) {
                    location.mkdir();
                    cacheHasUpdated();
                     downloadFile(getCacheLink(), getArchivedName());
                } else {
                    if (!version.exists()) {
                        cacheHasUpdated();
                         downloadFile(getCacheLink(), getArchivedName());
                    } else {
                        return null;
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
    
        public void cacheHasUpdated() {
            progress.setResizable(false);
            progress.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            addComponentsToPane(progress.getContentPane());
            progress.setLocationRelativeTo(null);
            progress.setPreferredSize(new Dimension(400, 120));
            progress.pack();
            label1.setText("Downloading Cache");
            progress.setVisible(true);
        }
    
        public void saveUrl(String filename, String urlString) throws MalformedURLException, IOException {
            BufferedInputStream in = null;
            FileOutputStream fout = null;
            try {
                in = new BufferedInputStream(new URL(urlString).openStream());
                fout = new FileOutputStream(filename);
    
                byte data[] = new byte[1024];
                int count;
                while ((count = in.read(data, 0, 1024)) != -1) {
                    fout.write(data, 0, count);
                }
            } finally {
                if (in != null) {
                    in.close();
                }
                if (fout != null) {
                    fout.close();
                }
            }
        }
    
        private void downloadFile(String adress, String localFileName) {
            OutputStream out = null;
            URLConnection conn;
            InputStream in = null;
            try {
                URL url = new URL(adress);
                out = new BufferedOutputStream(
                        new FileOutputStream(getCacheDir() + "/" + localFileName));
                conn = url.openConnection();
                in = conn.getInputStream();
                byte[] data = new byte[BUFFER];
                int numRead;
                long numWritten = 0;
                int length = conn.getContentLength();
                while ((numRead = in.read(data)) != -1) {
                    out.write(data, 0, numRead);
                    numWritten += numRead;
                    int percentage = (int) (((double) numWritten / (double) length) * 100D);
                    progressBar.setValue(percentage);
                }
            } catch (Exception exception) {
                exception.printStackTrace();
            } finally {
                try {
                    progress.setVisible(false);
                    if (in != null) {
                        in.close();
                    }
                    if (out != null) {
                        out.close();
                    }
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                }
            }
            fileExists();
        }
    
        private String getArchivedName() {
            int lastSlashIndex = getCacheLink().lastIndexOf('/');
            if (lastSlashIndex >= 0 && lastSlashIndex < getCacheLink().length() - 1) {
                return getCacheLink().substring(lastSlashIndex + 1);
            } else {
                System.err.println("error retreiving archivaed name.");
            }
            return "";
        }
    
        public void fileExists() {
            File file = new File(localCacheFile());
            boolean exists = file.exists();
            if (!exists) {
                System.out.println("The cache was not downloaded correctly.");
                System.out.println("Please download it manually at:");
                System.out.println(localCacheFile());
                System.out.println("File Directory:");
                System.out.println(getCacheDir());
                pauseHandler();
                cacheDownloadError();
            } else {
                //  drawLoadingText("Your cache is downloaded and ready to un-zip!");
                pauseHandler();
                unZip();
            }
        }
    
        private void unZip() {
            try {
                InputStream in =
                        new BufferedInputStream(new FileInputStream(fileToExtract));
                ZipInputStream zin = new ZipInputStream(in);
                ZipEntry e;
                while ((e = zin.getNextEntry()) != null) {
                    if (e.isDirectory()) {
                        (new File(getCacheDir() + e.getName())).mkdir();
                    } else {
                        if (e.getName().equals(fileToExtract)) {
                            unzip(zin, fileToExtract);
                            break;
                        }
                        unzip(zin, getCacheDir() + e.getName());
                    }
                    //    drawLoadingText("[UN-ZIP]: " + e.getName());
                }
                zin.close();
                BufferedWriter versionFile = new BufferedWriter(new FileWriter(getCacheDir() + "/cacheVersion" + getCacheVersion() + ".dat"));
                versionFile.close();
                JOptionPane.showMessageDialog(frame, "Cache has been downloaded and unzipped.");
            } catch (Exception e) {
                e.printStackTrace();
            }
            pauseHandler();
            unNeededCacheExists();
        }
    
        private void unzip(ZipInputStream zin, String s)
                throws IOException {
            FileOutputStream out = new FileOutputStream(s);
            byte[] b = new byte[BUFFER];
            int len = 0;
    
            while ((len = zin.read(b)) != -1) {
                out.write(b, 0, len);
            }
        }
    
        public void unNeededCacheExists() {
            File file = new File(localCacheFile());
            boolean exists = file.exists();
            if (!exists) {
                System.out.println("Your cache was not downloaded correctly.");
                System.out.println("Please try to re re run the client.");
            } else {
                System.out.println("Your cache is on your HDD");
                System.out.println("Auto Cache Deleter Attempting to delete...");
                delete();
            }
        }
    
        public void delete() {
            try {
                File file = new File(localCacheFile());
                if (file.delete()) {
                    //  drawLoadingText("[SUCCESS]" + file.getName() + " was deleted!");
                    System.out.println("[SUCCESS]" + file.getName() + " was deleted!");
                } else {
                    //   drawLoadingText("[ERROR]" + file.getName() + " was not deleted.");
                    System.out.println("[ERROR]" + file.getName() + " was not deleted.");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public void cacheDownloadError() {
            try {
                //  drawLoadingText("Cache Download Error - Contact an admin");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public void pauseHandler() {
            try {
                Thread.currentThread().sleep(pauseHandlerDelay1000Equals1Second());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    /**
     * ***********************
     * @author Google411 ***********************
     */
    Reply With Quote  
     

  2. #2  
    Banned
    Join Date
    Sep 2013
    Posts
    236
    Thanks given
    145
    Thanks received
    52
    Rep Power
    0
    In your startup method remove cacheupdate(this) or something similar to that.
    Reply With Quote  
     

  3. #3  
    Registered Member Life's Avatar
    Join Date
    Mar 2012
    Posts
    213
    Thanks given
    24
    Thanks received
    10
    Rep Power
    11
    Yeah startup method in client.java and find something like getCacheVersion(); or something and add // infront so it's like //getCacheVersion();. OR try replacing your code with:
    Spoiler for New Code:
    Code:
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipInputStream;
    import javax.swing.*;
    import java.net.*;
    import java.io.*;
    
    public class CacheDownloader {
    
        private client client;
        client frame;
        private final int BUFFER = 1024;
        private final int VERSION = 7;
        private final int pauseHandlerDelay = 1000;
        private String cacheLink = "https://dl.dropboxusercontent.com/s/qbiehryvw3c049e/cache.zip";
        private String cacheDir = System.getProperty("user.home") + "/simplex_474/";
        private String fileToExtract = getCacheDir() + getArchivedName();
        private static JLabel label1 = new JLabel();
        private static JProgressBar progressBar;
        private static JFrame progress = new JFrame("Cache Updater");
    
        public CacheDownloader(client client) {
            this.client = client;
        }
    
        private String getCacheLink() {
            return cacheLink;
        }
    
        private String getCacheDir() {
            return cacheDir;
        }
    
        private int pauseHandlerDelay1000Equals1Second() {
            return pauseHandlerDelay;
        }
    
        private String localCacheFile() {
            return getCacheDir() + getArchivedName();
        }
    
        public static void addComponentsToPane(Container pane) {
            pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
            label1.setAlignmentX(Component.CENTER_ALIGNMENT);
            pane.add(label1);
            progressBar = new JProgressBar(0, 100);
            progressBar.setValue(0);
            progressBar.setStringPainted(true);
            progressBar.setAlignmentX(Component.CENTER_ALIGNMENT);
            pane.add(progressBar);
        }
    
        public CacheDownloader downloadCache() {
            try {
                File location = new File(getCacheDir());
                File version = new File(getCacheDir() + "/cacheVersion" + getCacheVersion() + ".dat");
                if (!location.exists()) {
                    location.mkdir();
                    cacheHasUpdated();
                     downloadFile(getCacheLink(), getArchivedName());
                } else {
                    if (!version.exists()) {
                        cacheHasUpdated();
                         downloadFile(getCacheLink(), getArchivedName());
                    } else {
                        return null;
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }
    
        public void cacheHasUpdated() {
            progress.setResizable(false);
            progress.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            addComponentsToPane(progress.getContentPane());
            progress.setLocationRelativeTo(null);
            progress.setPreferredSize(new Dimension(400, 120));
            progress.pack();
            label1.setText("Downloading Cache");
            progress.setVisible(true);
        }
    
        public void saveUrl(String filename, String urlString) throws MalformedURLException, IOException {
            BufferedInputStream in = null;
            FileOutputStream fout = null;
            try {
                in = new BufferedInputStream(new URL(urlString).openStream());
                fout = new FileOutputStream(filename);
    
                byte data[] = new byte[1024];
                int count;
                while ((count = in.read(data, 0, 1024)) != -1) {
                    fout.write(data, 0, count);
                }
            } finally {
                if (in != null) {
                    in.close();
                }
                if (fout != null) {
                    fout.close();
                }
            }
        }
    
        private void downloadFile(String adress, String localFileName) {
            OutputStream out = null;
            URLConnection conn;
            InputStream in = null;
            try {
                URL url = new URL(adress);
                out = new BufferedOutputStream(
                        new FileOutputStream(getCacheDir() + "/" + localFileName));
                conn = url.openConnection();
                in = conn.getInputStream();
                byte[] data = new byte[BUFFER];
                int numRead;
                long numWritten = 0;
                int length = conn.getContentLength();
                while ((numRead = in.read(data)) != -1) {
                    out.write(data, 0, numRead);
                    numWritten += numRead;
                    int percentage = (int) (((double) numWritten / (double) length) * 100D);
                    progressBar.setValue(percentage);
                }
            } catch (Exception exception) {
                exception.printStackTrace();
            } finally {
                try {
                    progress.setVisible(false);
                    if (in != null) {
                        in.close();
                    }
                    if (out != null) {
                        out.close();
                    }
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                }
            }
            fileExists();
        }
    
        private String getArchivedName() {
            int lastSlashIndex = getCacheLink().lastIndexOf('/');
            if (lastSlashIndex >= 0 && lastSlashIndex < getCacheLink().length() - 1) {
                return getCacheLink().substring(lastSlashIndex + 1);
            } else {
                System.err.println("error retreiving archivaed name.");
            }
            return "";
        }
    
        public void fileExists() {
            File file = new File(localCacheFile());
            boolean exists = file.exists();
            if (!exists) {
                System.out.println("The cache was not downloaded correctly.");
                System.out.println("Please download it manually at:");
                System.out.println(localCacheFile());
                System.out.println("File Directory:");
                System.out.println(getCacheDir());
                pauseHandler();
                cacheDownloadError();
            } else {
                //  drawLoadingText("Your cache is downloaded and ready to un-zip!");
                pauseHandler();
                unZip();
            }
        }
    
        private void unZip() {
            try {
                InputStream in =
                        new BufferedInputStream(new FileInputStream(fileToExtract));
                ZipInputStream zin = new ZipInputStream(in);
                ZipEntry e;
                while ((e = zin.getNextEntry()) != null) {
                    if (e.isDirectory()) {
                        (new File(getCacheDir() + e.getName())).mkdir();
                    } else {
                        if (e.getName().equals(fileToExtract)) {
                            unzip(zin, fileToExtract);
                            break;
                        }
                        unzip(zin, getCacheDir() + e.getName());
                    }
                    //    drawLoadingText("[UN-ZIP]: " + e.getName());
                }
                zin.close();
                BufferedWriter versionFile = new BufferedWriter(new FileWriter(getCacheDir() + "/cacheVersion" + getCacheVersion() + ".dat"));
                versionFile.close();
                JOptionPane.showMessageDialog(frame, "Cache has been downloaded and unzipped.");
            } catch (Exception e) {
                e.printStackTrace();
            }
            pauseHandler();
            unNeededCacheExists();
        }
    
        private void unzip(ZipInputStream zin, String s)
                throws IOException {
            FileOutputStream out = new FileOutputStream(s);
            byte[] b = new byte[BUFFER];
            int len = 0;
    
            while ((len = zin.read(b)) != -1) {
                out.write(b, 0, len);
            }
        }
    
        public void unNeededCacheExists() {
            File file = new File(localCacheFile());
            boolean exists = file.exists();
            if (!exists) {
                System.out.println("Your cache was not downloaded correctly.");
                System.out.println("Please try to re re run the client.");
            } else {
                System.out.println("Your cache is on your HDD");
                System.out.println("Auto Cache Deleter Attempting to delete...");
                delete();
            }
        }
    
        public void delete() {
            try {
                File file = new File(localCacheFile());
                if (file.delete()) {
                    //  drawLoadingText("[SUCCESS]" + file.getName() + " was deleted!");
                    System.out.println("[SUCCESS]" + file.getName() + " was deleted!");
                } else {
                    //   drawLoadingText("[ERROR]" + file.getName() + " was not deleted.");
                    System.out.println("[ERROR]" + file.getName() + " was not deleted.");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public void cacheDownloadError() {
            try {
                //  drawLoadingText("Cache Download Error - Contact an admin");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public void pauseHandler() {
            try {
                Thread.currentThread().sleep(pauseHandlerDelay1000Equals1Second());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    /**
     * ***********************
     * @author Google411 ***********************
     */
    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. Question: What cache version?
    By Streax in forum Chat
    Replies: 2
    Last Post: 07-04-2010, 08:37 PM
  2. Cache Version
    By Cjay00091 in forum Help
    Replies: 0
    Last Post: 05-17-2009, 07:48 PM
  3. which cache version had...
    By joey. in forum Models
    Replies: 3
    Last Post: 03-30-2009, 11:41 PM
  4. Cache Restoring + Removal
    By CrazyPanda in forum Help
    Replies: 1
    Last Post: 03-05-2009, 04:50 AM
  5. RuneScape Cache Version Checker
    By Michael old in forum RS 503+ Client & Server
    Replies: 10
    Last Post: 02-23-2009, 05:08 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
  •