Skip to content

Commit 0a24972

Browse files
author
Michael Zarglis
committed
fix: remove Applet dependency for non-applet OSRS client
The OSRS client no longer extends java.applet.Applet, causing a ClassCastException when running in debug mode. Changes: - MicrobotRSAppletStub: Changed from implementing AppletStub to implementing ClientConfiguration interface - MicrobotClientLoader: Changed from ((Applet) rs).setStub() to rs.setConfiguration() - RuneLiteDebug: Replaced applet.init()/start() with client.initialize() and added client.unblockStartup() after plugins start This aligns the debug client loader with the main RuneLite/ClientLoader implementation that already uses the new ClientConfiguration interface.
1 parent b4cb6b2 commit 0a24972

File tree

3 files changed

+57
-152
lines changed

3 files changed

+57
-152
lines changed

runelite-client/src/main/java/net/runelite/client/RuneLiteDebug.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import lombok.Getter;
3636
import lombok.extern.slf4j.Slf4j;
3737
import net.runelite.api.Client;
38-
import net.runelite.api.Constants;
3938
import net.runelite.client.account.SessionManager;
4039
import net.runelite.client.config.ConfigManager;
4140
import net.runelite.client.discord.DiscordService;
@@ -71,7 +70,6 @@
7170
import javax.net.ssl.TrustManagerFactory;
7271
import javax.net.ssl.X509TrustManager;
7372
import javax.swing.*;
74-
import java.applet.Applet;
7573
import java.io.File;
7674
import java.io.IOException;
7775
import java.lang.management.ManagementFactory;
@@ -331,17 +329,14 @@ public void start() throws Exception {
331329
}
332330

333331
setupSystemProps();
334-
335-
// Start the applet
332+
333+
// Start the client
336334
copyJagexCache();
337-
var applet = (Applet) client;
338-
applet.setSize(Constants.GAME_FIXED_SIZE);
339335

340336
System.setProperty("jagex.disableBouncyCastle", "true");
341337
System.setProperty("jagex.userhome", RUNELITE_DIR.getAbsolutePath());
342338

343-
applet.init();
344-
applet.start();
339+
client.initialize();
345340

346341
SplashScreen.stage(.57, null, "Loading configuration");
347342

