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");
|
public static final File PLUGIN_DIR = new File(RUNELITE_DIR, "plugins");
|
||||||
|
|
||||||
private static Injector injector;
|
private static Injector injector;
|
||||||
|
|
||||||
private static OptionSet options;
|
private static OptionSet options;
|
||||||
private static RuneLite runelite;
|
|
||||||
|
|
||||||
private ClientUI gui;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RuneliteProperties properties;
|
private RuneliteProperties properties;
|
||||||
@@ -95,6 +91,7 @@ public class RuneLite
|
|||||||
private SessionManager sessionManager;
|
private SessionManager sessionManager;
|
||||||
|
|
||||||
Client client;
|
Client client;
|
||||||
|
ClientUI gui;
|
||||||
Notifier notifier;
|
Notifier notifier;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception
|
public static void main(String[] args) throws Exception
|
||||||
@@ -112,13 +109,12 @@ public class RuneLite
|
|||||||
OptionParser parser = new OptionParser();
|
OptionParser parser = new OptionParser();
|
||||||
parser.accepts("developer-mode");
|
parser.accepts("developer-mode");
|
||||||
parser.accepts("no-rs");
|
parser.accepts("no-rs");
|
||||||
options = parser.parse(args);
|
setOptions(parser.parse(args));
|
||||||
|
|
||||||
PROFILES_DIR.mkdirs();
|
PROFILES_DIR.mkdirs();
|
||||||
|
|
||||||
injector = Guice.createInjector(new RuneliteModule());
|
setInjector(Guice.createInjector(new RuneliteModule()));
|
||||||
runelite = injector.getInstance(RuneLite.class);
|
injector.getInstance(RuneLite.class).start();
|
||||||
runelite.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() throws Exception
|
public void start() throws Exception
|
||||||
@@ -157,7 +153,7 @@ public class RuneLite
|
|||||||
log.warn("unable to set look and feel", ex);
|
log.warn("unable to set look and feel", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
gui = new ClientUI(properties, client);
|
setGui(new ClientUI(properties, client));
|
||||||
});
|
});
|
||||||
|
|
||||||
configManager.load();
|
configManager.load();
|
||||||
@@ -190,11 +186,6 @@ public class RuneLite
|
|||||||
pluginManager.watch();
|
pluginManager.watch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientUI getGui()
|
|
||||||
{
|
|
||||||
return gui;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGui(ClientUI gui)
|
public void setGui(ClientUI gui)
|
||||||
{
|
{
|
||||||
this.gui = gui;
|
this.gui = gui;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class RuneliteModule extends AbstractModule
|
|||||||
@Provides
|
@Provides
|
||||||
ClientUI provideClientUi(RuneLite runelite)
|
ClientUI provideClientUi(RuneLite runelite)
|
||||||
{
|
{
|
||||||
return runelite.getGui();
|
return runelite.gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|||||||
@@ -57,12 +57,12 @@ import net.runelite.api.queries.NPCQuery;
|
|||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.events.ConfigChanged;
|
import net.runelite.client.events.ConfigChanged;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.task.Schedule;
|
import net.runelite.client.task.Schedule;
|
||||||
|
import net.runelite.client.ui.ClientUI;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.util.QueryRunner;
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class VolcanicMinePlugin extends Plugin
|
|||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RuneLite runeLite;
|
ClientUI clientUI;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
QueryRunner queryRunner;
|
QueryRunner queryRunner;
|
||||||
@@ -300,13 +300,13 @@ public class VolcanicMinePlugin extends Plugin
|
|||||||
|
|
||||||
private void sendNotification(String message)
|
private void sendNotification(String message)
|
||||||
{
|
{
|
||||||
if (!config.alertWhenFocused() && runeLite.getGui().isFocused())
|
if (!config.alertWhenFocused() && clientUI.isFocused())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (config.requestFocus())
|
if (config.requestFocus())
|
||||||
{
|
{
|
||||||
runeLite.getGui().requestFocus();
|
clientUI.requestFocus();
|
||||||
}
|
}
|
||||||
if (config.sendTrayNotification())
|
if (config.sendTrayNotification())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user