Merge pull request #270 from deathbeam/runelite-cleanup
Decouple RuneLite class
This commit is contained in:
@@ -28,10 +28,44 @@ import java.applet.Applet;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Optional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.http.api.updatecheck.UpdateCheckClient;
|
||||
|
||||
@Slf4j
|
||||
public class ClientLoader
|
||||
{
|
||||
public Applet loadRunelite() throws ClassNotFoundException, IOException, InstantiationException, IllegalAccessException
|
||||
public Optional<Applet> loadRs()
|
||||
{
|
||||
final UpdateCheckClient updateCheck = new UpdateCheckClient();
|
||||
boolean isOutdated = updateCheck.isOutdated();
|
||||
|
||||
try
|
||||
{
|
||||
if (isOutdated)
|
||||
{
|
||||
log.info("Runelite is outdated - fetching vanilla client");
|
||||
return Optional.of(loadVanilla());
|
||||
}
|
||||
|
||||
log.debug("Runelite is up to date");
|
||||
return Optional.of(loadRunelite());
|
||||
}
|
||||
catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e)
|
||||
{
|
||||
if (e instanceof ClassNotFoundException)
|
||||
{
|
||||
log.error("Unable to load client - class not found. This means you"
|
||||
+ " are not running RuneLite with Maven as the injected client"
|
||||
+ " is not in your classpath.");
|
||||
}
|
||||
|
||||
log.error("Error loading RS!", e);
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
private Applet loadRunelite() throws ClassNotFoundException, IOException, InstantiationException, IllegalAccessException
|
||||
{
|
||||
ConfigLoader config = new ConfigLoader();
|
||||
|
||||
@@ -48,7 +82,7 @@ public class ClientLoader
|
||||
return rs;
|
||||
}
|
||||
|
||||
public Applet loadVanilla() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
|
||||
private Applet loadVanilla() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
|
||||
{
|
||||
ConfigLoader config = new ConfigLoader();
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ package net.runelite.client;
|
||||
|
||||
import com.google.common.escape.Escaper;
|
||||
import com.google.common.escape.Escapers;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.TrayIcon;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -35,7 +36,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
public class Notifier
|
||||
{
|
||||
private static enum OSType
|
||||
private enum OSType
|
||||
{
|
||||
Windows, MacOS, Linux, Other
|
||||
};
|
||||
@@ -74,14 +75,28 @@ public class Notifier
|
||||
log.debug("Detect OS: {}", DETECTED_OS);
|
||||
}
|
||||
|
||||
private final String appName;
|
||||
private final TrayIcon trayIcon;
|
||||
|
||||
public Notifier(final TrayIcon trayIcon)
|
||||
Notifier(final String appName, final TrayIcon trayIcon)
|
||||
{
|
||||
this.appName = appName;
|
||||
this.trayIcon = trayIcon;
|
||||
}
|
||||
|
||||
public void sendNotification(
|
||||
|
||||
public void notify(String message)
|
||||
{
|
||||
notify(message, TrayIcon.MessageType.NONE);
|
||||
}
|
||||
|
||||
public void notify(String message, TrayIcon.MessageType type)
|
||||
{
|
||||
sendNotification(appName, message, type, null);
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
}
|
||||
|
||||
private void sendNotification(
|
||||
final String title,
|
||||
final String message,
|
||||
final TrayIcon.MessageType type,
|
||||
|
||||
@@ -24,51 +24,27 @@
|
||||
*/
|
||||
package net.runelite.client;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Image;
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.applet.Applet;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.ToolTipManager;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.client.account.AccountSession;
|
||||
import net.runelite.client.account.SessionManager;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.events.SessionClose;
|
||||
import net.runelite.client.events.SessionOpen;
|
||||
import net.runelite.client.menus.MenuManager;
|
||||
import net.runelite.client.plugins.PluginManager;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.overlay.OverlayRenderer;
|
||||
import net.runelite.http.api.account.AccountClient;
|
||||
import org.pushingpixels.substance.api.skin.SubstanceGraphiteLookAndFeel;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@@ -76,19 +52,10 @@ public class RuneLite
|
||||
{
|
||||
public static final File RUNELITE_DIR = new File(System.getProperty("user.home"), ".runelite");
|
||||
public static final File PROFILES_DIR = new File(RUNELITE_DIR, "profiles");
|
||||
public static final File SESSION_FILE = new File(RUNELITE_DIR, "session");
|
||||
public static final File PLUGIN_DIR = new File(RUNELITE_DIR, "plugins");
|
||||
|
||||
public static Image ICON;
|
||||
|
||||
private static Injector injector;
|
||||
|
||||
private static OptionSet options;
|
||||
private static RuneLite runelite;
|
||||
private static TrayIcon trayIcon;
|
||||
|
||||
private Client client;
|
||||
private ClientUI gui;
|
||||
|
||||
@Inject
|
||||
private RuneliteProperties properties;
|
||||
@@ -114,79 +81,65 @@ public class RuneLite
|
||||
@Inject
|
||||
private OverlayRenderer overlayRenderer;
|
||||
|
||||
private WSClient wsclient;
|
||||
@Inject
|
||||
private SessionManager sessionManager;
|
||||
|
||||
private AccountSession accountSession;
|
||||
|
||||
private Notifier notifier;
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
final URL icon = ClientUI.class.getResource("/runelite.png");
|
||||
ICON = ImageIO.read(icon.openStream());
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn(null, ex);
|
||||
}
|
||||
}
|
||||
Client client;
|
||||
ClientUI gui;
|
||||
Notifier notifier;
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
// Force heavy-weight popups/tooltips.
|
||||
// Prevents them from being obscured by the game applet.
|
||||
ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
|
||||
// Do not render shadows under popups/tooltips.
|
||||
// Fixes black boxes under popups that are above the game applet.
|
||||
System.setProperty("jgoodies.popupDropShadowEnabled", "false");
|
||||
// Do not fill in background on repaint. Reduces flickering when
|
||||
// the applet is resized.
|
||||
System.setProperty("sun.awt.noerasebackground", "true");
|
||||
|
||||
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
|
||||
{
|
||||
SwingUtilities.invokeAndWait(() ->
|
||||
// Load Runelite or Vanilla client
|
||||
final boolean hasRs = !getOptions().has("no-rs");
|
||||
final Optional<Applet> optionalClient = hasRs
|
||||
? new ClientLoader().loadRs()
|
||||
: Optional.empty();
|
||||
|
||||
if (!optionalClient.isPresent() && hasRs)
|
||||
{
|
||||
JFrame.setDefaultLookAndFeelDecorated(true);
|
||||
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
||||
System.exit(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
UIManager.setLookAndFeel(new SubstanceGraphiteLookAndFeel());
|
||||
}
|
||||
catch (UnsupportedLookAndFeelException ex)
|
||||
{
|
||||
log.warn("unable to set look and feel", ex);
|
||||
}
|
||||
final Applet client = optionalClient.orElseGet(null);
|
||||
final boolean isOutdated = client == null || !(client instanceof Client);
|
||||
|
||||
gui = new ClientUI(this);
|
||||
setTitle(null);
|
||||
if (!isOutdated)
|
||||
{
|
||||
this.client = (Client) client;
|
||||
}
|
||||
|
||||
setupTrayIcon();
|
||||
});
|
||||
// Load swing UI
|
||||
SwingUtilities.invokeAndWait(() -> setGui(ClientUI.create(properties, client)));
|
||||
|
||||
// Load default configuration
|
||||
configManager.load();
|
||||
|
||||
// Register event listeners
|
||||
eventBus.register(overlayRenderer);
|
||||
eventBus.register(menuManager);
|
||||
eventBus.register(chatMessageManager);
|
||||
|
||||
// Setup the notifier
|
||||
notifier = new Notifier(trayIcon);
|
||||
notifier = new Notifier(properties.getTitle(), gui.getTrayIcon());
|
||||
|
||||
// Tell the plugin manager if client is outdated or not
|
||||
pluginManager.setOutdated(isOutdated);
|
||||
|
||||
// Load the plugins, but does not start them yet.
|
||||
// This will initialize configuration
|
||||
@@ -200,185 +153,12 @@ public class RuneLite
|
||||
pluginManager.startCorePlugins();
|
||||
|
||||
// Load the session, including saved configuration
|
||||
loadSession();
|
||||
sessionManager.loadSession();
|
||||
|
||||
// Begin watching for new plugins
|
||||
pluginManager.watch();
|
||||
}
|
||||
|
||||
public void setTitle(String extra)
|
||||
{
|
||||
if (!Strings.isNullOrEmpty(extra))
|
||||
{
|
||||
gui.setTitle(properties.getTitle() + " " + properties.getVersion() + " " + extra);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui.setTitle(properties.getTitle() + " " + properties.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
private void setupTrayIcon()
|
||||
{
|
||||
if (!SystemTray.isSupported())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SystemTray systemTray = SystemTray.getSystemTray();
|
||||
|
||||
trayIcon = new TrayIcon(ICON, properties.getTitle());
|
||||
trayIcon.setImageAutoSize(true);
|
||||
|
||||
try
|
||||
{
|
||||
systemTray.add(trayIcon);
|
||||
}
|
||||
catch (AWTException ex)
|
||||
{
|
||||
log.debug("Unable to add system tray icon", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
// bring to front when tray icon is clicked
|
||||
trayIcon.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
gui.setVisible(true);
|
||||
gui.setState(Frame.NORMAL); // unminimize
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadSession()
|
||||
{
|
||||
if (!SESSION_FILE.exists())
|
||||
{
|
||||
log.info("No session file exists");
|
||||
return;
|
||||
}
|
||||
|
||||
AccountSession session;
|
||||
|
||||
try (FileInputStream in = new FileInputStream(SESSION_FILE))
|
||||
{
|
||||
session = new Gson().fromJson(new InputStreamReader(in), AccountSession.class);
|
||||
|
||||
log.debug("Loaded session for {}", session.getUsername());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.warn("Unable to load session file", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if session is still valid
|
||||
AccountClient accountClient = new AccountClient(session.getUuid());
|
||||
if (!accountClient.sesssionCheck())
|
||||
{
|
||||
log.debug("Loaded session {} is invalid", session.getUuid());
|
||||
return;
|
||||
}
|
||||
|
||||
openSession(session);
|
||||
}
|
||||
|
||||
public void saveSession()
|
||||
{
|
||||
if (accountSession == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try (FileWriter fw = new FileWriter(SESSION_FILE))
|
||||
{
|
||||
new Gson().toJson(accountSession, fw);
|
||||
|
||||
log.debug("Saved session to {}", SESSION_FILE);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn("Unable to save session file", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteSession()
|
||||
{
|
||||
SESSION_FILE.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the given session as the active session and open a socket to the
|
||||
* server with the given session
|
||||
*
|
||||
* @param session
|
||||
*/
|
||||
public void openSession(AccountSession session)
|
||||
{
|
||||
// If the ws session already exists, don't need to do anything
|
||||
if (wsclient == null || !wsclient.getSession().equals(session))
|
||||
{
|
||||
if (wsclient != null)
|
||||
{
|
||||
wsclient.close();
|
||||
}
|
||||
|
||||
wsclient = new WSClient(eventBus, executor, session);
|
||||
wsclient.connect();
|
||||
}
|
||||
|
||||
accountSession = session;
|
||||
|
||||
if (session.getUsername() != null)
|
||||
{
|
||||
// Initialize config for new session
|
||||
// If the session isn't logged in yet, don't switch to the new config
|
||||
configManager.switchSession(session);
|
||||
}
|
||||
|
||||
eventBus.post(new SessionOpen());
|
||||
}
|
||||
|
||||
public void closeSession()
|
||||
{
|
||||
if (wsclient != null)
|
||||
{
|
||||
wsclient.close();
|
||||
wsclient = null;
|
||||
}
|
||||
|
||||
if (accountSession == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
log.debug("Logging out of account {}", accountSession.getUsername());
|
||||
|
||||
accountSession = null; // No more account
|
||||
|
||||
// Restore config
|
||||
configManager.switchSession(null);
|
||||
|
||||
eventBus.post(new SessionClose());
|
||||
}
|
||||
|
||||
public Client getClient()
|
||||
{
|
||||
return client;
|
||||
}
|
||||
|
||||
public void setClient(Client client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public ClientUI getGui()
|
||||
{
|
||||
return gui;
|
||||
}
|
||||
|
||||
public void setGui(ClientUI gui)
|
||||
{
|
||||
this.gui = gui;
|
||||
@@ -403,30 +183,4 @@ public class RuneLite
|
||||
{
|
||||
RuneLite.options = options;
|
||||
}
|
||||
|
||||
public static TrayIcon getTrayIcon()
|
||||
{
|
||||
return trayIcon;
|
||||
}
|
||||
|
||||
public void notify(String message)
|
||||
{
|
||||
notify(message, TrayIcon.MessageType.NONE);
|
||||
}
|
||||
|
||||
public void notify(String message, TrayIcon.MessageType type)
|
||||
{
|
||||
notifier.sendNotification(properties.getTitle(), message, type, null);
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
}
|
||||
|
||||
public AccountSession getAccountSession()
|
||||
{
|
||||
return accountSession;
|
||||
}
|
||||
|
||||
public <T> T[] runQuery(Query query)
|
||||
{
|
||||
return (T[]) query.result(client);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.client.account.SessionManager;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.config.RuneliteConfig;
|
||||
@@ -42,6 +43,7 @@ import net.runelite.client.plugins.PluginManager;
|
||||
import net.runelite.client.task.Scheduler;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
@Slf4j
|
||||
public class RuneliteModule extends AbstractModule
|
||||
@@ -50,6 +52,7 @@ public class RuneliteModule extends AbstractModule
|
||||
protected void configure()
|
||||
{
|
||||
bind(ScheduledExecutorService.class).toInstance(Executors.newSingleThreadScheduledExecutor());
|
||||
bind(QueryRunner.class);
|
||||
bind(MenuManager.class);
|
||||
bind(ChatMessageManager.class);
|
||||
bind(ItemManager.class);
|
||||
@@ -57,18 +60,25 @@ public class RuneliteModule extends AbstractModule
|
||||
bind(Scheduler.class);
|
||||
bind(PluginManager.class);
|
||||
bind(RuneliteProperties.class);
|
||||
bind(SessionManager.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
Client provideClient(RuneLite runelite)
|
||||
Client provideClient(RuneLite runeLite)
|
||||
{
|
||||
return runelite.getClient();
|
||||
return runeLite.client;
|
||||
}
|
||||
|
||||
@Provides
|
||||
ClientUI provideClientUi(RuneLite runelite)
|
||||
{
|
||||
return runelite.getGui();
|
||||
return runelite.gui;
|
||||
}
|
||||
|
||||
@Provides
|
||||
Notifier provideNotifier(RuneLite runeLite)
|
||||
{
|
||||
return runeLite.notifier;
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.account;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.gson.Gson;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.events.SessionClose;
|
||||
import net.runelite.client.events.SessionOpen;
|
||||
import net.runelite.http.api.account.AccountClient;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
public class SessionManager
|
||||
{
|
||||
private static final File SESSION_FILE = new File(RuneLite.RUNELITE_DIR, "session");
|
||||
private WSClient wsclient;
|
||||
|
||||
@Getter
|
||||
private AccountSession accountSession;
|
||||
|
||||
@Inject
|
||||
private EventBus eventBus;
|
||||
|
||||
@Inject
|
||||
private ConfigManager configManager;
|
||||
|
||||
@Inject
|
||||
private ScheduledExecutorService executor;
|
||||
|
||||
public void loadSession()
|
||||
{
|
||||
if (!SESSION_FILE.exists())
|
||||
{
|
||||
log.info("No session file exists");
|
||||
return;
|
||||
}
|
||||
|
||||
AccountSession session;
|
||||
|
||||
try (FileInputStream in = new FileInputStream(SESSION_FILE))
|
||||
{
|
||||
session = new Gson().fromJson(new InputStreamReader(in), AccountSession.class);
|
||||
|
||||
log.debug("Loaded session for {}", session.getUsername());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.warn("Unable to load session file", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if session is still valid
|
||||
AccountClient accountClient = new AccountClient(session.getUuid());
|
||||
if (!accountClient.sesssionCheck())
|
||||
{
|
||||
log.debug("Loaded session {} is invalid", session.getUuid());
|
||||
return;
|
||||
}
|
||||
|
||||
openSession(session);
|
||||
}
|
||||
|
||||
public void saveSession()
|
||||
{
|
||||
if (accountSession == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try (FileWriter fw = new FileWriter(SESSION_FILE))
|
||||
{
|
||||
new Gson().toJson(accountSession, fw);
|
||||
|
||||
log.debug("Saved session to {}", SESSION_FILE);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn("Unable to save session file", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteSession()
|
||||
{
|
||||
SESSION_FILE.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the given session as the active session and open a socket to the
|
||||
* server with the given session
|
||||
*
|
||||
* @param session
|
||||
*/
|
||||
public void openSession(AccountSession session)
|
||||
{
|
||||
// If the ws session already exists, don't need to do anything
|
||||
if (wsclient == null || !wsclient.getSession().equals(session))
|
||||
{
|
||||
if (wsclient != null)
|
||||
{
|
||||
wsclient.close();
|
||||
}
|
||||
|
||||
wsclient = new WSClient(eventBus, executor, session);
|
||||
wsclient.connect();
|
||||
}
|
||||
|
||||
accountSession = session;
|
||||
|
||||
if (session.getUsername() != null)
|
||||
{
|
||||
// Initialize config for new session
|
||||
// If the session isn't logged in yet, don't switch to the new config
|
||||
configManager.switchSession(session);
|
||||
}
|
||||
|
||||
eventBus.post(new SessionOpen());
|
||||
}
|
||||
|
||||
public void closeSession()
|
||||
{
|
||||
if (wsclient != null)
|
||||
{
|
||||
wsclient.close();
|
||||
wsclient = null;
|
||||
}
|
||||
|
||||
if (accountSession == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
log.debug("Logging out of account {}", accountSession.getUsername());
|
||||
|
||||
accountSession = null; // No more account
|
||||
|
||||
// Restore config
|
||||
configManager.switchSession(null);
|
||||
|
||||
eventBus.post(new SessionClose());
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client;
|
||||
package net.runelite.client.account;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.gson.Gson;
|
||||
@@ -32,12 +32,11 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.account.AccountSession;
|
||||
import net.runelite.http.api.RuneliteAPI;
|
||||
import net.runelite.http.api.ws.messages.Handshake;
|
||||
import net.runelite.http.api.ws.messages.Ping;
|
||||
import net.runelite.http.api.ws.WebsocketGsonFactory;
|
||||
import net.runelite.http.api.ws.WebsocketMessage;
|
||||
import net.runelite.http.api.ws.messages.Handshake;
|
||||
import net.runelite.http.api.ws.messages.Ping;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
@@ -38,4 +38,6 @@ public @interface PluginDescriptor
|
||||
String name();
|
||||
|
||||
boolean developerPlugin() default false;
|
||||
|
||||
boolean loadWhenOutdated() default false;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import javax.inject.Singleton;
|
||||
import javax.swing.SwingUtilities;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.events.PluginChanged;
|
||||
@@ -67,6 +68,9 @@ public class PluginManager
|
||||
@Inject
|
||||
PluginWatcher pluginWatcher;
|
||||
|
||||
@Setter
|
||||
boolean isOutdated;
|
||||
|
||||
private final List<Plugin> plugins = new CopyOnWriteArrayList<>();
|
||||
|
||||
public void loadCorePlugins() throws IOException
|
||||
@@ -127,6 +131,11 @@ public class PluginManager
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!pluginDescriptor.loadWhenOutdated() && isOutdated)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pluginDescriptor.developerPlugin() && !developerPlugins)
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -35,8 +35,8 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.account.AccountSession;
|
||||
import net.runelite.client.account.SessionManager;
|
||||
import net.runelite.client.events.SessionClose;
|
||||
import net.runelite.client.events.SessionOpen;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
@@ -56,7 +56,7 @@ import net.runelite.http.api.ws.messages.LoginResponse;
|
||||
public class AccountPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
RuneLite runelite;
|
||||
SessionManager sessionManager;
|
||||
|
||||
@Inject
|
||||
ClientUI ui;
|
||||
@@ -87,7 +87,7 @@ public class AccountPlugin extends Plugin
|
||||
private void logoutClick(ActionEvent ae)
|
||||
{
|
||||
// Destroy session
|
||||
AccountSession session = runelite.getAccountSession();
|
||||
AccountSession session = sessionManager.getAccountSession();
|
||||
if (session != null)
|
||||
{
|
||||
AccountClient client = new AccountClient(session.getUuid());
|
||||
@@ -101,8 +101,8 @@ public class AccountPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
runelite.closeSession(); // remove session from client
|
||||
runelite.deleteSession(); // delete saved session file
|
||||
sessionManager.closeSession(); // remove session from client
|
||||
sessionManager.deleteSession(); // delete saved session file
|
||||
|
||||
// Replace logout nav button with login
|
||||
PluginToolbar navigationPanel = ui.getPluginToolbar();
|
||||
@@ -129,7 +129,7 @@ public class AccountPlugin extends Plugin
|
||||
session.setUuid(login.getUid());
|
||||
session.setCreated(Instant.now());
|
||||
|
||||
runelite.openSession(session);
|
||||
sessionManager.openSession(session);
|
||||
|
||||
if (!Desktop.isDesktopSupported())
|
||||
{
|
||||
@@ -161,21 +161,21 @@ public class AccountPlugin extends Plugin
|
||||
{
|
||||
log.debug("Now logged in as {}", loginResponse.getUsername());
|
||||
|
||||
AccountSession session = runelite.getAccountSession();
|
||||
AccountSession session = sessionManager.getAccountSession();
|
||||
session.setUsername(loginResponse.getUsername());
|
||||
|
||||
// Open session, again, now that we have a username
|
||||
// This triggers onSessionOpen
|
||||
runelite.openSession(session);
|
||||
sessionManager.openSession(session);
|
||||
|
||||
// Save session to disk
|
||||
runelite.saveSession();
|
||||
sessionManager.saveSession();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onSessionOpen(SessionOpen sessionOpen)
|
||||
{
|
||||
AccountSession session = runelite.getAccountSession();
|
||||
AccountSession session = sessionManager.getAccountSession();
|
||||
|
||||
if (session.getUsername() == null)
|
||||
{
|
||||
@@ -184,7 +184,7 @@ public class AccountPlugin extends Plugin
|
||||
|
||||
log.debug("Session opened as {}", session.getUsername());
|
||||
|
||||
runelite.setTitle("(" + session.getUsername() + ")");
|
||||
ui.setTitle("(" + session.getUsername() + ")");
|
||||
|
||||
replaceLoginWithLogout();
|
||||
}
|
||||
@@ -200,7 +200,7 @@ public class AccountPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onSessionClose(SessionClose sessionClose)
|
||||
{
|
||||
runelite.setTitle(null);
|
||||
ui.setTitle(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.attackindicator;
|
||||
|
||||
import static net.runelite.client.plugins.attackindicator.AttackStyle.CASTING;
|
||||
import static net.runelite.client.plugins.attackindicator.AttackStyle.DEFENSIVE_CASTING;
|
||||
import static net.runelite.client.plugins.attackindicator.AttackStyle.OTHER;
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import com.google.common.collect.Table;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
@@ -32,7 +35,6 @@ import com.google.inject.Provides;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
@@ -45,7 +47,6 @@ import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.events.VarbitChanged;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import static net.runelite.client.plugins.attackindicator.AttackStyle.*;
|
||||
import net.runelite.client.task.Schedule;
|
||||
|
||||
@PluginDescriptor(
|
||||
@@ -63,7 +64,6 @@ public class AttackIndicatorPlugin extends Plugin
|
||||
private final Table<WeaponType, WidgetInfo, Boolean> widgetsToHide = HashBasedTable.create();
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
@@ -69,7 +68,6 @@ public class ChatCommandsPlugin extends Plugin
|
||||
private final HiscoreClient hiscoreClient = new HiscoreClient();
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -39,7 +39,6 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -77,7 +76,6 @@ public class ClanChatPlugin extends Plugin
|
||||
private int modIconsLength;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.google.inject.Binder;
|
||||
import com.google.inject.Provides;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
@@ -47,7 +46,6 @@ import net.runelite.client.task.Schedule;
|
||||
public class ClueScrollPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -27,7 +27,6 @@ package net.runelite.client.plugins.combatlevel;
|
||||
import com.google.inject.Provides;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Experience;
|
||||
@@ -48,7 +47,6 @@ public class CombatLevelPlugin extends Plugin
|
||||
private final DecimalFormat decimalFormat = new DecimalFormat("#.###");
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
@@ -66,7 +64,7 @@ public class CombatLevelPlugin extends Plugin
|
||||
)
|
||||
public void updateCombatLevel()
|
||||
{
|
||||
if (client == null || client.getGameState() != GameState.LOGGED_IN)
|
||||
if (client.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class FightCaveOverlay extends Overlay
|
||||
public Dimension render(Graphics2D graphics, Point parent)
|
||||
{
|
||||
JadAttack attack = plugin.getAttack();
|
||||
if (attack == null || client == null || client.isPrayerActive(attack.getPrayer()))
|
||||
if (attack == null || client.isPrayerActive(attack.getPrayer()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -25,22 +25,20 @@
|
||||
package net.runelite.client.plugins.fightcave;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.queries.NPCQuery;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Fight cave plugin"
|
||||
@@ -48,11 +46,10 @@ import net.runelite.client.ui.overlay.Overlay;
|
||||
public class FightCavePlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
RuneLite runelite;
|
||||
QueryRunner queryRunner;
|
||||
|
||||
@Inject
|
||||
FightCaveConfig config;
|
||||
@@ -86,7 +83,7 @@ public class FightCavePlugin extends Plugin
|
||||
)
|
||||
public void update()
|
||||
{
|
||||
if (!config.enabled() || client == null || client.getGameState() != GameState.LOGGED_IN)
|
||||
if (!config.enabled() || client.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -112,7 +109,7 @@ public class FightCavePlugin extends Plugin
|
||||
private NPC findJad()
|
||||
{
|
||||
Query query = new NPCQuery().nameContains("TzTok-Jad");
|
||||
NPC[] result = runelite.runQuery(query);
|
||||
NPC[] result = queryRunner.runQuery(query);
|
||||
return result.length >= 1 ? result[0] : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,34 +32,30 @@ import java.awt.Point;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.queries.NPCQuery;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
class FishingSpotOverlay extends Overlay
|
||||
{
|
||||
private final List<Integer> ids = new ArrayList<>();
|
||||
|
||||
private final RuneLite runelite;
|
||||
private final Client client;
|
||||
private final QueryRunner queryRunner;
|
||||
private final FishingConfig config;
|
||||
|
||||
@Inject
|
||||
ItemManager itemManager;
|
||||
|
||||
@Inject
|
||||
public FishingSpotOverlay(RuneLite runelite, @Nullable Client client, FishingConfig config)
|
||||
public FishingSpotOverlay(QueryRunner queryRunner, FishingConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
this.runelite = runelite;
|
||||
this.client = client;
|
||||
this.queryRunner = queryRunner;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@@ -73,7 +69,7 @@ class FishingSpotOverlay extends Overlay
|
||||
|
||||
NPCQuery query = new NPCQuery()
|
||||
.idEquals(Ints.toArray(ids));
|
||||
NPC[] npcs = runelite.runQuery(query);
|
||||
NPC[] npcs = queryRunner.runQuery(query);
|
||||
|
||||
for (NPC npc : npcs)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,8 @@ import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Hiscore plugin"
|
||||
name = "Hiscore plugin",
|
||||
loadWhenOutdated = true
|
||||
)
|
||||
public class HiscorePlugin extends Plugin
|
||||
{
|
||||
|
||||
@@ -31,9 +31,9 @@ import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
@@ -47,7 +47,6 @@ import net.runelite.api.Player;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.queries.GameObjectQuery;
|
||||
import net.runelite.api.queries.PlayerQuery;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.events.GameObjectsChanged;
|
||||
@@ -56,6 +55,7 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
@Slf4j
|
||||
@PluginDescriptor(
|
||||
@@ -67,7 +67,7 @@ public class HunterPlugin extends Plugin
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private RuneLite runelite;
|
||||
private QueryRunner queryRunner;
|
||||
|
||||
@Inject
|
||||
private HunterConfig config;
|
||||
@@ -139,7 +139,7 @@ public class HunterPlugin extends Plugin
|
||||
case ObjectID.NET_TRAP_9002: //Net trap placed at black sallys
|
||||
//Look for players that are on the same tile
|
||||
PlayerQuery playerQuery = new PlayerQuery().atLocalLocation(gameObject.getLocalLocation());
|
||||
List<Player> possiblePlayers = Arrays.asList(runelite.runQuery(playerQuery));
|
||||
List<Player> possiblePlayers = Arrays.asList(queryRunner.runQuery(playerQuery));
|
||||
|
||||
/* If the player is on that tile, and it has the correct animation, assume he is the one that placed the trap
|
||||
* Special case: if you herb+tar, then move and place the trap, it does not detect laying the trap. It does work
|
||||
@@ -294,7 +294,7 @@ public class HunterPlugin extends Plugin
|
||||
GameObjectQuery goQuery = new GameObjectQuery()
|
||||
.atWorldLocation(trap.getGameObject().getWorldLocation());
|
||||
//This is for placeable traps like box traps. There are no gameobjects on that location if the trap collapsed
|
||||
if (runelite.runQuery(goQuery).length == 0)
|
||||
if (queryRunner.runQuery(goQuery).length == 0)
|
||||
{
|
||||
it.remove();
|
||||
log.debug("Trap removed from personal trap collection, {} left", traps.size());
|
||||
@@ -303,7 +303,7 @@ public class HunterPlugin extends Plugin
|
||||
{
|
||||
goQuery = goQuery
|
||||
.idEquals(ObjectID.BOULDER_19215); //Deadfalls are the only ones (that i can test) that have this behaviour. I think maniacal monkeys have this too.
|
||||
if (runelite.runQuery(goQuery).length != 0)
|
||||
if (queryRunner.runQuery(goQuery).length != 0)
|
||||
{
|
||||
it.remove();
|
||||
log.debug("Special trap removed from personal trap collection, {} left", traps.size());
|
||||
|
||||
@@ -25,20 +25,81 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.idlenotifier;
|
||||
|
||||
import static net.runelite.api.AnimationID.COOKING_FIRE;
|
||||
import static net.runelite.api.AnimationID.COOKING_RANGE;
|
||||
import static net.runelite.api.AnimationID.CRAFTING_GLASSBLOWING;
|
||||
import static net.runelite.api.AnimationID.FISHING_CAGE;
|
||||
import static net.runelite.api.AnimationID.FISHING_HARPOON;
|
||||
import static net.runelite.api.AnimationID.FISHING_KARAMBWAN;
|
||||
import static net.runelite.api.AnimationID.FISHING_NET;
|
||||
import static net.runelite.api.AnimationID.FISHING_POLE_CAST;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_BOW_CUTTING;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_MAGIC_LONGBOW;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_MAGIC_SHORTBOW;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_MAPLE_LONGBOW;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_MAPLE_SHORTBOW;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_NORMAL_LONGBOW;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_NORMAL_SHORTBOW;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_OAK_LONGBOW;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_OAK_SHORTBOW;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_WILLOW_LONGBOW;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_WILLOW_SHORTBOW;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_YEW_LONGBOW;
|
||||
import static net.runelite.api.AnimationID.FLETCHING_STRING_YEW_SHORTBOW;
|
||||
import static net.runelite.api.AnimationID.GEM_CUTTING_DIAMOND;
|
||||
import static net.runelite.api.AnimationID.GEM_CUTTING_EMERALD;
|
||||
import static net.runelite.api.AnimationID.GEM_CUTTING_JADE;
|
||||
import static net.runelite.api.AnimationID.GEM_CUTTING_OPAL;
|
||||
import static net.runelite.api.AnimationID.GEM_CUTTING_REDTOPAZ;
|
||||
import static net.runelite.api.AnimationID.GEM_CUTTING_RUBY;
|
||||
import static net.runelite.api.AnimationID.GEM_CUTTING_SAPPHIRE;
|
||||
import static net.runelite.api.AnimationID.HERBLORE_POTIONMAKING;
|
||||
import static net.runelite.api.AnimationID.IDLE;
|
||||
import static net.runelite.api.AnimationID.MAGIC_CHARGING_ORBS;
|
||||
import static net.runelite.api.AnimationID.MINING_ADAMANT_PICKAXE;
|
||||
import static net.runelite.api.AnimationID.MINING_BLACK_PICKAXE;
|
||||
import static net.runelite.api.AnimationID.MINING_BRONZE_PICKAXE;
|
||||
import static net.runelite.api.AnimationID.MINING_DRAGON_PICKAXE;
|
||||
import static net.runelite.api.AnimationID.MINING_DRAGON_PICKAXE_ORN;
|
||||
import static net.runelite.api.AnimationID.MINING_INFERNAL_PICKAXE;
|
||||
import static net.runelite.api.AnimationID.MINING_IRON_PICKAXE;
|
||||
import static net.runelite.api.AnimationID.MINING_MITHRIL_PICKAXE;
|
||||
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_ADAMANT;
|
||||
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_BLACK;
|
||||
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_BRONZE;
|
||||
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_DRAGON;
|
||||
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_DRAGON_ORN;
|
||||
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_INFERNAL;
|
||||
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_IRON;
|
||||
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_MITHRIL;
|
||||
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_RUNE;
|
||||
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_STEEL;
|
||||
import static net.runelite.api.AnimationID.MINING_RUNE_PICKAXE;
|
||||
import static net.runelite.api.AnimationID.MINING_STEEL_PICKAXE;
|
||||
import static net.runelite.api.AnimationID.SMITHING_ANVIL;
|
||||
import static net.runelite.api.AnimationID.SMITHING_CANNONBALL;
|
||||
import static net.runelite.api.AnimationID.SMITHING_SMELTING;
|
||||
import static net.runelite.api.AnimationID.WOODCUTTING_ADAMANT;
|
||||
import static net.runelite.api.AnimationID.WOODCUTTING_BLACK;
|
||||
import static net.runelite.api.AnimationID.WOODCUTTING_BRONZE;
|
||||
import static net.runelite.api.AnimationID.WOODCUTTING_DRAGON;
|
||||
import static net.runelite.api.AnimationID.WOODCUTTING_INFERNAL;
|
||||
import static net.runelite.api.AnimationID.WOODCUTTING_IRON;
|
||||
import static net.runelite.api.AnimationID.WOODCUTTING_MITHRIL;
|
||||
import static net.runelite.api.AnimationID.WOODCUTTING_RUNE;
|
||||
import static net.runelite.api.AnimationID.WOODCUTTING_STEEL;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Provides;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Actor;
|
||||
import static net.runelite.api.AnimationID.*;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.events.AnimationChanged;
|
||||
import net.runelite.client.events.GameStateChanged;
|
||||
@@ -53,13 +114,12 @@ import net.runelite.client.ui.ClientUI;
|
||||
public class IdleNotifierPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
RuneLite runelite;
|
||||
Notifier notifier;
|
||||
|
||||
@Inject
|
||||
ClientUI gui;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
@@ -260,7 +320,7 @@ public class IdleNotifierPlugin extends Plugin
|
||||
}
|
||||
if (config.sendTrayNotification())
|
||||
{
|
||||
runelite.notify(message);
|
||||
notifier.notify(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,17 +32,15 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Polygon;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NpcID;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.queries.NPCQuery;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -55,17 +53,15 @@ public class ImplingsOverlay extends Overlay
|
||||
private static final int STATIC_SPAWN = 1618;
|
||||
private static final int DYNAMIC_SPAWN = 1633;
|
||||
|
||||
private final RuneLite runelite;
|
||||
private final Client client;
|
||||
private final QueryRunner queryRunner;
|
||||
private final ImplingsConfig config;
|
||||
private final List<Integer> ids = new LinkedList<>();
|
||||
|
||||
@Inject
|
||||
public ImplingsOverlay(RuneLite runelite, @Nullable Client client, ImplingsConfig config)
|
||||
public ImplingsOverlay(QueryRunner queryRunner, ImplingsConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
this.runelite = runelite;
|
||||
this.client = client;
|
||||
this.queryRunner = queryRunner;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@@ -73,7 +69,7 @@ public class ImplingsOverlay extends Overlay
|
||||
public Dimension render(Graphics2D graphics, java.awt.Point parent)
|
||||
{
|
||||
NPCQuery implingQuery = new NPCQuery().idEquals(Ints.toArray(ids));
|
||||
NPC[] implings = runelite.runQuery(implingQuery);
|
||||
NPC[] implings = queryRunner.runQuery(implingQuery);
|
||||
for (NPC imp : implings)
|
||||
{
|
||||
//Spawns have the name "null", so they get changed to "Spawn"
|
||||
|
||||
@@ -37,22 +37,22 @@ import net.runelite.api.queries.EquipmentItemQuery;
|
||||
import net.runelite.api.queries.InventoryItemQuery;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
class JewelleryCountOverlay extends Overlay
|
||||
{
|
||||
private final RuneLite runelite;
|
||||
private final QueryRunner queryRunner;
|
||||
private final JewelleryCountConfig config;
|
||||
|
||||
@Inject
|
||||
JewelleryCountOverlay(RuneLite runelite, JewelleryCountConfig config)
|
||||
JewelleryCountOverlay(QueryRunner queryRunner, JewelleryCountConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
this.runelite = runelite;
|
||||
this.queryRunner = queryRunner;
|
||||
this.config = config;
|
||||
this.setDrawOverBankScreen(true);
|
||||
}
|
||||
@@ -89,14 +89,14 @@ class JewelleryCountOverlay extends Overlay
|
||||
private Collection<WidgetItem> getJewelleryWidgetItems()
|
||||
{
|
||||
Query inventoryQuery = new InventoryItemQuery();
|
||||
WidgetItem[] inventoryWidgetItems = runelite.runQuery(inventoryQuery);
|
||||
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
||||
|
||||
Query equipmentQuery = new EquipmentItemQuery().slotEquals(
|
||||
WidgetInfo.EQUIPMENT_AMULET,
|
||||
WidgetInfo.EQUIPMENT_RING,
|
||||
WidgetInfo.EQUIPMENT_GLOVES
|
||||
);
|
||||
WidgetItem[] equipmentWidgetItems = runelite.runQuery(equipmentQuery);
|
||||
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
||||
|
||||
Collection<WidgetItem> jewellery = new ArrayList<>();
|
||||
jewellery.addAll(Arrays.asList(inventoryWidgetItems));
|
||||
|
||||
@@ -45,15 +45,15 @@ import net.runelite.api.Query;
|
||||
import net.runelite.api.queries.NPCQuery;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
@Slf4j
|
||||
public class PestControlOverlay extends Overlay
|
||||
{
|
||||
private final RuneLite runelite;
|
||||
private final QueryRunner queryRunner;
|
||||
private final Client client;
|
||||
|
||||
private final PestControlPlugin plugin;
|
||||
@@ -62,11 +62,11 @@ public class PestControlOverlay extends Overlay
|
||||
private Game game;
|
||||
|
||||
@Inject
|
||||
public PestControlOverlay(RuneLite runelite, PestControlPlugin plugin)
|
||||
public PestControlOverlay(QueryRunner queryRunner, Client client, PestControlPlugin plugin)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
this.runelite = runelite;
|
||||
this.client = runelite.getClient();
|
||||
this.queryRunner = queryRunner;
|
||||
this.client = client;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class PestControlOverlay extends Overlay
|
||||
private void renderSpinners(Graphics2D graphics)
|
||||
{
|
||||
Query query = new NPCQuery().nameEquals("Spinner");
|
||||
NPC[] result = runelite.runQuery(query);
|
||||
NPC[] result = queryRunner.runQuery(query);
|
||||
Arrays.stream(result).forEach(npc -> OverlayUtil.renderActorOverlay(graphics, npc, npc.getName(), Color.CYAN));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ package net.runelite.client.plugins.rememberusername;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Provides;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
@@ -41,7 +40,6 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
public class RememberUsernamePlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -40,23 +40,23 @@ import net.runelite.api.queries.EquipmentItemQuery;
|
||||
import net.runelite.api.queries.InventoryItemQuery;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
public class BindNeckOverlay extends Overlay
|
||||
{
|
||||
private final RuneLite runelite;
|
||||
private final QueryRunner queryRunner;
|
||||
private final RunecraftConfig config;
|
||||
int bindingCharges;
|
||||
|
||||
@Inject
|
||||
BindNeckOverlay(RuneLite runelite, RunecraftConfig config)
|
||||
BindNeckOverlay(QueryRunner queryRunner, RunecraftConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
this.runelite = runelite;
|
||||
this.queryRunner = queryRunner;
|
||||
this.config = config;
|
||||
this.setDrawOverBankScreen(true);
|
||||
}
|
||||
@@ -91,12 +91,12 @@ public class BindNeckOverlay extends Overlay
|
||||
{
|
||||
Query inventoryQuery = new InventoryItemQuery()
|
||||
.idEquals(BINDING_NECKLACE);
|
||||
WidgetItem[] inventoryWidgetItems = runelite.runQuery(inventoryQuery);
|
||||
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
||||
|
||||
Query equipmentQuery = new EquipmentItemQuery()
|
||||
.slotEquals(WidgetInfo.EQUIPMENT_AMULET)
|
||||
.idEquals(BINDING_NECKLACE);
|
||||
WidgetItem[] equipmentWidgetItems = runelite.runQuery(equipmentQuery);
|
||||
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
||||
|
||||
Collection<WidgetItem> necklaces = new ArrayList<>();
|
||||
necklaces.addAll(Arrays.asList(inventoryWidgetItems));
|
||||
|
||||
@@ -35,11 +35,11 @@ import net.runelite.api.Query;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.queries.InventoryItemQuery;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
public class RunecraftOverlay extends Overlay
|
||||
{
|
||||
@@ -47,17 +47,17 @@ public class RunecraftOverlay extends Overlay
|
||||
private static final int LARGE_POUCH_DAMAGED = ItemID.LARGE_POUCH_5513;
|
||||
private static final int GIANT_POUCH_DAMAGED = ItemID.GIANT_POUCH_5515;
|
||||
|
||||
private final RuneLite runelite;
|
||||
private final QueryRunner queryRunner;
|
||||
private final Client client;
|
||||
|
||||
private final RunecraftConfig config;
|
||||
|
||||
@Inject
|
||||
RunecraftOverlay(RuneLite runelite, RunecraftConfig config)
|
||||
RunecraftOverlay(QueryRunner queryRunner, Client client, RunecraftConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
this.runelite = runelite;
|
||||
this.client = runelite.getClient();
|
||||
this.queryRunner = queryRunner;
|
||||
this.client = client;
|
||||
this.config = config;
|
||||
this.setDrawOverBankScreen(true);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class RunecraftOverlay extends Overlay
|
||||
}
|
||||
|
||||
Query query = new InventoryItemQuery();
|
||||
WidgetItem[] widgetItems = runelite.runQuery(query);
|
||||
WidgetItem[] widgetItems = queryRunner.runQuery(query);
|
||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||
|
||||
for (WidgetItem item : widgetItems)
|
||||
|
||||
@@ -36,13 +36,13 @@ import net.runelite.api.Query;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.queries.InventoryItemQuery;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
import net.runelite.client.ui.overlay.tooltip.Tooltip;
|
||||
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
public class RunepouchOverlay extends Overlay
|
||||
{
|
||||
@@ -57,18 +57,18 @@ public class RunepouchOverlay extends Overlay
|
||||
|
||||
private final RuneImageCache runeImageCache = new RuneImageCache();
|
||||
|
||||
private final RuneLite runelite;
|
||||
private final QueryRunner queryRunner;
|
||||
private final Client client;
|
||||
private final RunepouchConfig config;
|
||||
private final TooltipManager tooltipManager;
|
||||
|
||||
@Inject
|
||||
RunepouchOverlay(RuneLite runelite, RunepouchConfig config, TooltipManager tooltipManager)
|
||||
RunepouchOverlay(QueryRunner queryRunner, Client client, RunepouchConfig config, TooltipManager tooltipManager)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
this.tooltipManager = tooltipManager;
|
||||
this.runelite = runelite;
|
||||
this.client = runelite.getClient();
|
||||
this.queryRunner = queryRunner;
|
||||
this.client = client;
|
||||
this.config = config;
|
||||
this.setDrawOverBankScreen(true);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class RunepouchOverlay extends Overlay
|
||||
}
|
||||
|
||||
Query query = new InventoryItemQuery().idEquals(ItemID.RUNE_POUCH);
|
||||
WidgetItem[] items = runelite.runQuery(query);
|
||||
WidgetItem[] items = queryRunner.runQuery(query);
|
||||
if (items.length == 0)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -40,15 +40,15 @@ import net.runelite.api.queries.EquipmentItemQuery;
|
||||
import net.runelite.api.queries.InventoryItemQuery;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.FontManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
class SlayerOverlay extends Overlay
|
||||
{
|
||||
private final RuneLite runelite;
|
||||
private final QueryRunner queryRunner;
|
||||
private final SlayerConfig config;
|
||||
private final SlayerPlugin plugin;
|
||||
|
||||
@@ -80,10 +80,10 @@ class SlayerOverlay extends Overlay
|
||||
);
|
||||
|
||||
@Inject
|
||||
SlayerOverlay(RuneLite runelite, SlayerPlugin plugin, SlayerConfig config)
|
||||
SlayerOverlay(QueryRunner queryRunner, SlayerPlugin plugin, SlayerConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
this.runelite = runelite;
|
||||
this.queryRunner = queryRunner;
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
}
|
||||
@@ -132,10 +132,10 @@ class SlayerOverlay extends Overlay
|
||||
private Collection<WidgetItem> getSlayerWidgetItems()
|
||||
{
|
||||
Query inventoryQuery = new InventoryItemQuery();
|
||||
WidgetItem[] inventoryWidgetItems = runelite.runQuery(inventoryQuery);
|
||||
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
||||
|
||||
Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_HELMET, WidgetInfo.EQUIPMENT_RING);
|
||||
WidgetItem[] equipmentWidgetItems = runelite.runQuery(equipmentQuery);
|
||||
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
||||
|
||||
WidgetItem[] items = concat(inventoryWidgetItems, equipmentWidgetItems, WidgetItem.class);
|
||||
return ImmutableList.copyOf(items);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.slayer;
|
||||
|
||||
import static net.runelite.api.Skill.SLAYER;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Provides;
|
||||
@@ -33,13 +34,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.ItemID;
|
||||
import static net.runelite.api.Skill.SLAYER;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
@@ -73,7 +72,6 @@ public class SlayerPlugin extends Plugin
|
||||
private static final Pattern REWARD_POINTS = Pattern.compile("Reward points: (\\d*)");
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
@@ -146,7 +144,7 @@ public class SlayerPlugin extends Plugin
|
||||
)
|
||||
public void scheduledChecks()
|
||||
{
|
||||
if (!config.enabled() || client == null)
|
||||
if (!config.enabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,14 @@ package net.runelite.client.plugins.teamcapes;
|
||||
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Provides;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Player;
|
||||
@@ -35,23 +43,12 @@ import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Team capes plugin"
|
||||
)
|
||||
public class TeamCapesPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
@@ -86,7 +83,7 @@ public class TeamCapesPlugin extends Plugin
|
||||
)
|
||||
public void update()
|
||||
{
|
||||
if (!config.enabled() || client == null || client.getGameState() != GameState.LOGGED_IN)
|
||||
if (!config.enabled() || client.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class VolcanicMineOverlay extends Overlay
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics, java.awt.Point point)
|
||||
{
|
||||
if (client == null || !plugin.getInside() || !config.enabled())
|
||||
if (!plugin.getInside() || !config.enabled())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -25,31 +25,11 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.volcanicmine;
|
||||
|
||||
import static java.lang.Math.abs;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.Color;
|
||||
import static java.lang.Math.abs;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.Region;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
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.overlay.Overlay;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
@@ -59,10 +39,31 @@ import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.Prayer;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.Region;
|
||||
import net.runelite.api.Tile;
|
||||
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.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;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Volcanic mine helper"
|
||||
@@ -81,11 +82,16 @@ public class VolcanicMinePlugin extends Plugin
|
||||
private static final Pattern coltagPattern = Pattern.compile("((<col=([0-f]){6}>)|(<\\/col>))");
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
RuneLite runeLite;
|
||||
ClientUI clientUI;
|
||||
|
||||
@Inject
|
||||
QueryRunner queryRunner;
|
||||
|
||||
@Inject
|
||||
Notifier notifier;
|
||||
|
||||
@Inject
|
||||
VolcanicMineConfig config;
|
||||
@@ -274,7 +280,7 @@ public class VolcanicMinePlugin extends Plugin
|
||||
Query query = new NPCQuery()
|
||||
.nameEquals(LAVA_BEAST)
|
||||
.isWithinArea(player.getLocalLocation(), LAVA_BEAST_ATTACK_RANGE);
|
||||
NPC[] npcs = runeLite.runQuery(query);
|
||||
NPC[] npcs = queryRunner.runQuery(query);
|
||||
return npcs.length > 0;
|
||||
}
|
||||
|
||||
@@ -292,17 +298,17 @@ 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())
|
||||
{
|
||||
runeLite.notify(message);
|
||||
notifier.notify(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.events.ChatMessage;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
@@ -46,7 +46,7 @@ import net.runelite.client.ui.overlay.Overlay;
|
||||
public class WoodcuttingPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
RuneLite runelite;
|
||||
Notifier notifier;
|
||||
|
||||
@Inject
|
||||
WoodcuttingOverlay overlay;
|
||||
@@ -91,7 +91,7 @@ public class WoodcuttingPlugin extends Plugin
|
||||
|
||||
if (event.getMessage().contains("A bird's nest falls out of the tree") && config.showNestNotification())
|
||||
{
|
||||
runelite.notify("A bird nest has spawned!");
|
||||
notifier.notify("A bird nest has spawned!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Experience;
|
||||
@@ -55,7 +54,6 @@ public class XpGlobesPlugin extends Plugin
|
||||
private final List<XpGlobe> xpGlobes = new ArrayList<>();
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -24,10 +24,6 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.xptracker;
|
||||
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.io.IOException;
|
||||
@@ -35,13 +31,16 @@ import java.text.NumberFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
|
||||
@Slf4j
|
||||
public class XpPanel extends PluginPanel
|
||||
@@ -50,7 +49,6 @@ public class XpPanel extends PluginPanel
|
||||
private final XpTrackerPlugin xpTracker;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -35,7 +35,6 @@ import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.task.Schedule;
|
||||
@@ -51,7 +50,6 @@ public class XpTrackerPlugin extends Plugin
|
||||
ClientUI ui;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
private NavigationButton navButton;
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
@@ -50,7 +49,6 @@ public class XteaPlugin extends Plugin
|
||||
private final Set<Integer> sentRegions = new HashSet<>();
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.google.inject.Provides;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
@@ -39,7 +38,6 @@ import net.runelite.api.GameState;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.api.queries.NPCQuery;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
@@ -55,6 +53,7 @@ import net.runelite.client.plugins.zulrah.patterns.ZulrahPatternD;
|
||||
import net.runelite.client.plugins.zulrah.phase.ZulrahPhase;
|
||||
import net.runelite.client.task.Schedule;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.util.QueryRunner;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Zulrah plugin"
|
||||
@@ -63,10 +62,9 @@ import net.runelite.client.ui.overlay.Overlay;
|
||||
public class ZulrahPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
RuneLite runelite;
|
||||
QueryRunner queryRunner;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
@@ -118,7 +116,7 @@ public class ZulrahPlugin extends Plugin
|
||||
)
|
||||
public void update()
|
||||
{
|
||||
if (!config.enabled() || client == null || client.getGameState() != GameState.LOGGED_IN)
|
||||
if (!config.enabled() || client.getGameState() != GameState.LOGGED_IN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -187,7 +185,7 @@ public class ZulrahPlugin extends Plugin
|
||||
private NPC findZulrah()
|
||||
{
|
||||
Query query = new NPCQuery().nameEquals("Zulrah");
|
||||
NPC[] result = runelite.runQuery(query);
|
||||
NPC[] result = queryRunner.runQuery(query);
|
||||
return result.length == 1 ? result[0] : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ZulrahPrayerOverlay extends Overlay
|
||||
{
|
||||
ZulrahInstance instance = plugin.getInstance();
|
||||
|
||||
if (client == null || instance == null)
|
||||
if (instance == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -25,89 +25,46 @@
|
||||
package net.runelite.client.ui;
|
||||
|
||||
import java.applet.Applet;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.BorderLayout;
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.swing.JPanel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.client.ClientLoader;
|
||||
import net.runelite.http.api.updatecheck.UpdateCheckClient;
|
||||
|
||||
@Slf4j
|
||||
final class ClientPanel extends JPanel
|
||||
{
|
||||
public static final int PANEL_WIDTH = 765, PANEL_HEIGHT = 503;
|
||||
|
||||
private final ClientUI ui;
|
||||
private Applet rs;
|
||||
|
||||
public ClientPanel(ClientUI ui)
|
||||
public ClientPanel(@Nullable Applet client)
|
||||
{
|
||||
this.ui = ui;
|
||||
setSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setLayout(new BorderLayout());
|
||||
setBackground(Color.black);
|
||||
}
|
||||
|
||||
public void loadRs() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
|
||||
{
|
||||
ClientLoader loader = new ClientLoader();
|
||||
|
||||
UpdateCheckClient updateCheck = new UpdateCheckClient();
|
||||
boolean isOutdated = updateCheck.isOutdated();
|
||||
if (isOutdated)
|
||||
{
|
||||
log.info("Runelite is outdated - fetching vanilla client");
|
||||
rs = loader.loadVanilla();
|
||||
}
|
||||
else
|
||||
{
|
||||
log.debug("Runelite is up to date");
|
||||
|
||||
try
|
||||
{
|
||||
rs = loader.loadRunelite();
|
||||
}
|
||||
catch (ClassNotFoundException ex)
|
||||
{
|
||||
log.error("Unable to load client - class not found. This means you"
|
||||
+ " are not running RuneLite with Maven as the injected client"
|
||||
+ " is not in your classpath.");
|
||||
throw new ClassNotFoundException("Unable to load injected client", ex);
|
||||
}
|
||||
}
|
||||
|
||||
rs.setLayout(null);
|
||||
rs.setSize(PANEL_WIDTH, PANEL_HEIGHT);
|
||||
|
||||
rs.init();
|
||||
rs.start();
|
||||
|
||||
add(rs, BorderLayout.CENTER);
|
||||
|
||||
if (isOutdated)
|
||||
if (client == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(rs instanceof Client))
|
||||
{
|
||||
log.error("Injected client does not implement Client!");
|
||||
return;
|
||||
}
|
||||
client.setLayout(null);
|
||||
client.setSize(PANEL_WIDTH, PANEL_HEIGHT);
|
||||
|
||||
Client client = (Client) rs;
|
||||
client.init();
|
||||
client.start();
|
||||
|
||||
ui.getRunelite().setClient(client);
|
||||
add(client, BorderLayout.CENTER);
|
||||
|
||||
// This causes the whole game frame to be redrawn each frame instead
|
||||
// of only the viewport, so we can hook to MainBufferProvider#draw
|
||||
// and draw anywhere without it leaving artifacts
|
||||
client.setGameDrawingMode(2);
|
||||
if (client instanceof Client)
|
||||
{
|
||||
((Client)client).setGameDrawingMode(2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -24,24 +24,39 @@
|
||||
*/
|
||||
package net.runelite.client.ui;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import java.applet.Applet;
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.ToolTipManager;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.RuneliteProperties;
|
||||
import org.pushingpixels.substance.api.skin.SubstanceGraphiteLookAndFeel;
|
||||
import org.pushingpixels.substance.internal.ui.SubstanceRootPaneUI;
|
||||
|
||||
@Slf4j
|
||||
@@ -50,24 +65,79 @@ public class ClientUI extends JFrame
|
||||
private static final int CLIENT_WIDTH = 809;
|
||||
private static final int SCROLLBAR_WIDTH = 17;
|
||||
private static final int EXPANDED_WIDTH = CLIENT_WIDTH + PluginPanel.PANEL_WIDTH + SCROLLBAR_WIDTH;
|
||||
private static final BufferedImage ICON;
|
||||
|
||||
private final RuneLite runelite;
|
||||
@Getter
|
||||
private TrayIcon trayIcon;
|
||||
|
||||
private final Applet client;
|
||||
private final RuneliteProperties properties;
|
||||
private JPanel container;
|
||||
private JPanel navContainer;
|
||||
private ClientPanel panel;
|
||||
private PluginToolbar pluginToolbar;
|
||||
private PluginPanel pluginPanel;
|
||||
|
||||
public ClientUI(RuneLite runelite)
|
||||
static
|
||||
{
|
||||
this.runelite = runelite;
|
||||
BufferedImage icon = null;
|
||||
|
||||
try
|
||||
{
|
||||
icon = ImageIO.read(ClientUI.class.getResourceAsStream("/runelite.png"));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.warn("Client icon failed to load", e);
|
||||
}
|
||||
|
||||
ICON = icon;
|
||||
}
|
||||
|
||||
public static ClientUI create(RuneliteProperties properties, Applet client)
|
||||
{
|
||||
// Force heavy-weight popups/tooltips.
|
||||
// Prevents them from being obscured by the game applet.
|
||||
ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
|
||||
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
||||
|
||||
// Do not render shadows under popups/tooltips.
|
||||
// Fixes black boxes under popups that are above the game applet.
|
||||
System.setProperty("jgoodies.popupDropShadowEnabled", "false");
|
||||
|
||||
// Do not fill in background on repaint. Reduces flickering when
|
||||
// the applet is resized.
|
||||
System.setProperty("sun.awt.noerasebackground", "true");
|
||||
|
||||
// Use custom window decorations
|
||||
JFrame.setDefaultLookAndFeelDecorated(true);
|
||||
|
||||
// Use substance look and feel
|
||||
try
|
||||
{
|
||||
UIManager.setLookAndFeel(new SubstanceGraphiteLookAndFeel());
|
||||
}
|
||||
catch (UnsupportedLookAndFeelException ex)
|
||||
{
|
||||
log.warn("unable to set look and feel", ex);
|
||||
}
|
||||
|
||||
// Use custom UI font
|
||||
setUIFont(new FontUIResource(FontManager.getRunescapeFont()));
|
||||
|
||||
return new ClientUI(properties, client);
|
||||
}
|
||||
|
||||
private ClientUI(RuneliteProperties properties, Applet client)
|
||||
{
|
||||
this.properties = properties;
|
||||
this.client = client;
|
||||
this.trayIcon = setupTrayIcon();
|
||||
|
||||
init();
|
||||
pack();
|
||||
TitleBarPane titleBarPane = new TitleBarPane(this.getRootPane(), (SubstanceRootPaneUI)this.getRootPane().getUI());
|
||||
titleBarPane.editTitleBar(this);
|
||||
setTitle("RuneLite");
|
||||
setIconImage(RuneLite.ICON);
|
||||
new TitleBarPane(this.getRootPane(), (SubstanceRootPaneUI)this.getRootPane().getUI()).editTitleBar(this);
|
||||
setTitle(null);
|
||||
setIconImage(ICON);
|
||||
setLocationRelativeTo(getOwner());
|
||||
setResizable(true);
|
||||
setVisible(true);
|
||||
@@ -89,6 +159,55 @@ public class ClientUI extends JFrame
|
||||
}
|
||||
}
|
||||
|
||||
private TrayIcon setupTrayIcon()
|
||||
{
|
||||
if (!SystemTray.isSupported())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
SystemTray systemTray = SystemTray.getSystemTray();
|
||||
TrayIcon trayIcon = new TrayIcon(ICON, properties.getTitle());
|
||||
trayIcon.setImageAutoSize(true);
|
||||
|
||||
try
|
||||
{
|
||||
systemTray.add(trayIcon);
|
||||
}
|
||||
catch (AWTException ex)
|
||||
{
|
||||
log.debug("Unable to add system tray icon", ex);
|
||||
return trayIcon;
|
||||
}
|
||||
|
||||
// bring to front when tray icon is clicked
|
||||
trayIcon.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
setVisible(true);
|
||||
setState(Frame.NORMAL); // unminimize
|
||||
}
|
||||
});
|
||||
|
||||
return trayIcon;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setTitle(String extra)
|
||||
{
|
||||
if (!Strings.isNullOrEmpty(extra))
|
||||
{
|
||||
super.setTitle(properties.getTitle() + " " + properties.getVersion() + " " + extra);
|
||||
}
|
||||
else
|
||||
{
|
||||
super.setTitle(properties.getTitle() + " " + properties.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
assert SwingUtilities.isEventDispatchThread();
|
||||
@@ -106,21 +225,7 @@ public class ClientUI extends JFrame
|
||||
|
||||
container = new JPanel();
|
||||
container.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
panel = new ClientPanel(this);
|
||||
if (!RuneLite.getOptions().has("no-rs"))
|
||||
{
|
||||
try
|
||||
{
|
||||
panel.loadRs();
|
||||
}
|
||||
catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException ex)
|
||||
{
|
||||
log.error("Error loading RS!", ex);
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
container.add(panel, BorderLayout.CENTER);
|
||||
container.add(new ClientPanel(client), BorderLayout.CENTER);
|
||||
|
||||
navContainer = new JPanel();
|
||||
navContainer.setLayout(new BorderLayout(0, 0));
|
||||
@@ -183,11 +288,10 @@ public class ClientUI extends JFrame
|
||||
|
||||
private void checkExit()
|
||||
{
|
||||
Client client = runelite.getClient();
|
||||
int result = JOptionPane.OK_OPTION;
|
||||
|
||||
// only ask if not logged out
|
||||
if (client != null && client.getGameState() != GameState.LOGIN_SCREEN)
|
||||
if (client != null && client instanceof Client && ((Client)client).getGameState() != GameState.LOGIN_SCREEN)
|
||||
{
|
||||
result = JOptionPane.showConfirmDialog(this, "Are you sure you want to exit?", "Exit", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||
}
|
||||
@@ -202,14 +306,4 @@ public class ClientUI extends JFrame
|
||||
{
|
||||
return pluginToolbar;
|
||||
}
|
||||
|
||||
public PluginPanel getPluginPanel()
|
||||
{
|
||||
return pluginPanel;
|
||||
}
|
||||
|
||||
RuneLite getRunelite()
|
||||
{
|
||||
return runelite;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
@@ -61,7 +60,6 @@ public class PanelComponent implements RenderableEntity
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Nullable
|
||||
private String title;
|
||||
|
||||
@Setter
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Tomas Slusny <slusnucky@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.util;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Query;
|
||||
|
||||
@Singleton
|
||||
public class QueryRunner
|
||||
{
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T[] runQuery(Query query)
|
||||
{
|
||||
return (T[]) query.result(client);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ public class ExamplePlugin extends Plugin
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExamplePlugin.class);
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
Client client;
|
||||
|
||||
@Inject
|
||||
|
||||
Reference in New Issue
Block a user