- Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMiniClient.java
More file actions
Latest commit
93 lines (80 loc) · 3.37 KB
/
Copy pathMiniClient.java
File metadata and controls
93 lines (80 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
importjava.applet.Applet;
importjava.applet.AppletContext;
importjava.applet.AppletStub;
importjava.io.BufferedReader;
importjava.io.InputStreamReader;
importjava.net.SocketTimeoutException;
importjava.net.URL;
importjava.net.URLClassLoader;
importjava.net.URLConnection;
importjava.util.HashMap;
importjavax.swing.JFrame;
publicclassMiniClientimplementsAppletStub {
privateHashMap<String, String> parameters = newHashMap<>();
publicMiniClient() throwsException {
// Jagex adds 300 to worlds in game, so 'oldschool216' is world 516, etc.
StringgameUrl = "http://oldschool216.runescape.com/";
// Create window.
JFrameframe = newJFrame("Runescape");
frame.setSize(200, 0);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(true);
frame.setVisible(true);
// Read applet parameters, see http://oldschool1.runescape.com/jav_config.ws for example.
while (true) {
URLConnectionconnection = newURL(gameUrl + "jav_config.ws").openConnection();
connection.setConnectTimeout(1000);
connection.setReadTimeout(1000);
try (BufferedReaderreader = newBufferedReader(newInputStreamReader(connection.getInputStream()))) {
Stringline;
while ((line = reader.readLine()) != null) {
inteqIndex = line.indexOf('=');
if (eqIndex == -1) continue;
Stringname = line.substring(0, eqIndex);
if (!name.equals("msg")) {
if (name.equals("param")) {
intsecondEqIndex = line.indexOf('=', eqIndex + 2);
parameters.put(line.substring(eqIndex + 1, secondEqIndex), line.substring(secondEqIndex + 1));
} else {
parameters.put(name, line.substring(eqIndex + 1));
}
}
}
break;
} catch (SocketTimeoutExceptione) {}
}
// Load Runescape applet.
URLClassLoaderclassLoader = newURLClassLoader(newURL[] { newURL(gameUrl + parameters.get("initial_jar")) });
StringinitialClass = parameters.get("initial_class");
initialClass = initialClass.substring(0, initialClass.indexOf('.'));
Appletapplet = (Applet) classLoader.loadClass(initialClass).newInstance();
applet.setStub(this);
applet.resize(765, 503);
applet.setPreferredSize(applet.getSize());
applet.init();
applet.start();
frame.add(applet);
frame.pack();
}
publicbooleanisActive() { returntrue; }
publicURLgetDocumentBase() { returngetCodeBase(); }
publicURLgetCodeBase() {
try {
returnnewURL(parameters.get("codebase"));
} catch (Throwablee) {
returnnull;
}
}
publicStringgetParameter(Stringname) { returnparameters.get(name); }
publicAppletContextgetAppletContext() { returnnull; }
publicvoidappletResize(intwidth, intheight) {}
publicstaticvoidmain(String[] args) {
try {
System.setProperty("sun.java2d.opengl", "true");
newMiniClient();
} catch (Throwablee) {
e.printStackTrace();
System.exit(1);
}
}
}