gpt4 book ai didi

java - RuneScape 私有(private)服务器 - 缓存下载器

转载 作者:行者123 更新时间:2023-12-01 05:16:52 25 4
gpt4 key购买 nike

我确实有一个 RuneScape 私有(private)服务器,并且我确实有一个客户端。

我正在尝试制作一个网络客户端,我已经做到了,但由于某种原因它从我的网站下载缓存并保留在cache.zip中。它不会解压,只是下载到我创建的位置。我很困惑,需要帮助来解决这个问题,因为我向我的成员(member)保证今晚会上线。

这是下载缓存后文件夹的样子。

http://i50.tinypic.com/2iasgmw.png

应该将其中的文件提取到文件夹中。

这是我的CacheDownloader.java

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.BufferedOutputStream;
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URLConnection;
import java.net.URL;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import sign.Signlink;

public class CacheDownloader {

private Client Client;

private final int BUFFER = 1024;

private final int VERSION = 1;
private String cacheLink = "http://www.survivalpkz.com/client/cache.zip";
private String fileToExtract = getCacheDir() + getArchivedName();

public CacheDownloader(Client Client) {
this.Client = Client;
}

private void drawLoadingText(String text) {
Client.drawLoadingText(35, text);
}

private void drawLoadingText(int amount, String text) {
Client.drawLoadingText(amount, text);
}

private String getCacheDir() {
return Signlink.findCacheDir();
}

private String getCacheLink() {
return cacheLink;
}

private int getCacheVersion() {
return VERSION;
}

public CacheDownloader downloadCache() {
try {
File location = new File(getCacheDir());
File version = new File(getCacheDir() + "/cacheVersion"
+ getCacheVersion() + ".dat");

if (!location.exists()) {
downloadFile(getCacheLink(), getArchivedName());

System.out.println("Unzipping the Cache.");
unZip();
System.out.println("Cache has Unzipped.");

BufferedWriter versionFile = new BufferedWriter(new FileWriter(
getCacheDir() + "/cacheVersion" + getCacheVersion()
+ ".dat"));
versionFile.close();
} else {
if (!version.exists()) {
downloadFile(getCacheLink(), getArchivedName());

System.out.println("Unzipping the Cache.");
unZip();
System.out.println("Cache has Unzipped.");

BufferedWriter versionFile = new BufferedWriter(
new FileWriter(getCacheDir() + "/cacheVersion"
+ getCacheVersion() + ".dat"));
versionFile.close();

} else {
return null;
}
}
} catch (Exception e) {

}
return null;
}

private void downloadFile(String address, String localFileName) {
OutputStream out = null;
URLConnection conn;
InputStream in = null;

try {

URL url = new URL(address);
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);
drawLoadingText(percentage, "Downloading Cache " + percentage
+ "%");

}

System.out.println(localFileName + "\t" + numWritten);
drawLoadingText("Finished downloading " + getArchivedName() + "!");

} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
} catch (IOException ioe) {
}
}

}

private String getArchivedName() {
int lastSlashIndex = getCacheLink().lastIndexOf('/');
if (lastSlashIndex >= 0 && lastSlashIndex < getCacheLink().length() - 1) {
return getCacheLink().substring(lastSlashIndex + 1);
} else {
System.err.println("Error retreving Archive.");
}
return "";
}

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());
}
System.out.println("Unzipping: " + e.getName());
}
zin.close();

} catch (Exception e) {
e.printStackTrace();
}
}

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);
}
out.close();
}
}

最佳答案

您正在运行哪个版本?...

例如,在 718 Web 客户端中,您无需执行任何与缓存相关的操作!

我的网络客户端小程序:

<center>
<applet name="Pre-Evolution" width="900px" height="600px" archive="Pre-Evolution_Client.jar" code="Loader.class" mayscript="">
<param name="worldid" value="2"/>
<param name="members" value="1"/>
<param name="modewhat" value="2"/>
<param name="modewhere" value="2"/>
<param name="safemode" value="1"/>
<param name="lang" value="0"/>
<param name="affid" value="0"/>
<param name="settings" value="ROEqp2kbj*NX9PSCbdgpOvokkMwrCkXjg3c6KXgaLZY"/>
<param name="cookieprefix" value=""/>
<param name="cookiehost" value=".google.com"/>
<param name="plug" value="0"/>
<param name="js" value="1"/>
<param name="game" value="0"/>
<param name="colourid" value="0"/>
</applet>
</center>

关于java - RuneScape 私有(private)服务器 - 缓存下载器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11029227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com