Remove object wrappers and use mixins to inject functionality
This causes hierarchy to be runelite-client -> runelite-api and injected-client -> runescape-api -> runelite-api. The mixin injector fufills the runelite-api interface with access to the runescape-api interfaces. The mixins live in runelite-mixins and are not loaded within the client. Note the obfuscated client classes do not pass JVM verification on 7+, so the mixins are currently set to target Java 6.
This commit is contained in:
@@ -52,6 +52,7 @@ import javax.swing.UnsupportedLookAndFeelException;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Query;
|
||||
import net.runelite.client.account.AccountSession;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.events.SessionClose;
|
||||
@@ -428,4 +429,9 @@ public class RuneLite
|
||||
{
|
||||
return infoBoxManager;
|
||||
}
|
||||
|
||||
public <T> T[] runQuery(Query query)
|
||||
{
|
||||
return (T[]) query.result(client);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,9 @@ package net.runelite.client.callback;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.MainBufferProvider;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MessageNode;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.events.*;
|
||||
@@ -35,8 +37,6 @@ import net.runelite.client.game.DeathChecker;
|
||||
import net.runelite.client.task.Scheduler;
|
||||
import net.runelite.client.ui.overlay.OverlayRenderer;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.rs.api.MainBufferProvider;
|
||||
import net.runelite.rs.api.MessageNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -205,7 +205,7 @@ public class Hooks
|
||||
// Hook is fired prior to actually setting these on the MessageNode, so send them
|
||||
// in the event too.
|
||||
SetMessage setMessage = new SetMessage();
|
||||
setMessage.setMessageNode(new net.runelite.api.MessageNode(messageNode));
|
||||
setMessage.setMessageNode(messageNode);
|
||||
setMessage.setType(ChatMessageType.of(type));
|
||||
setMessage.setName(name);
|
||||
setMessage.setSender(sender);
|
||||
|
||||
@@ -119,7 +119,7 @@ public class MenuManager
|
||||
|
||||
client.getPlayerOptions()[playerOptionIndex] = menuText;
|
||||
client.getPlayerOptionsPriorities()[playerOptionIndex] = true;
|
||||
client.getPlayerMenuType()[playerOptionIndex] = MenuAction.RUNELITE.getId();
|
||||
client.getPlayerMenuTypes()[playerOptionIndex] = MenuAction.RUNELITE.getId();
|
||||
|
||||
playerMenuIndexMap.put(playerOptionIndex, menuText);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.ItemComposition;
|
||||
import net.runelite.api.MessageNode;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.events.SetMessage;
|
||||
@@ -46,7 +47,6 @@ import net.runelite.http.api.item.Item;
|
||||
import net.runelite.http.api.item.ItemClient;
|
||||
import net.runelite.http.api.item.ItemPrice;
|
||||
import net.runelite.http.api.item.SearchResult;
|
||||
import net.runelite.rs.api.ItemComposition;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.ItemComposition;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.rs.api.ItemComposition;
|
||||
|
||||
public class ClueScrollOverlay extends Overlay
|
||||
{
|
||||
|
||||
@@ -123,7 +123,7 @@ public class DevToolsOverlay extends Overlay
|
||||
|
||||
private void renderPlayers(Graphics2D graphics)
|
||||
{
|
||||
Player[] players = client.getPlayers();
|
||||
Player[] players = client.getCachedPlayers();
|
||||
Player local = client.getLocalPlayer();
|
||||
|
||||
if (players != null && (players.length - 1) > 0)
|
||||
@@ -148,7 +148,7 @@ public class DevToolsOverlay extends Overlay
|
||||
|
||||
private void renderNpcs(Graphics2D graphics)
|
||||
{
|
||||
NPC[] npcs = client.getNpcs();
|
||||
NPC[] npcs = client.getCachedNPCs();
|
||||
if (npcs != null && (npcs.length - 1) > 0)
|
||||
{
|
||||
for (NPC npc : npcs)
|
||||
|
||||
@@ -53,8 +53,9 @@ class FishingSpotOverlay extends Overlay
|
||||
|
||||
private final List<Integer> ids = new ArrayList<>();
|
||||
|
||||
private final RuneLite runelite = RuneLite.getRunelite();
|
||||
private final Client client = RuneLite.getClient();
|
||||
private final FishingConfig config;
|
||||
private final static Client client = RuneLite.getClient();
|
||||
|
||||
public FishingSpotOverlay(FishingPlugin plugin)
|
||||
{
|
||||
@@ -72,7 +73,7 @@ class FishingSpotOverlay extends Overlay
|
||||
|
||||
NPCQuery query = new NPCQuery()
|
||||
.idEquals(Ints.toArray(ids));
|
||||
NPC[] npcs = client.runQuery(query);
|
||||
NPC[] npcs = runelite.runQuery(query);
|
||||
|
||||
for (NPC npc : npcs)
|
||||
{
|
||||
|
||||
@@ -41,6 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemComposition;
|
||||
import net.runelite.api.ItemLayer;
|
||||
import net.runelite.api.Node;
|
||||
import net.runelite.api.Player;
|
||||
@@ -53,7 +54,6 @@ import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.http.api.item.ItemPrice;
|
||||
import net.runelite.rs.api.ItemComposition;
|
||||
|
||||
public class GroundItemsOverlay extends Overlay
|
||||
{
|
||||
|
||||
@@ -54,11 +54,12 @@ public class ImplingsOverlay extends Overlay
|
||||
private static final int STATIC_SPAWN = 1618;
|
||||
private static final int DYNAMIC_SPAWN = 1633;
|
||||
|
||||
private final RuneLite runelite = RuneLite.getRunelite();
|
||||
private final Client client = RuneLite.getClient();
|
||||
|
||||
private final ImplingsConfig config;
|
||||
private final List<Integer> ids;
|
||||
|
||||
private final Client client = RuneLite.getClient();
|
||||
|
||||
public ImplingsOverlay(Implings plugin)
|
||||
{
|
||||
super(OverlayPosition.DYNAMIC);
|
||||
@@ -75,7 +76,7 @@ public class ImplingsOverlay extends Overlay
|
||||
}
|
||||
|
||||
NPCQuery implingQuery = new NPCQuery().idEquals(Ints.toArray(ids));
|
||||
NPC[] implings = client.runQuery(implingQuery);
|
||||
NPC[] implings = runelite.runQuery(implingQuery);
|
||||
for (NPC imp : implings)
|
||||
{
|
||||
//Spawns have the name "null", so they get changed to "Spawn"
|
||||
|
||||
@@ -66,7 +66,7 @@ class MouseHighlightOverlay extends Overlay
|
||||
|
||||
String[] targets = client.getMenuTargets();
|
||||
String[] options = client.getMenuOptions();
|
||||
int count = client.getMenuCount() - 1;
|
||||
int count = client.getMenuOptionCount() - 1;
|
||||
|
||||
if (count < 0 || count >= targets.length || count >= options.length)
|
||||
{
|
||||
|
||||
@@ -54,7 +54,9 @@ public class PestControlOverlay extends Overlay
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(PestControlOverlay.class);
|
||||
|
||||
private final RuneLite runelite = RuneLite.getRunelite();
|
||||
private final Client client = RuneLite.getClient();
|
||||
|
||||
private final PestControl plugin;
|
||||
|
||||
// Pest control game
|
||||
@@ -107,7 +109,7 @@ public class PestControlOverlay extends Overlay
|
||||
private void renderSpinners(Graphics2D graphics)
|
||||
{
|
||||
Query query = new NPCQuery().nameEquals("Spinner");
|
||||
NPC[] result = client.runQuery(query);
|
||||
NPC[] result = runelite.runQuery(query);
|
||||
Arrays.stream(result).forEach(npc -> OverlayUtil.renderActorOverlay(graphics, npc, npc.getName(), Color.CYAN));
|
||||
}
|
||||
|
||||
@@ -266,4 +268,4 @@ public class PestControlOverlay extends Overlay
|
||||
{
|
||||
return widget.getText().trim().equals("0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class XpGlobesOverlay extends Overlay
|
||||
}
|
||||
|
||||
//check the width of the client if we can draw properly
|
||||
int clientWidth = client.isResized() ? client.getClientWidth() : client.getViewportHeight();
|
||||
int clientWidth = client.isResized() ? client.getCanvas().getWidth() : client.getViewportHeight();
|
||||
if (clientWidth <= 0)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -51,6 +51,7 @@ public class Zulrah extends Plugin
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(Zulrah.class);
|
||||
|
||||
private final RuneLite runelite = RuneLite.getRunelite();
|
||||
private final Client client = RuneLite.getClient();
|
||||
|
||||
private final StatusOverlay overlay = new StatusOverlay(this);
|
||||
@@ -171,7 +172,7 @@ public class Zulrah extends Plugin
|
||||
private NPC findZulrah()
|
||||
{
|
||||
Query query = new NPCQuery().nameEquals("Zulrah");
|
||||
NPC[] result = client.runQuery(query);
|
||||
NPC[] result = runelite.runQuery(query);
|
||||
return result.length == 1 ? result[0] : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,13 +84,14 @@ final class ClientPanel extends JPanel
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(rs instanceof net.runelite.rs.api.Client))
|
||||
if (!(rs instanceof Client))
|
||||
{
|
||||
logger.error("Injected client does not implement Client!");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
Client client = new Client((net.runelite.rs.api.Client) rs);
|
||||
Client client = (Client) rs;
|
||||
|
||||
RuneLite.setClient(client);
|
||||
|
||||
// This causes the whole game frame to be redrawn each frame instead
|
||||
|
||||
@@ -52,8 +52,8 @@ public class TopDownRendererRight implements Renderer
|
||||
overlays.sort((o1, o2) -> o2.getPriority().compareTo(o1.getPriority()));
|
||||
|
||||
int y = BORDER_TOP;
|
||||
int clientWidth = client.getClientWidth();
|
||||
int clientHeight = client.getClientHeight();
|
||||
int clientWidth = client.getCanvas().getWidth();
|
||||
int clientHeight = client.getCanvas().getHeight();
|
||||
|
||||
for (Overlay overlay : overlays)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user