Hello rune server, i seem to be getting the following error, and i'm not sure why. i could be missing something fairly simple but i figured i'd ask for some advice anyways.
Currently messing around with swiffy's latest give to the community.
The cache link and the url link to have the "load images" load up will not work unless it's the cache itself being the problem and i don't beleive it is.
I have all my links set up correctly as far as i know anyways, yet all the client does is blackscreen whist giving me a 403 error. Yes i know what that means, and i'm not understanding what's wrong with it. Cache is packed correctly, and repacked correctly. links are live etc but the client just won't load up at all.
Would anyone be able to help me out with possibly adding the updatecache that was released Here:
[code]import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
* The custom update server to download and update the cache.
* @author Apacheah64
*/
public class Update {
/**
* The client reference.
*/
private Client c;
/**
* The cache directory.
*/
private static final String CACHE_DIR = signlink.findcachedir();
/**
* Construct a new {@code Updater} {@code Object}.
* [MENTION=75098]Para[/MENTION]m c The client reference.
*/
public Update(Client c) {
this.c = c;
}
/**
* Update the cache.
*/
public void updateCache() {
new File(CACHE_DIR).mkdirs();
File file = new File(CACHE_DIR+"rusereborn.dat");//its a check if the cache already exists
if(!file.exists()) {
c.drawLoadingText(0, "Checking for updates");
downloadArchive("http://162.218.48.74/~ruserebo/client/cache/RuseReborn.zip");
}
file = new File(CACHE_DIR+"cache.zip");
if(file.exists()) {
unzip(CACHE_DIR+"cache.zip");
}
}
/**
* Download the cache archive from the web server.
* [MENTION=75098]Para[/MENTION]m dlurl The uniform resource locater to the file that has to be downloaded.
* [MENTION=75098]Para[/MENTION]m cachePart The part of the cache that is being downloaded.
*/
private void downloadArchive(String dlurl) {
try {
URLConnection url = new URL(dlurl).openConnection();
int i = url.getContentLength();
InputStream is = url.getInputStream();
OutputStream os = new FileOutputStream(CACHE_DIR+"/cache.zip");
byte[] b = new byte[4096];
int length;
int old = 0;
while ((length = is.read(b)) != -1) {
os.write(b, 0, length);
old += length;
int percent = (int) ((double) old / (double) i * 100.0);
drawLoadingText(percent, "Checking for updates - " + percent + "%");
}
is.close();
os.close();
unzip(CACHE_DIR+"cache.zip");
File file = new File(CACHE_DIR+"rusereborn.dat");
if(!file.exists()) {
file.createNewFile();// got ya
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Unzip the cache archive part.
* [MENTION=75098]Para[/MENTION]m file The file location.
*/
private void unzip(String file) {
Enumeration<?> entries;
ZipFile zipFile;
try {
zipFile = new ZipFile(file);
entries = zipFile.entries();
while(entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry)entries.nextElement();
if(entry.isDirectory()) {
(new File(CACHE_DIR+"/"+entry.getName())).mkdir();
continue;
}
copyInputStream(zipFile.getInputStream(entry),
new BufferedOutputStream(new FileOutputStream(CACHE_DIR+"/"+entry.getName())));
drawLoadingText(100, "Unpacking Cache");
}
zipFile.close();
File zip = new File(file);
zip.delete();
} catch (IOException ioe) {
ioe.printStackTrace();
return;
}
}
/**
* Make a copy of the input stream and write it.
* [MENTION=75098]Para[/MENTION]m in The input.
* [MENTION=75098]Para[/MENTION]m out The output.
* @throws IOException
*/
private static final void copyInputStream(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int len;
while((len = in.read(buffer)) >= 0) {
out.write(buffer, 0, len);
}
in.close();
out.close();
}
private static void drawLoadingText(int amount, String text) {
Client.loadingPercentage = amount;
Client.loadingText = text;
}
}
[/code]
Thankyou very much. Pm me if you'd like to assist me