@@ -400,6 +395,8 @@ public void start() throws Exception {
400395

401396
pluginManager.startPlugins();
402397

398+
client.unblockStartup();
399+
403400
if (telemetryClient != null) {
404401
telemetryClient.submitTelemetry();
405402
telemetryClient.submitVmErrors(LOGS_DIR);

runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotClientLoader.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@
4141

4242
import javax.annotation.Nonnull;
4343
import javax.swing.*;
44-
import java.applet.Applet;
4544
import java.io.*;
4645
import java.util.Map;
4746
import java.util.function.Supplier;
4847

4948
@Slf4j
50-
@SuppressWarnings({"deprecation", "removal"})
49+
@SuppressWarnings({"deprecation"})
5150
public class MicrobotClientLoader implements Supplier<Client>
5251
{
5352
private static final int NUM_ATTEMPTS = 6;
@@ -195,7 +194,7 @@ private Client loadClient(MicrobotRSConfig config) throws ClassNotFoundException
195194
.loadClass(initialClass);
196195

197196
Client rs = (Client) clientClass.newInstance();
198-
((Applet) rs).setStub(new MicrobotRSAppletStub(config, runtimeConfigLoader));
197+
rs.setConfiguration(new MicrobotRSAppletStub(config, runtimeConfigLoader));
199198

200199
log.info("injected-client {}", rs.getBuildID());
201200

runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotRSAppletStub.java

Lines changed: 50 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,22 @@
2626
package net.runelite.client.plugins.microbot;
2727

2828
import lombok.RequiredArgsConstructor;
29+
import net.runelite.api.ClientConfiguration;
2930
import net.runelite.client.RuntimeConfig;
3031
import net.runelite.client.RuntimeConfigLoader;
3132
import net.runelite.client.ui.FatalErrorDialog;
3233
import net.runelite.client.util.LinkBrowser;
3334

3435
import javax.swing.*;
35-
import java.applet.Applet;
36-
import java.applet.AppletContext;
37-
import java.applet.AppletStub;
38-
import java.applet.AudioClip;
39-
import java.awt.*;
40-
import java.io.IOException;
41-
import java.io.InputStream;
4236
import java.net.MalformedURLException;
4337
import java.net.URL;
44-
import java.util.Enumeration;
45-
import java.util.Iterator;
4638

4739
@RequiredArgsConstructor
48-
class MicrobotRSAppletStub implements AppletStub
40+
class MicrobotRSAppletStub implements ClientConfiguration
4941
{
5042
private final MicrobotRSConfig config;
5143
private final RuntimeConfigLoader runtimeConfigLoader;
5244

53-
@Override
54-
public boolean isActive()
55-
{
56-
return true;
57-
}
58-
59-
@Override
60-
public URL getDocumentBase()
61-
{
62-
return getCodeBase();
63-
}
64-
6545
@Override
6646
public URL getCodeBase()
6747
{
@@ -82,129 +62,58 @@ public String getParameter(String name)
8262
}
8363

8464
@Override
85-
public AppletContext getAppletContext()
65+
public void onError(String code)
8666
{
87-
return new AppletContext()
67+
try
8868
{
89-
@Override
90-
public AudioClip getAudioClip(URL url)
91-
{
92-
return null;
93-
}
94-
95-
@Override
96-
public Image getImage(URL url)
97-
{
98-
return null;
99-
}
100-
101-
@Override
102-
public Applet getApplet(String name)
103-
{
104-
return null;
105-
}
106-
107-
@Override
108-
public Enumeration<Applet> getApplets()
109-
{
110-
return null;
111-
}
112-
113-
@Override
114-
public void showDocument(URL url)
115-
{
116-
if (url.getPath().startsWith("/error_game_"))
117-
{
118-
try
119-
{
120-
RuntimeConfig rtc = runtimeConfigLoader.get();
121-
if (rtc.showOutageMessage())
122-
{
123-
return;
124-
}
125-
}
126-
catch (Exception e)
127-
{
128-
}
129-
130-
String code = url.getPath()
131-
.replace("/", "")
132-
.replace(".ws", "");
133-
134-
if (code.equals("error_game_js5connect"))
135-
{
136-
SwingUtilities.invokeLater(() ->
137-
new FatalErrorDialog("RuneLite is unable to connect to the RuneScape update server. " +
138-
"RuneScape might be offline for an update, check the game status page. If the game " +
139-
"is online, then either a firewall is blocking RuneLite, or you don't have internet access.")
140-
.setTitle("RuneLite", "Unable to connect to update server")
141-
.addButton("Game Status", () -> LinkBrowser.browse("https://secure.runescape.com/m=news/game-status-information-centre?oldschool=1"))
142-
.open());
143-
}
144-
else if (code.equals("error_game_js5io"))
145-
{
146-
SwingUtilities.invokeLater(() ->
147-
new FatalErrorDialog("OldSchool RuneScape is unable to retrieve updates from its update server. " +
148-
"This is likely due to a firewall blocking the RuneScape server. Try disabling your firewall, or use " +
149-
"a different network.")
150-
.setTitle("RuneLite", "Unable to connect to update server")
151-
.addHelpButtons()
152-
.open());
153-
}
154-
else if (code.equals("error_game_crash"))
155-
{
156-
SwingUtilities.invokeLater(() ->
157-
new FatalErrorDialog("OldSchool RuneScape has crashed. Crashes are most commonly caused by plugin hub plugins, " +
158-
"but can also be caused by RuneLite or Jagex client bugs. If you receive this message commonly, try playing in " +
159-
"safe mode to eliminate the potential of plugins causing the crash. The client log file will contain additional " +
160-
"information about the crash.")
161-
.setTitle("RuneLite", "OldSchool RuneScape has crashed")
162-
.addHelpButtons()
163-
.open());
164-
}
165-
else
166-
{
167-
SwingUtilities.invokeLater(() ->
168-
new FatalErrorDialog("OldSchool RuneScape has crashed with the message: " + code)
169-
.setTitle("RuneLite", "OldSchool RuneScape has crashed")
170-
.addHelpButtons()
171-
.open());
172-
}
173-
}
174-
}
175-
176-
@Override
177-
public void showDocument(URL url, String target)
69+
RuntimeConfig rtc = runtimeConfigLoader.get();
70+
if (rtc.showOutageMessage())
17871
{
179-
showDocument(url);
72+
return;
18073
}
74+
}
75+
catch (Exception e)
76+
{
77+
}
18178

182-
@Override
183-
public void showStatus(String status)
184-
{
185-
}
186-
187-
@Override
188-
public void setStream(String key, InputStream stream) throws IOException
189-
{
190-
}
191-
192-
@Override
193-
public InputStream getStream(String key)
194-
{
195-
return null;
196-
}
197-
198-
@Override
199-
public Iterator<String> getStreamKeys()
200-
{
201-
return null;
202-
}
203-
};
204-
}
205-
206-
@Override
207-
public void appletResize(int width, int height)
208-
{
79+
if (code.equals("error_game_js5connect"))
80+
{
81+
SwingUtilities.invokeLater(() ->
82+
new FatalErrorDialog("RuneLite is unable to connect to the RuneScape update server. " +
83+
"RuneScape might be offline for an update, check the game status page. If the game " +
84+
"is online, then either a firewall is blocking RuneLite, or you don't have internet access.")
85+
.setTitle("RuneLite", "Unable to connect to update server")
86+
.addButton("Game Status", () -> LinkBrowser.browse("https://secure.runescape.com/m=news/game-status-information-centre?oldschool=1"))
87+
.open());
88+
}
89+
else if (code.equals("error_game_js5io"))
90+
{
91+
SwingUtilities.invokeLater(() ->
92+
new FatalErrorDialog("OldSchool RuneScape is unable to retrieve updates from its update server. " +
93+
"This is likely due to a firewall blocking the RuneScape server. Try disabling your firewall, or use " +
94+
"a different network.")
95+
.setTitle("RuneLite", "Unable to connect to update server")
96+
.addHelpButtons()
97+
.open());
98+
}
99+
else if (code.equals("error_game_crash"))
100+
{
101+
SwingUtilities.invokeLater(() ->
102+
new FatalErrorDialog("OldSchool RuneScape has crashed. Crashes are most commonly caused by plugin hub plugins, " +
103+
"but can also be caused by RuneLite or Jagex client bugs. If you receive this message commonly, try playing in " +
104+
"safe mode to eliminate the potential of plugins causing the crash. The client log file will contain additional " +
105+
"information about the crash.")
106+
.setTitle("RuneLite", "OldSchool RuneScape has crashed")
107+
.addHelpButtons()
108+
.open());
109+
}
110+
else
111+
{
112+
SwingUtilities.invokeLater(() ->
113+
new FatalErrorDialog("OldSchool RuneScape has crashed with the message: " + code)
114+
.setTitle("RuneLite", "OldSchool RuneScape has crashed")
115+
.addHelpButtons()
116+
.open());
117+
}
209118
}
210119
}

0 commit comments

Comments
 (0)