2626package net .runelite .client .plugins .microbot ;
2727
2828import lombok .RequiredArgsConstructor ;
29+ import net .runelite .api .ClientConfiguration ;
2930import net .runelite .client .RuntimeConfig ;
3031import net .runelite .client .RuntimeConfigLoader ;
3132import net .runelite .client .ui .FatalErrorDialog ;
3233import net .runelite .client .util .LinkBrowser ;
3334
3435import 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 ;
4236import java .net .MalformedURLException ;
4337import 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