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.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
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 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();
|
ConfigLoader config = new ConfigLoader();
|
||||||
|
|
||||||
@@ -48,7 +82,7 @@ public class ClientLoader
|
|||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Applet loadVanilla() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
|
private Applet loadVanilla() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
|
||||||
{
|
{
|
||||||
ConfigLoader config = new ConfigLoader();
|
ConfigLoader config = new ConfigLoader();
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ package net.runelite.client;
|
|||||||
|
|
||||||
import com.google.common.escape.Escaper;
|
import com.google.common.escape.Escaper;
|
||||||
import com.google.common.escape.Escapers;
|
import com.google.common.escape.Escapers;
|
||||||
|
import java.awt.Toolkit;
|
||||||
import java.awt.TrayIcon;
|
import java.awt.TrayIcon;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -35,7 +36,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class Notifier
|
public class Notifier
|
||||||
{
|
{
|
||||||
private static enum OSType
|
private enum OSType
|
||||||
{
|
{
|
||||||
Windows, MacOS, Linux, Other
|
Windows, MacOS, Linux, Other
|
||||||
};
|
};
|
||||||
@@ -74,14 +75,28 @@ public class Notifier
|
|||||||
log.debug("Detect OS: {}", DETECTED_OS);
|
log.debug("Detect OS: {}", DETECTED_OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final String appName;
|
||||||
private final TrayIcon trayIcon;
|
private final TrayIcon trayIcon;
|
||||||
|
|
||||||
public Notifier(final TrayIcon trayIcon)
|
Notifier(final String appName, final TrayIcon trayIcon)
|
||||||
{
|
{
|
||||||
|
this.appName = appName;
|
||||||
this.trayIcon = trayIcon;
|
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 title,
|
||||||
final String message,
|
final String message,
|
||||||
final TrayIcon.MessageType type,
|
final TrayIcon.MessageType type,
|
||||||
|
|||||||
@@ -24,51 +24,27 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client;
|
package net.runelite.client;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.google.common.eventbus.EventBus;
|
import com.google.common.eventbus.EventBus;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import java.awt.AWTException;
|
import java.applet.Applet;
|
||||||
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.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.util.Optional;
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPopupMenu;
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.ToolTipManager;
|
|
||||||
import javax.swing.UIManager;
|
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
|
||||||
import joptsimple.OptionParser;
|
import joptsimple.OptionParser;
|
||||||
import joptsimple.OptionSet;
|
import joptsimple.OptionSet;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Query;
|
import net.runelite.client.account.SessionManager;
|
||||||
import net.runelite.client.account.AccountSession;
|
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
import net.runelite.client.config.ConfigManager;
|
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.menus.MenuManager;
|
||||||
import net.runelite.client.plugins.PluginManager;
|
import net.runelite.client.plugins.PluginManager;
|
||||||
import net.runelite.client.ui.ClientUI;
|
import net.runelite.client.ui.ClientUI;
|
||||||
import net.runelite.client.ui.overlay.OverlayRenderer;
|
import net.runelite.client.ui.overlay.OverlayRenderer;
|
||||||
import net.runelite.http.api.account.AccountClient;
|
|
||||||
import org.pushingpixels.substance.api.skin.SubstanceGraphiteLookAndFeel;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Slf4j
|
@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 RUNELITE_DIR = new File(System.getProperty("user.home"), ".runelite");
|
||||||
public static final File PROFILES_DIR = new File(RUNELITE_DIR, "profiles");
|
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 final File PLUGIN_DIR = new File(RUNELITE_DIR, "plugins");
|
||||||
|
|
||||||
public static Image ICON;
|
|
||||||
|
|
||||||
private static Injector injector;
|
private static Injector injector;
|
||||||
|
|
||||||
private static OptionSet options;
|
private static OptionSet options;
|
||||||
private static RuneLite runelite;
|
|
||||||
private static TrayIcon trayIcon;
|
|
||||||
|
|
||||||
private Client client;
|
|
||||||
private ClientUI gui;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RuneliteProperties properties;
|
private RuneliteProperties properties;
|
||||||
@@ -114,79 +81,65 @@ public class RuneLite
|
|||||||
@Inject
|
@Inject
|
||||||
private OverlayRenderer overlayRenderer;
|
private OverlayRenderer overlayRenderer;
|
||||||
|
|
||||||
private WSClient wsclient;
|
@Inject
|
||||||
|
private SessionManager sessionManager;
|
||||||
|
|
||||||
private AccountSession accountSession;
|
Client client;
|
||||||
|
ClientUI gui;
|
||||||
private Notifier notifier;
|
Notifier notifier;
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final URL icon = ClientUI.class.getResource("/runelite.png");
|
|
||||||
ICON = ImageIO.read(icon.openStream());
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
log.warn(null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception
|
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();
|
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
|
||||||
{
|
{
|
||||||
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);
|
System.exit(-1);
|
||||||
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
final Applet client = optionalClient.orElseGet(null);
|
||||||
{
|
final boolean isOutdated = client == null || !(client instanceof Client);
|
||||||
UIManager.setLookAndFeel(new SubstanceGraphiteLookAndFeel());
|
|
||||||
}
|
|
||||||
catch (UnsupportedLookAndFeelException ex)
|
|
||||||
{
|
|
||||||
log.warn("unable to set look and feel", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
gui = new ClientUI(this);
|
if (!isOutdated)
|
||||||
setTitle(null);
|
{
|
||||||
|
this.client = (Client) client;
|
||||||
|
}
|
||||||
|
|
||||||
setupTrayIcon();
|
// Load swing UI
|
||||||
});
|
SwingUtilities.invokeAndWait(() -> setGui(ClientUI.create(properties, client)));
|
||||||
|
|
||||||
|
// Load default configuration
|
||||||
configManager.load();
|
configManager.load();
|
||||||
|
|
||||||
|
// Register event listeners
|
||||||
eventBus.register(overlayRenderer);
|
eventBus.register(overlayRenderer);
|
||||||
eventBus.register(menuManager);
|
eventBus.register(menuManager);
|
||||||
eventBus.register(chatMessageManager);
|
eventBus.register(chatMessageManager);
|
||||||
|
|
||||||
// Setup the notifier
|
// 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.
|
// Load the plugins, but does not start them yet.
|
||||||
// This will initialize configuration
|
// This will initialize configuration
|
||||||
@@ -200,185 +153,12 @@ public class RuneLite
|
|||||||
pluginManager.startCorePlugins();
|
pluginManager.startCorePlugins();
|
||||||
|
|
||||||
// Load the session, including saved configuration
|
// Load the session, including saved configuration
|
||||||
loadSession();
|
sessionManager.loadSession();
|
||||||
|
|
||||||
// Begin watching for new plugins
|
// Begin watching for new plugins
|
||||||
pluginManager.watch();
|
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)
|
public void setGui(ClientUI gui)
|
||||||
{
|
{
|
||||||
this.gui = gui;
|
this.gui = gui;
|
||||||
@@ -403,30 +183,4 @@ public class RuneLite
|
|||||||
{
|
{
|
||||||
RuneLite.options = options;
|
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 javax.inject.Singleton;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.client.account.SessionManager;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.config.RuneliteConfig;
|
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.task.Scheduler;
|
||||||
import net.runelite.client.ui.ClientUI;
|
import net.runelite.client.ui.ClientUI;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class RuneliteModule extends AbstractModule
|
public class RuneliteModule extends AbstractModule
|
||||||
@@ -50,6 +52,7 @@ public class RuneliteModule extends AbstractModule
|
|||||||
protected void configure()
|
protected void configure()
|
||||||
{
|
{
|
||||||
bind(ScheduledExecutorService.class).toInstance(Executors.newSingleThreadScheduledExecutor());
|
bind(ScheduledExecutorService.class).toInstance(Executors.newSingleThreadScheduledExecutor());
|
||||||
|
bind(QueryRunner.class);
|
||||||
bind(MenuManager.class);
|
bind(MenuManager.class);
|
||||||
bind(ChatMessageManager.class);
|
bind(ChatMessageManager.class);
|
||||||
bind(ItemManager.class);
|
bind(ItemManager.class);
|
||||||
@@ -57,18 +60,25 @@ public class RuneliteModule extends AbstractModule
|
|||||||
bind(Scheduler.class);
|
bind(Scheduler.class);
|
||||||
bind(PluginManager.class);
|
bind(PluginManager.class);
|
||||||
bind(RuneliteProperties.class);
|
bind(RuneliteProperties.class);
|
||||||
|
bind(SessionManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
Client provideClient(RuneLite runelite)
|
Client provideClient(RuneLite runeLite)
|
||||||
{
|
{
|
||||||
return runelite.getClient();
|
return runeLite.client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
ClientUI provideClientUi(RuneLite runelite)
|
ClientUI provideClientUi(RuneLite runelite)
|
||||||
{
|
{
|
||||||
return runelite.getGui();
|
return runelite.gui;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
Notifier provideNotifier(RuneLite runeLite)
|
||||||
|
{
|
||||||
|
return runeLite.notifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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.common.eventbus.EventBus;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
@@ -32,12 +32,11 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.client.account.AccountSession;
|
|
||||||
import net.runelite.http.api.RuneliteAPI;
|
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.WebsocketGsonFactory;
|
||||||
import net.runelite.http.api.ws.WebsocketMessage;
|
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.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
@@ -38,4 +38,6 @@ public @interface PluginDescriptor
|
|||||||
String name();
|
String name();
|
||||||
|
|
||||||
boolean developerPlugin() default false;
|
boolean developerPlugin() default false;
|
||||||
|
|
||||||
|
boolean loadWhenOutdated() default false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.client.RuneLite;
|
import net.runelite.client.RuneLite;
|
||||||
import net.runelite.client.events.PluginChanged;
|
import net.runelite.client.events.PluginChanged;
|
||||||
@@ -67,6 +68,9 @@ public class PluginManager
|
|||||||
@Inject
|
@Inject
|
||||||
PluginWatcher pluginWatcher;
|
PluginWatcher pluginWatcher;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
boolean isOutdated;
|
||||||
|
|
||||||
private final List<Plugin> plugins = new CopyOnWriteArrayList<>();
|
private final List<Plugin> plugins = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
public void loadCorePlugins() throws IOException
|
public void loadCorePlugins() throws IOException
|
||||||
@@ -127,6 +131,11 @@ public class PluginManager
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pluginDescriptor.loadWhenOutdated() && isOutdated)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (pluginDescriptor.developerPlugin() && !developerPlugins)
|
if (pluginDescriptor.developerPlugin() && !developerPlugins)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.account.AccountSession;
|
import net.runelite.client.account.AccountSession;
|
||||||
|
import net.runelite.client.account.SessionManager;
|
||||||
import net.runelite.client.events.SessionClose;
|
import net.runelite.client.events.SessionClose;
|
||||||
import net.runelite.client.events.SessionOpen;
|
import net.runelite.client.events.SessionOpen;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
@@ -56,7 +56,7 @@ import net.runelite.http.api.ws.messages.LoginResponse;
|
|||||||
public class AccountPlugin extends Plugin
|
public class AccountPlugin extends Plugin
|
||||||
{
|
{
|
||||||
@Inject
|
@Inject
|
||||||
RuneLite runelite;
|
SessionManager sessionManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ClientUI ui;
|
ClientUI ui;
|
||||||
@@ -87,7 +87,7 @@ public class AccountPlugin extends Plugin
|
|||||||
private void logoutClick(ActionEvent ae)
|
private void logoutClick(ActionEvent ae)
|
||||||
{
|
{
|
||||||
// Destroy session
|
// Destroy session
|
||||||
AccountSession session = runelite.getAccountSession();
|
AccountSession session = sessionManager.getAccountSession();
|
||||||
if (session != null)
|
if (session != null)
|
||||||
{
|
{
|
||||||
AccountClient client = new AccountClient(session.getUuid());
|
AccountClient client = new AccountClient(session.getUuid());
|
||||||
@@ -101,8 +101,8 @@ public class AccountPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runelite.closeSession(); // remove session from client
|
sessionManager.closeSession(); // remove session from client
|
||||||
runelite.deleteSession(); // delete saved session file
|
sessionManager.deleteSession(); // delete saved session file
|
||||||
|
|
||||||
// Replace logout nav button with login
|
// Replace logout nav button with login
|
||||||
PluginToolbar navigationPanel = ui.getPluginToolbar();
|
PluginToolbar navigationPanel = ui.getPluginToolbar();
|
||||||
@@ -129,7 +129,7 @@ public class AccountPlugin extends Plugin
|
|||||||
session.setUuid(login.getUid());
|
session.setUuid(login.getUid());
|
||||||
session.setCreated(Instant.now());
|
session.setCreated(Instant.now());
|
||||||
|
|
||||||
runelite.openSession(session);
|
sessionManager.openSession(session);
|
||||||
|
|
||||||
if (!Desktop.isDesktopSupported())
|
if (!Desktop.isDesktopSupported())
|
||||||
{
|
{
|
||||||
@@ -161,21 +161,21 @@ public class AccountPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
log.debug("Now logged in as {}", loginResponse.getUsername());
|
log.debug("Now logged in as {}", loginResponse.getUsername());
|
||||||
|
|
||||||
AccountSession session = runelite.getAccountSession();
|
AccountSession session = sessionManager.getAccountSession();
|
||||||
session.setUsername(loginResponse.getUsername());
|
session.setUsername(loginResponse.getUsername());
|
||||||
|
|
||||||
// Open session, again, now that we have a username
|
// Open session, again, now that we have a username
|
||||||
// This triggers onSessionOpen
|
// This triggers onSessionOpen
|
||||||
runelite.openSession(session);
|
sessionManager.openSession(session);
|
||||||
|
|
||||||
// Save session to disk
|
// Save session to disk
|
||||||
runelite.saveSession();
|
sessionManager.saveSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onSessionOpen(SessionOpen sessionOpen)
|
public void onSessionOpen(SessionOpen sessionOpen)
|
||||||
{
|
{
|
||||||
AccountSession session = runelite.getAccountSession();
|
AccountSession session = sessionManager.getAccountSession();
|
||||||
|
|
||||||
if (session.getUsername() == null)
|
if (session.getUsername() == null)
|
||||||
{
|
{
|
||||||
@@ -184,7 +184,7 @@ public class AccountPlugin extends Plugin
|
|||||||
|
|
||||||
log.debug("Session opened as {}", session.getUsername());
|
log.debug("Session opened as {}", session.getUsername());
|
||||||
|
|
||||||
runelite.setTitle("(" + session.getUsername() + ")");
|
ui.setTitle("(" + session.getUsername() + ")");
|
||||||
|
|
||||||
replaceLoginWithLogout();
|
replaceLoginWithLogout();
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ public class AccountPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onSessionClose(SessionClose sessionClose)
|
public void onSessionClose(SessionClose sessionClose)
|
||||||
{
|
{
|
||||||
runelite.setTitle(null);
|
ui.setTitle(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.attackindicator;
|
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.HashBasedTable;
|
||||||
import com.google.common.collect.Table;
|
import com.google.common.collect.Table;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
@@ -32,7 +35,6 @@ import com.google.inject.Provides;
|
|||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
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.events.VarbitChanged;
|
||||||
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 static net.runelite.client.plugins.attackindicator.AttackStyle.*;
|
|
||||||
import net.runelite.client.task.Schedule;
|
import net.runelite.client.task.Schedule;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
@@ -63,7 +64,6 @@ public class AttackIndicatorPlugin extends Plugin
|
|||||||
private final Table<WeaponType, WidgetInfo, Boolean> widgetsToHide = HashBasedTable.create();
|
private final Table<WeaponType, WidgetInfo, Boolean> widgetsToHide = HashBasedTable.create();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import java.io.IOException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
@@ -69,7 +68,6 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
private final HiscoreClient hiscoreClient = new HiscoreClient();
|
private final HiscoreClient hiscoreClient = new HiscoreClient();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -77,7 +76,6 @@ public class ClanChatPlugin extends Plugin
|
|||||||
private int modIconsLength;
|
private int modIconsLength;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import com.google.inject.Binder;
|
|||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
@@ -47,7 +46,6 @@ import net.runelite.client.task.Schedule;
|
|||||||
public class ClueScrollPlugin extends Plugin
|
public class ClueScrollPlugin extends Plugin
|
||||||
{
|
{
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ package net.runelite.client.plugins.combatlevel;
|
|||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Experience;
|
import net.runelite.api.Experience;
|
||||||
@@ -48,7 +47,6 @@ public class CombatLevelPlugin extends Plugin
|
|||||||
private final DecimalFormat decimalFormat = new DecimalFormat("#.###");
|
private final DecimalFormat decimalFormat = new DecimalFormat("#.###");
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -66,7 +64,7 @@ public class CombatLevelPlugin extends Plugin
|
|||||||
)
|
)
|
||||||
public void updateCombatLevel()
|
public void updateCombatLevel()
|
||||||
{
|
{
|
||||||
if (client == null || client.getGameState() != GameState.LOGGED_IN)
|
if (client.getGameState() != GameState.LOGGED_IN)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class FightCaveOverlay extends Overlay
|
|||||||
public Dimension render(Graphics2D graphics, Point parent)
|
public Dimension render(Graphics2D graphics, Point parent)
|
||||||
{
|
{
|
||||||
JadAttack attack = plugin.getAttack();
|
JadAttack attack = plugin.getAttack();
|
||||||
if (attack == null || client == null || client.isPrayerActive(attack.getPrayer()))
|
if (attack == null || client.isPrayerActive(attack.getPrayer()))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,22 +25,20 @@
|
|||||||
package net.runelite.client.plugins.fightcave;
|
package net.runelite.client.plugins.fightcave;
|
||||||
|
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import java.time.temporal.ChronoUnit;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.Query;
|
import net.runelite.api.Query;
|
||||||
import net.runelite.api.queries.NPCQuery;
|
import net.runelite.api.queries.NPCQuery;
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
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.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Fight cave plugin"
|
name = "Fight cave plugin"
|
||||||
@@ -48,11 +46,10 @@ import net.runelite.client.ui.overlay.Overlay;
|
|||||||
public class FightCavePlugin extends Plugin
|
public class FightCavePlugin extends Plugin
|
||||||
{
|
{
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RuneLite runelite;
|
QueryRunner queryRunner;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
FightCaveConfig config;
|
FightCaveConfig config;
|
||||||
@@ -86,7 +83,7 @@ public class FightCavePlugin extends Plugin
|
|||||||
)
|
)
|
||||||
public void update()
|
public void update()
|
||||||
{
|
{
|
||||||
if (!config.enabled() || client == null || client.getGameState() != GameState.LOGGED_IN)
|
if (!config.enabled() || client.getGameState() != GameState.LOGGED_IN)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -112,7 +109,7 @@ public class FightCavePlugin extends Plugin
|
|||||||
private NPC findJad()
|
private NPC findJad()
|
||||||
{
|
{
|
||||||
Query query = new NPCQuery().nameContains("TzTok-Jad");
|
Query query = new NPCQuery().nameContains("TzTok-Jad");
|
||||||
NPC[] result = runelite.runQuery(query);
|
NPC[] result = queryRunner.runQuery(query);
|
||||||
return result.length >= 1 ? result[0] : null;
|
return result.length >= 1 ? result[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,34 +32,30 @@ import java.awt.Point;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.queries.NPCQuery;
|
import net.runelite.api.queries.NPCQuery;
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
class FishingSpotOverlay extends Overlay
|
class FishingSpotOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private final List<Integer> ids = new ArrayList<>();
|
private final List<Integer> ids = new ArrayList<>();
|
||||||
|
|
||||||
private final RuneLite runelite;
|
private final QueryRunner queryRunner;
|
||||||
private final Client client;
|
|
||||||
private final FishingConfig config;
|
private final FishingConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ItemManager itemManager;
|
ItemManager itemManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FishingSpotOverlay(RuneLite runelite, @Nullable Client client, FishingConfig config)
|
public FishingSpotOverlay(QueryRunner queryRunner, FishingConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
this.runelite = runelite;
|
this.queryRunner = queryRunner;
|
||||||
this.client = client;
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +69,7 @@ class FishingSpotOverlay extends Overlay
|
|||||||
|
|
||||||
NPCQuery query = new NPCQuery()
|
NPCQuery query = new NPCQuery()
|
||||||
.idEquals(Ints.toArray(ids));
|
.idEquals(Ints.toArray(ids));
|
||||||
NPC[] npcs = runelite.runQuery(query);
|
NPC[] npcs = queryRunner.runQuery(query);
|
||||||
|
|
||||||
for (NPC npc : npcs)
|
for (NPC npc : npcs)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ import net.runelite.client.ui.ClientUI;
|
|||||||
import net.runelite.client.ui.NavigationButton;
|
import net.runelite.client.ui.NavigationButton;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Hiscore plugin"
|
name = "Hiscore plugin",
|
||||||
|
loadWhenOutdated = true
|
||||||
)
|
)
|
||||||
public class HiscorePlugin extends Plugin
|
public class HiscorePlugin extends Plugin
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ import java.time.Instant;
|
|||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -47,7 +47,6 @@ import net.runelite.api.Player;
|
|||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.api.queries.GameObjectQuery;
|
import net.runelite.api.queries.GameObjectQuery;
|
||||||
import net.runelite.api.queries.PlayerQuery;
|
import net.runelite.api.queries.PlayerQuery;
|
||||||
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.events.GameObjectsChanged;
|
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.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.task.Schedule;
|
import net.runelite.client.task.Schedule;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
@@ -67,7 +67,7 @@ public class HunterPlugin extends Plugin
|
|||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RuneLite runelite;
|
private QueryRunner queryRunner;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private HunterConfig config;
|
private HunterConfig config;
|
||||||
@@ -139,7 +139,7 @@ public class HunterPlugin extends Plugin
|
|||||||
case ObjectID.NET_TRAP_9002: //Net trap placed at black sallys
|
case ObjectID.NET_TRAP_9002: //Net trap placed at black sallys
|
||||||
//Look for players that are on the same tile
|
//Look for players that are on the same tile
|
||||||
PlayerQuery playerQuery = new PlayerQuery().atLocalLocation(gameObject.getLocalLocation());
|
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
|
/* 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
|
* 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()
|
GameObjectQuery goQuery = new GameObjectQuery()
|
||||||
.atWorldLocation(trap.getGameObject().getWorldLocation());
|
.atWorldLocation(trap.getGameObject().getWorldLocation());
|
||||||
//This is for placeable traps like box traps. There are no gameobjects on that location if the trap collapsed
|
//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();
|
it.remove();
|
||||||
log.debug("Trap removed from personal trap collection, {} left", traps.size());
|
log.debug("Trap removed from personal trap collection, {} left", traps.size());
|
||||||
@@ -303,7 +303,7 @@ public class HunterPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
goQuery = goQuery
|
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.
|
.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();
|
it.remove();
|
||||||
log.debug("Special trap removed from personal trap collection, {} left", traps.size());
|
log.debug("Special trap removed from personal trap collection, {} left", traps.size());
|
||||||
|
|||||||
@@ -25,20 +25,81 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.idlenotifier;
|
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.common.eventbus.Subscribe;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Actor;
|
import net.runelite.api.Actor;
|
||||||
import static net.runelite.api.AnimationID.*;
|
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.Skill;
|
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.config.ConfigManager;
|
||||||
import net.runelite.client.events.AnimationChanged;
|
import net.runelite.client.events.AnimationChanged;
|
||||||
import net.runelite.client.events.GameStateChanged;
|
import net.runelite.client.events.GameStateChanged;
|
||||||
@@ -53,13 +114,12 @@ import net.runelite.client.ui.ClientUI;
|
|||||||
public class IdleNotifierPlugin extends Plugin
|
public class IdleNotifierPlugin extends Plugin
|
||||||
{
|
{
|
||||||
@Inject
|
@Inject
|
||||||
RuneLite runelite;
|
Notifier notifier;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ClientUI gui;
|
ClientUI gui;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -260,7 +320,7 @@ public class IdleNotifierPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
if (config.sendTrayNotification())
|
if (config.sendTrayNotification())
|
||||||
{
|
{
|
||||||
runelite.notify(message);
|
notifier.notify(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,17 +32,15 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.Polygon;
|
import java.awt.Polygon;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Actor;
|
import net.runelite.api.Actor;
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.NpcID;
|
import net.runelite.api.NpcID;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.api.queries.NPCQuery;
|
import net.runelite.api.queries.NPCQuery;
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
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 STATIC_SPAWN = 1618;
|
||||||
private static final int DYNAMIC_SPAWN = 1633;
|
private static final int DYNAMIC_SPAWN = 1633;
|
||||||
|
|
||||||
private final RuneLite runelite;
|
private final QueryRunner queryRunner;
|
||||||
private final Client client;
|
|
||||||
private final ImplingsConfig config;
|
private final ImplingsConfig config;
|
||||||
private final List<Integer> ids = new LinkedList<>();
|
private final List<Integer> ids = new LinkedList<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ImplingsOverlay(RuneLite runelite, @Nullable Client client, ImplingsConfig config)
|
public ImplingsOverlay(QueryRunner queryRunner, ImplingsConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
this.runelite = runelite;
|
this.queryRunner = queryRunner;
|
||||||
this.client = client;
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +69,7 @@ public class ImplingsOverlay extends Overlay
|
|||||||
public Dimension render(Graphics2D graphics, java.awt.Point parent)
|
public Dimension render(Graphics2D graphics, java.awt.Point parent)
|
||||||
{
|
{
|
||||||
NPCQuery implingQuery = new NPCQuery().idEquals(Ints.toArray(ids));
|
NPCQuery implingQuery = new NPCQuery().idEquals(Ints.toArray(ids));
|
||||||
NPC[] implings = runelite.runQuery(implingQuery);
|
NPC[] implings = queryRunner.runQuery(implingQuery);
|
||||||
for (NPC imp : implings)
|
for (NPC imp : implings)
|
||||||
{
|
{
|
||||||
//Spawns have the name "null", so they get changed to "Spawn"
|
//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.queries.InventoryItemQuery;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
class JewelleryCountOverlay extends Overlay
|
class JewelleryCountOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private final RuneLite runelite;
|
private final QueryRunner queryRunner;
|
||||||
private final JewelleryCountConfig config;
|
private final JewelleryCountConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
JewelleryCountOverlay(RuneLite runelite, JewelleryCountConfig config)
|
JewelleryCountOverlay(QueryRunner queryRunner, JewelleryCountConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
this.runelite = runelite;
|
this.queryRunner = queryRunner;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.setDrawOverBankScreen(true);
|
this.setDrawOverBankScreen(true);
|
||||||
}
|
}
|
||||||
@@ -89,14 +89,14 @@ class JewelleryCountOverlay extends Overlay
|
|||||||
private Collection<WidgetItem> getJewelleryWidgetItems()
|
private Collection<WidgetItem> getJewelleryWidgetItems()
|
||||||
{
|
{
|
||||||
Query inventoryQuery = new InventoryItemQuery();
|
Query inventoryQuery = new InventoryItemQuery();
|
||||||
WidgetItem[] inventoryWidgetItems = runelite.runQuery(inventoryQuery);
|
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
||||||
|
|
||||||
Query equipmentQuery = new EquipmentItemQuery().slotEquals(
|
Query equipmentQuery = new EquipmentItemQuery().slotEquals(
|
||||||
WidgetInfo.EQUIPMENT_AMULET,
|
WidgetInfo.EQUIPMENT_AMULET,
|
||||||
WidgetInfo.EQUIPMENT_RING,
|
WidgetInfo.EQUIPMENT_RING,
|
||||||
WidgetInfo.EQUIPMENT_GLOVES
|
WidgetInfo.EQUIPMENT_GLOVES
|
||||||
);
|
);
|
||||||
WidgetItem[] equipmentWidgetItems = runelite.runQuery(equipmentQuery);
|
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
||||||
|
|
||||||
Collection<WidgetItem> jewellery = new ArrayList<>();
|
Collection<WidgetItem> jewellery = new ArrayList<>();
|
||||||
jewellery.addAll(Arrays.asList(inventoryWidgetItems));
|
jewellery.addAll(Arrays.asList(inventoryWidgetItems));
|
||||||
|
|||||||
@@ -45,15 +45,15 @@ import net.runelite.api.Query;
|
|||||||
import net.runelite.api.queries.NPCQuery;
|
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.RuneLite;
|
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PestControlOverlay extends Overlay
|
public class PestControlOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private final RuneLite runelite;
|
private final QueryRunner queryRunner;
|
||||||
private final Client client;
|
private final Client client;
|
||||||
|
|
||||||
private final PestControlPlugin plugin;
|
private final PestControlPlugin plugin;
|
||||||
@@ -62,11 +62,11 @@ public class PestControlOverlay extends Overlay
|
|||||||
private Game game;
|
private Game game;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PestControlOverlay(RuneLite runelite, PestControlPlugin plugin)
|
public PestControlOverlay(QueryRunner queryRunner, Client client, PestControlPlugin plugin)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
this.runelite = runelite;
|
this.queryRunner = queryRunner;
|
||||||
this.client = runelite.getClient();
|
this.client = client;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ public class PestControlOverlay extends Overlay
|
|||||||
private void renderSpinners(Graphics2D graphics)
|
private void renderSpinners(Graphics2D graphics)
|
||||||
{
|
{
|
||||||
Query query = new NPCQuery().nameEquals("Spinner");
|
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));
|
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.common.eventbus.Subscribe;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
@@ -41,7 +40,6 @@ import net.runelite.client.plugins.PluginDescriptor;
|
|||||||
public class RememberUsernamePlugin extends Plugin
|
public class RememberUsernamePlugin extends Plugin
|
||||||
{
|
{
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@@ -40,23 +40,23 @@ import net.runelite.api.queries.EquipmentItemQuery;
|
|||||||
import net.runelite.api.queries.InventoryItemQuery;
|
import net.runelite.api.queries.InventoryItemQuery;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
public class BindNeckOverlay extends Overlay
|
public class BindNeckOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private final RuneLite runelite;
|
private final QueryRunner queryRunner;
|
||||||
private final RunecraftConfig config;
|
private final RunecraftConfig config;
|
||||||
int bindingCharges;
|
int bindingCharges;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BindNeckOverlay(RuneLite runelite, RunecraftConfig config)
|
BindNeckOverlay(QueryRunner queryRunner, RunecraftConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
this.runelite = runelite;
|
this.queryRunner = queryRunner;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.setDrawOverBankScreen(true);
|
this.setDrawOverBankScreen(true);
|
||||||
}
|
}
|
||||||
@@ -91,12 +91,12 @@ public class BindNeckOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
Query inventoryQuery = new InventoryItemQuery()
|
Query inventoryQuery = new InventoryItemQuery()
|
||||||
.idEquals(BINDING_NECKLACE);
|
.idEquals(BINDING_NECKLACE);
|
||||||
WidgetItem[] inventoryWidgetItems = runelite.runQuery(inventoryQuery);
|
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
||||||
|
|
||||||
Query equipmentQuery = new EquipmentItemQuery()
|
Query equipmentQuery = new EquipmentItemQuery()
|
||||||
.slotEquals(WidgetInfo.EQUIPMENT_AMULET)
|
.slotEquals(WidgetInfo.EQUIPMENT_AMULET)
|
||||||
.idEquals(BINDING_NECKLACE);
|
.idEquals(BINDING_NECKLACE);
|
||||||
WidgetItem[] equipmentWidgetItems = runelite.runQuery(equipmentQuery);
|
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
||||||
|
|
||||||
Collection<WidgetItem> necklaces = new ArrayList<>();
|
Collection<WidgetItem> necklaces = new ArrayList<>();
|
||||||
necklaces.addAll(Arrays.asList(inventoryWidgetItems));
|
necklaces.addAll(Arrays.asList(inventoryWidgetItems));
|
||||||
|
|||||||
@@ -35,11 +35,11 @@ import net.runelite.api.Query;
|
|||||||
import net.runelite.api.Varbits;
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.api.queries.InventoryItemQuery;
|
import net.runelite.api.queries.InventoryItemQuery;
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
public class RunecraftOverlay extends Overlay
|
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 LARGE_POUCH_DAMAGED = ItemID.LARGE_POUCH_5513;
|
||||||
private static final int GIANT_POUCH_DAMAGED = ItemID.GIANT_POUCH_5515;
|
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 Client client;
|
||||||
|
|
||||||
private final RunecraftConfig config;
|
private final RunecraftConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RunecraftOverlay(RuneLite runelite, RunecraftConfig config)
|
RunecraftOverlay(QueryRunner queryRunner, Client client, RunecraftConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
this.runelite = runelite;
|
this.queryRunner = queryRunner;
|
||||||
this.client = runelite.getClient();
|
this.client = client;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.setDrawOverBankScreen(true);
|
this.setDrawOverBankScreen(true);
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ public class RunecraftOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
Query query = new InventoryItemQuery();
|
Query query = new InventoryItemQuery();
|
||||||
WidgetItem[] widgetItems = runelite.runQuery(query);
|
WidgetItem[] widgetItems = queryRunner.runQuery(query);
|
||||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||||
|
|
||||||
for (WidgetItem item : widgetItems)
|
for (WidgetItem item : widgetItems)
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ import net.runelite.api.Query;
|
|||||||
import net.runelite.api.Varbits;
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.api.queries.InventoryItemQuery;
|
import net.runelite.api.queries.InventoryItemQuery;
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
import net.runelite.client.ui.overlay.tooltip.Tooltip;
|
import net.runelite.client.ui.overlay.tooltip.Tooltip;
|
||||||
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
|
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
public class RunepouchOverlay extends Overlay
|
public class RunepouchOverlay extends Overlay
|
||||||
{
|
{
|
||||||
@@ -57,18 +57,18 @@ public class RunepouchOverlay extends Overlay
|
|||||||
|
|
||||||
private final RuneImageCache runeImageCache = new RuneImageCache();
|
private final RuneImageCache runeImageCache = new RuneImageCache();
|
||||||
|
|
||||||
private final RuneLite runelite;
|
private final QueryRunner queryRunner;
|
||||||
private final Client client;
|
private final Client client;
|
||||||
private final RunepouchConfig config;
|
private final RunepouchConfig config;
|
||||||
private final TooltipManager tooltipManager;
|
private final TooltipManager tooltipManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RunepouchOverlay(RuneLite runelite, RunepouchConfig config, TooltipManager tooltipManager)
|
RunepouchOverlay(QueryRunner queryRunner, Client client, RunepouchConfig config, TooltipManager tooltipManager)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
this.tooltipManager = tooltipManager;
|
this.tooltipManager = tooltipManager;
|
||||||
this.runelite = runelite;
|
this.queryRunner = queryRunner;
|
||||||
this.client = runelite.getClient();
|
this.client = client;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.setDrawOverBankScreen(true);
|
this.setDrawOverBankScreen(true);
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ public class RunepouchOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
Query query = new InventoryItemQuery().idEquals(ItemID.RUNE_POUCH);
|
Query query = new InventoryItemQuery().idEquals(ItemID.RUNE_POUCH);
|
||||||
WidgetItem[] items = runelite.runQuery(query);
|
WidgetItem[] items = queryRunner.runQuery(query);
|
||||||
if (items.length == 0)
|
if (items.length == 0)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -40,15 +40,15 @@ import net.runelite.api.queries.EquipmentItemQuery;
|
|||||||
import net.runelite.api.queries.InventoryItemQuery;
|
import net.runelite.api.queries.InventoryItemQuery;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
class SlayerOverlay extends Overlay
|
class SlayerOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private final RuneLite runelite;
|
private final QueryRunner queryRunner;
|
||||||
private final SlayerConfig config;
|
private final SlayerConfig config;
|
||||||
private final SlayerPlugin plugin;
|
private final SlayerPlugin plugin;
|
||||||
|
|
||||||
@@ -80,10 +80,10 @@ class SlayerOverlay extends Overlay
|
|||||||
);
|
);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SlayerOverlay(RuneLite runelite, SlayerPlugin plugin, SlayerConfig config)
|
SlayerOverlay(QueryRunner queryRunner, SlayerPlugin plugin, SlayerConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
setPosition(OverlayPosition.DYNAMIC);
|
||||||
this.runelite = runelite;
|
this.queryRunner = queryRunner;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
@@ -132,10 +132,10 @@ class SlayerOverlay extends Overlay
|
|||||||
private Collection<WidgetItem> getSlayerWidgetItems()
|
private Collection<WidgetItem> getSlayerWidgetItems()
|
||||||
{
|
{
|
||||||
Query inventoryQuery = new InventoryItemQuery();
|
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);
|
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);
|
WidgetItem[] items = concat(inventoryWidgetItems, equipmentWidgetItems, WidgetItem.class);
|
||||||
return ImmutableList.copyOf(items);
|
return ImmutableList.copyOf(items);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.slayer;
|
package net.runelite.client.plugins.slayer;
|
||||||
|
|
||||||
|
import static net.runelite.api.Skill.SLAYER;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
@@ -33,13 +34,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import static net.runelite.api.Skill.SLAYER;
|
|
||||||
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.config.ConfigManager;
|
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*)");
|
private static final Pattern REWARD_POINTS = Pattern.compile("Reward points: (\\d*)");
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -146,7 +144,7 @@ public class SlayerPlugin extends Plugin
|
|||||||
)
|
)
|
||||||
public void scheduledChecks()
|
public void scheduledChecks()
|
||||||
{
|
{
|
||||||
if (!config.enabled() || client == null)
|
if (!config.enabled())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,14 @@ package net.runelite.client.plugins.teamcapes;
|
|||||||
|
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.Provides;
|
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.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.Player;
|
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.task.Schedule;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
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(
|
@PluginDescriptor(
|
||||||
name = "Team capes plugin"
|
name = "Team capes plugin"
|
||||||
)
|
)
|
||||||
public class TeamCapesPlugin extends Plugin
|
public class TeamCapesPlugin extends Plugin
|
||||||
{
|
{
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -86,7 +83,7 @@ public class TeamCapesPlugin extends Plugin
|
|||||||
)
|
)
|
||||||
public void update()
|
public void update()
|
||||||
{
|
{
|
||||||
if (!config.enabled() || client == null || client.getGameState() != GameState.LOGGED_IN)
|
if (!config.enabled() || client.getGameState() != GameState.LOGGED_IN)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class VolcanicMineOverlay extends Overlay
|
|||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics, java.awt.Point point)
|
public Dimension render(Graphics2D graphics, java.awt.Point point)
|
||||||
{
|
{
|
||||||
if (client == null || !plugin.getInside() || !config.enabled())
|
if (!plugin.getInside() || !config.enabled())
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,31 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.volcanicmine;
|
package net.runelite.client.plugins.volcanicmine;
|
||||||
|
|
||||||
|
import static java.lang.Math.abs;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.awt.Color;
|
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.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
@@ -59,10 +39,31 @@ import java.util.Map.Entry;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import javax.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.Prayer;
|
||||||
import net.runelite.api.Query;
|
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.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(
|
@PluginDescriptor(
|
||||||
name = "Volcanic mine helper"
|
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>))");
|
private static final Pattern coltagPattern = Pattern.compile("((<col=([0-f]){6}>)|(<\\/col>))");
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RuneLite runeLite;
|
ClientUI clientUI;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
QueryRunner queryRunner;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Notifier notifier;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
VolcanicMineConfig config;
|
VolcanicMineConfig config;
|
||||||
@@ -274,7 +280,7 @@ public class VolcanicMinePlugin extends Plugin
|
|||||||
Query query = new NPCQuery()
|
Query query = new NPCQuery()
|
||||||
.nameEquals(LAVA_BEAST)
|
.nameEquals(LAVA_BEAST)
|
||||||
.isWithinArea(player.getLocalLocation(), LAVA_BEAST_ATTACK_RANGE);
|
.isWithinArea(player.getLocalLocation(), LAVA_BEAST_ATTACK_RANGE);
|
||||||
NPC[] npcs = runeLite.runQuery(query);
|
NPC[] npcs = queryRunner.runQuery(query);
|
||||||
return npcs.length > 0;
|
return npcs.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,17 +298,17 @@ 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())
|
||||||
{
|
{
|
||||||
runeLite.notify(message);
|
notifier.notify(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import java.time.Instant;
|
|||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.ChatMessageType;
|
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.config.ConfigManager;
|
||||||
import net.runelite.client.events.ChatMessage;
|
import net.runelite.client.events.ChatMessage;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
@@ -46,7 +46,7 @@ import net.runelite.client.ui.overlay.Overlay;
|
|||||||
public class WoodcuttingPlugin extends Plugin
|
public class WoodcuttingPlugin extends Plugin
|
||||||
{
|
{
|
||||||
@Inject
|
@Inject
|
||||||
RuneLite runelite;
|
Notifier notifier;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
WoodcuttingOverlay overlay;
|
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())
|
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.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Experience;
|
import net.runelite.api.Experience;
|
||||||
@@ -55,7 +54,6 @@ public class XpGlobesPlugin extends Plugin
|
|||||||
private final List<XpGlobe> xpGlobes = new ArrayList<>();
|
private final List<XpGlobe> xpGlobes = new ArrayList<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@@ -24,10 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.xptracker;
|
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.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -35,13 +31,16 @@ import java.text.NumberFormat;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import javax.annotation.Nullable;
|
import javax.imageio.ImageIO;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.api.Skill;
|
||||||
|
import net.runelite.client.ui.PluginPanel;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class XpPanel extends PluginPanel
|
public class XpPanel extends PluginPanel
|
||||||
@@ -50,7 +49,6 @@ public class XpPanel extends PluginPanel
|
|||||||
private final XpTrackerPlugin xpTracker;
|
private final XpTrackerPlugin xpTracker;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import net.runelite.client.plugins.Plugin;
|
|||||||
import net.runelite.client.ui.ClientUI;
|
import net.runelite.client.ui.ClientUI;
|
||||||
import net.runelite.client.ui.NavigationButton;
|
import net.runelite.client.ui.NavigationButton;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.task.Schedule;
|
import net.runelite.client.task.Schedule;
|
||||||
@@ -51,7 +50,6 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
ClientUI ui;
|
ClientUI ui;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
private NavigationButton navButton;
|
private NavigationButton navButton;
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import java.io.IOException;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
@@ -50,7 +49,6 @@ public class XteaPlugin extends Plugin
|
|||||||
private final Set<Integer> sentRegions = new HashSet<>();
|
private final Set<Integer> sentRegions = new HashSet<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import com.google.inject.Provides;
|
|||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
@@ -39,7 +38,6 @@ import net.runelite.api.GameState;
|
|||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.Query;
|
import net.runelite.api.Query;
|
||||||
import net.runelite.api.queries.NPCQuery;
|
import net.runelite.api.queries.NPCQuery;
|
||||||
import net.runelite.client.RuneLite;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
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.plugins.zulrah.phase.ZulrahPhase;
|
||||||
import net.runelite.client.task.Schedule;
|
import net.runelite.client.task.Schedule;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
import net.runelite.client.util.QueryRunner;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Zulrah plugin"
|
name = "Zulrah plugin"
|
||||||
@@ -63,10 +62,9 @@ import net.runelite.client.ui.overlay.Overlay;
|
|||||||
public class ZulrahPlugin extends Plugin
|
public class ZulrahPlugin extends Plugin
|
||||||
{
|
{
|
||||||
@Inject
|
@Inject
|
||||||
RuneLite runelite;
|
QueryRunner queryRunner;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -118,7 +116,7 @@ public class ZulrahPlugin extends Plugin
|
|||||||
)
|
)
|
||||||
public void update()
|
public void update()
|
||||||
{
|
{
|
||||||
if (!config.enabled() || client == null || client.getGameState() != GameState.LOGGED_IN)
|
if (!config.enabled() || client.getGameState() != GameState.LOGGED_IN)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -187,7 +185,7 @@ public class ZulrahPlugin extends Plugin
|
|||||||
private NPC findZulrah()
|
private NPC findZulrah()
|
||||||
{
|
{
|
||||||
Query query = new NPCQuery().nameEquals("Zulrah");
|
Query query = new NPCQuery().nameEquals("Zulrah");
|
||||||
NPC[] result = runelite.runQuery(query);
|
NPC[] result = queryRunner.runQuery(query);
|
||||||
return result.length == 1 ? result[0] : null;
|
return result.length == 1 ? result[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class ZulrahPrayerOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
ZulrahInstance instance = plugin.getInstance();
|
ZulrahInstance instance = plugin.getInstance();
|
||||||
|
|
||||||
if (client == null || instance == null)
|
if (instance == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,89 +25,46 @@
|
|||||||
package net.runelite.client.ui;
|
package net.runelite.client.ui;
|
||||||
|
|
||||||
import java.applet.Applet;
|
import java.applet.Applet;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.BorderLayout;
|
import javax.annotation.Nullable;
|
||||||
import java.io.IOException;
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.client.ClientLoader;
|
|
||||||
import net.runelite.http.api.updatecheck.UpdateCheckClient;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
final class ClientPanel extends JPanel
|
final class ClientPanel extends JPanel
|
||||||
{
|
{
|
||||||
public static final int PANEL_WIDTH = 765, PANEL_HEIGHT = 503;
|
public static final int PANEL_WIDTH = 765, PANEL_HEIGHT = 503;
|
||||||
|
|
||||||
private final ClientUI ui;
|
public ClientPanel(@Nullable Applet client)
|
||||||
private Applet rs;
|
|
||||||
|
|
||||||
public ClientPanel(ClientUI ui)
|
|
||||||
{
|
{
|
||||||
this.ui = ui;
|
|
||||||
setSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
setSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||||
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||||
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setBackground(Color.black);
|
setBackground(Color.black);
|
||||||
}
|
|
||||||
|
|
||||||
public void loadRs() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException
|
if (client == null)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(rs instanceof Client))
|
client.setLayout(null);
|
||||||
{
|
client.setSize(PANEL_WIDTH, PANEL_HEIGHT);
|
||||||
log.error("Injected client does not implement Client!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
// This causes the whole game frame to be redrawn each frame instead
|
||||||
// of only the viewport, so we can hook to MainBufferProvider#draw
|
// of only the viewport, so we can hook to MainBufferProvider#draw
|
||||||
// and draw anywhere without it leaving artifacts
|
// 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;
|
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.BorderLayout;
|
||||||
import java.awt.Dimension;
|
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.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.ScrollPaneConstants;
|
import javax.swing.ScrollPaneConstants;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.ToolTipManager;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
import javax.swing.plaf.FontUIResource;
|
import javax.swing.plaf.FontUIResource;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
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;
|
import org.pushingpixels.substance.internal.ui.SubstanceRootPaneUI;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -50,24 +65,79 @@ public class ClientUI extends JFrame
|
|||||||
private static final int CLIENT_WIDTH = 809;
|
private static final int CLIENT_WIDTH = 809;
|
||||||
private static final int SCROLLBAR_WIDTH = 17;
|
private static final int SCROLLBAR_WIDTH = 17;
|
||||||
private static final int EXPANDED_WIDTH = CLIENT_WIDTH + PluginPanel.PANEL_WIDTH + SCROLLBAR_WIDTH;
|
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 container;
|
||||||
private JPanel navContainer;
|
private JPanel navContainer;
|
||||||
private ClientPanel panel;
|
|
||||||
private PluginToolbar pluginToolbar;
|
private PluginToolbar pluginToolbar;
|
||||||
private PluginPanel pluginPanel;
|
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()));
|
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();
|
init();
|
||||||
pack();
|
pack();
|
||||||
TitleBarPane titleBarPane = new TitleBarPane(this.getRootPane(), (SubstanceRootPaneUI)this.getRootPane().getUI());
|
new TitleBarPane(this.getRootPane(), (SubstanceRootPaneUI)this.getRootPane().getUI()).editTitleBar(this);
|
||||||
titleBarPane.editTitleBar(this);
|
setTitle(null);
|
||||||
setTitle("RuneLite");
|
setIconImage(ICON);
|
||||||
setIconImage(RuneLite.ICON);
|
|
||||||
setLocationRelativeTo(getOwner());
|
setLocationRelativeTo(getOwner());
|
||||||
setResizable(true);
|
setResizable(true);
|
||||||
setVisible(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()
|
private void init()
|
||||||
{
|
{
|
||||||
assert SwingUtilities.isEventDispatchThread();
|
assert SwingUtilities.isEventDispatchThread();
|
||||||
@@ -106,21 +225,7 @@ public class ClientUI extends JFrame
|
|||||||
|
|
||||||
container = new JPanel();
|
container = new JPanel();
|
||||||
container.setLayout(new BorderLayout(0, 0));
|
container.setLayout(new BorderLayout(0, 0));
|
||||||
|
container.add(new ClientPanel(client), BorderLayout.CENTER);
|
||||||
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);
|
|
||||||
|
|
||||||
navContainer = new JPanel();
|
navContainer = new JPanel();
|
||||||
navContainer.setLayout(new BorderLayout(0, 0));
|
navContainer.setLayout(new BorderLayout(0, 0));
|
||||||
@@ -183,11 +288,10 @@ public class ClientUI extends JFrame
|
|||||||
|
|
||||||
private void checkExit()
|
private void checkExit()
|
||||||
{
|
{
|
||||||
Client client = runelite.getClient();
|
|
||||||
int result = JOptionPane.OK_OPTION;
|
int result = JOptionPane.OK_OPTION;
|
||||||
|
|
||||||
// only ask if not logged out
|
// 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);
|
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;
|
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.awt.Rectangle;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -61,7 +60,6 @@ public class PanelComponent implements RenderableEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Nullable
|
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
@Setter
|
@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);
|
private static final Logger logger = LoggerFactory.getLogger(ExamplePlugin.class);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Nullable
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
Reference in New Issue
Block a user