Cleanup RuneLite class fields
- Remove runelite variable - Use setters for options and injector (to use them outside of tests) - Remove getter for gui and make it package-private - Use package-private gui field when providing ClientUI from RuneliteModule Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -61,11 +61,7 @@ public class RuneLite
|
||||
public static final File PLUGIN_DIR = new File(RUNELITE_DIR, "plugins");
|
||||
|
||||
private static Injector injector;
|
||||
|
||||
private static OptionSet options;
|
||||
private static RuneLite runelite;
|
||||
|
||||
private ClientUI gui;
|
||||
|
||||
@Inject
|
||||
private RuneliteProperties properties;
|
||||
@@ -95,6 +91,7 @@ public class RuneLite
|
||||
private SessionManager sessionManager;
|
||||
|
||||
Client client;
|
||||
ClientUI gui;
|
||||
Notifier notifier;
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
@@ -112,13 +109,12 @@ public class RuneLite
|
||||
OptionParser parser = new OptionParser();
|
||||
parser.accepts("developer-mode");
|
||||
parser.accepts("no-rs");
|
||||
options = parser.parse(args);
|
||||
setOptions(parser.parse(args));
|
||||
|
||||
PROFILES_DIR.mkdirs();
|
||||
|
||||
injector = Guice.createInjector(new RuneliteModule());
|
||||
runelite = injector.getInstance(RuneLite.class);
|
||||
runelite.start();
|
||||
setInjector(Guice.createInjector(new RuneliteModule()));
|
||||
injector.getInstance(RuneLite.class).start();
|
||||
}
|
||||
|
||||
public void start() throws Exception
|
||||
@@ -157,7 +153,7 @@ public class RuneLite
|
||||
log.warn("unable to set look and feel", ex);
|
||||
}
|
||||
|
||||
gui = new ClientUI(properties, client);
|
||||
setGui(new ClientUI(properties, client));
|
||||
});
|
||||
|
||||
configManager.load();
|
||||
@@ -190,11 +186,6 @@ public class RuneLite
|
||||
pluginManager.watch();
|
||||
}
|
||||
|
||||
public ClientUI getGui()
|
||||
{
|
||||
return gui;
|
||||
}
|
||||
|
||||
public void setGui(ClientUI gui)
|
||||
{
|
||||
this.gui = gui;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class RuneliteModule extends AbstractModule
|
||||
@Provides
|
||||
ClientUI provideClientUi(RuneLite runelite)
|
||||
{
|
||||
return runelite.getGui();
|
||||
return runelite.gui;
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -57,12 +57,12 @@ import net.runelite.api.queries.NPCQuery;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class VolcanicMinePlugin extends Plugin
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
RuneLite runeLite;
|
||||
ClientUI clientUI;
|
||||
|
||||
@Inject
|
||||
QueryRunner queryRunner;
|
||||
@@ -300,13 +300,13 @@ public class VolcanicMinePlugin extends Plugin
|
||||
|
||||
private void sendNotification(String message)
|
||||
{
|
||||
if (!config.alertWhenFocused() && runeLite.getGui().isFocused())
|
||||
if (!config.alertWhenFocused() && clientUI.isFocused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (config.requestFocus())
|
||||
{
|
||||
runeLite.getGui().requestFocus();
|
||||
clientUI.requestFocus();
|
||||
}
|
||||
if (config.sendTrayNotification())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user