From 59886b084ae2740e30c225eb0f2bd79fb41fdbcd Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 6 Jun 2019 09:56:03 -0400 Subject: [PATCH 01/63] mixins: fix duplicate spawn events for large gameobjects --- .../java/net/runelite/mixins/RSTileMixin.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java index 093fa17d88..1cb4a729a8 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java @@ -76,6 +76,9 @@ public abstract class RSTileMixin implements RSTile @Shadow("clientInstance") private static RSClient client; + @Inject + private static RSGameObject lastGameObject; + @Inject private static RSDeque[][][] lastGroundItems = new RSDeque[Constants.MAX_Z][Constants.SCENE_SIZE][Constants.SCENE_SIZE]; @@ -234,12 +237,26 @@ public abstract class RSTileMixin implements RSTile // Update previous object to current previousGameObjects[idx] = current; + // Last game object + RSGameObject last = lastGameObject; + + // Update last game object + lastGameObject = current; + // Duplicate event, return if (current == previous) { return; } + if (current != null && current == last) + { + // When >1 tile objects are added to the scene, the same GameObject is added to + // multiple tiles. We keep lastGameObject to prevent duplicate spawn events from + // firing for these objects. + return; + } + // actors, projectiles, and graphics objects are added and removed from the scene each frame as GameObjects, // so ignore them. boolean currentInvalid = false, prevInvalid = false; From bb25aee4cc190463c694498039a311b4dcbb147a Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 7 Jun 2019 17:34:32 -0400 Subject: [PATCH 02/63] key remapping: don't remap fkeys when options dialog is open --- .../keyremapping/KeyRemappingListener.java | 5 ++++- .../keyremapping/KeyRemappingPlugin.java | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java index 89c88345fa..ba1b3cfa29 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java @@ -107,7 +107,10 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener } } - if (config.fkeyRemap()) + // In addition to the above checks, the F-key remapping shouldn't + // activate when dialogs are open which listen for number keys + // to select options + if (config.fkeyRemap() && !plugin.isDialogOpen()) { if (ONE.matches(e)) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java index eb9e7ebc1a..24a48224b0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java @@ -131,6 +131,26 @@ public class KeyRemappingPlugin extends Plugin return true; } + /** + * Check if a dialog is open that will grab numerical input, to prevent F-key remapping + * from triggering. + * + * @return + */ + boolean isDialogOpen() + { + // Most chat dialogs with numerical input are added without the chatbox or its key listener being removed, + // so chatboxFocused() is true. The chatbox onkey script uses the following logic to ignore key presses, + // so we will use it too to not remap F-keys. + return isHidden(WidgetInfo.CHATBOX_MESSAGES) || isHidden(WidgetInfo.CHATBOX_TRANSPARENT_LINES); + } + + private boolean isHidden(WidgetInfo widgetInfo) + { + Widget w = client.getWidget(widgetInfo); + return w == null || w.isSelfHidden(); + } + @Subscribe public void onScriptCallbackEvent(ScriptCallbackEvent scriptCallbackEvent) { From 5f972f5bcc3c9222d9fac84c59c3ddb840f2f938 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 7 Jun 2019 19:06:06 -0400 Subject: [PATCH 03/63] key remapping: remove some unused widget and keylistener checks --- .../keyremapping/KeyRemappingPlugin.java | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java index 24a48224b0..89d833c92b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java @@ -179,31 +179,23 @@ public class KeyRemappingPlugin extends Plugin void lockChat() { - Widget chatboxParent = client.getWidget(WidgetInfo.CHATBOX_PARENT); - if (chatboxParent != null && chatboxParent.getOnKeyListener() != null) + Widget chatboxInput = client.getWidget(WidgetInfo.CHATBOX_INPUT); + if (chatboxInput != null) { - Widget chatboxInput = client.getWidget(WidgetInfo.CHATBOX_INPUT); - if (chatboxInput != null) - { - chatboxInput.setText(getPlayerNameWithIcon() + ": " + PRESS_ENTER_TO_CHAT); - } + chatboxInput.setText(getPlayerNameWithIcon() + ": " + PRESS_ENTER_TO_CHAT); } } void unlockChat() { - Widget chatboxParent = client.getWidget(WidgetInfo.CHATBOX_PARENT); - if (chatboxParent != null) + Widget chatboxInput = client.getWidget(WidgetInfo.CHATBOX_INPUT); + if (chatboxInput != null) { - Widget chatboxInput = client.getWidget(WidgetInfo.CHATBOX_INPUT); - if (chatboxInput != null) + if (client.getGameState() == GameState.LOGGED_IN) { - if (client.getGameState() == GameState.LOGGED_IN) - { - final boolean isChatboxTransparent = client.isResized() && client.getVar(Varbits.TRANSPARENT_CHATBOX) == 1; - final Color textColor = isChatboxTransparent ? JagexColors.CHAT_TYPED_TEXT_TRANSPARENT_BACKGROUND : JagexColors.CHAT_TYPED_TEXT_OPAQUE_BACKGROUND; - chatboxInput.setText(getPlayerNameWithIcon() + ": " + ColorUtil.wrapWithColorTag(client.getVar(VarClientStr.CHATBOX_TYPED_TEXT) + "*", textColor)); - } + final boolean isChatboxTransparent = client.isResized() && client.getVar(Varbits.TRANSPARENT_CHATBOX) == 1; + final Color textColor = isChatboxTransparent ? JagexColors.CHAT_TYPED_TEXT_TRANSPARENT_BACKGROUND : JagexColors.CHAT_TYPED_TEXT_OPAQUE_BACKGROUND; + chatboxInput.setText(getPlayerNameWithIcon() + ": " + ColorUtil.wrapWithColorTag(client.getVar(VarClientStr.CHATBOX_TYPED_TEXT) + "*", textColor)); } } } From b5acb61771d31fa31266a545b485d72ee92a655c Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 7 Jun 2019 19:06:46 -0400 Subject: [PATCH 04/63] key remapping: fix clearing input when plugin is turned on --- .../plugins/keyremapping/KeyRemappingListener.java | 11 +++-------- .../plugins/keyremapping/KeyRemappingPlugin.java | 2 ++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java index ba1b3cfa29..56cf3bbedc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java @@ -191,23 +191,18 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: + case KeyEvent.VK_ESCAPE: plugin.setTyping(false); clientThread.invoke(plugin::lockChat); break; - case KeyEvent.VK_ESCAPE: - plugin.setTyping(false); - clientThread.invoke(() -> - { - client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, ""); - plugin.lockChat(); - }); - break; case KeyEvent.VK_BACK_SPACE: + // Only lock chat on backspace when the typed text is now empty if (Strings.isNullOrEmpty(client.getVar(VarClientStr.CHATBOX_TYPED_TEXT))) { plugin.setTyping(false); clientThread.invoke(plugin::lockChat); } + break; } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java index 89d833c92b..0bfebefdb1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java @@ -183,6 +183,8 @@ public class KeyRemappingPlugin extends Plugin if (chatboxInput != null) { chatboxInput.setText(getPlayerNameWithIcon() + ": " + PRESS_ENTER_TO_CHAT); + // Typed text can be non-empty on plugin start, so clear it now + client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, ""); } } From bcc9943b7c29e5d468a5a0dae6f6f92754aa2618 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 7 Jun 2019 19:00:00 -0400 Subject: [PATCH 05/63] scripts: correctly pop unused input string when blocking chat input --- runelite-client/src/main/scripts/CommandScript.rs2asm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/scripts/CommandScript.rs2asm b/runelite-client/src/main/scripts/CommandScript.rs2asm index 1c523d5aa2..0dc4503c95 100644 --- a/runelite-client/src/main/scripts/CommandScript.rs2asm +++ b/runelite-client/src/main/scripts/CommandScript.rs2asm @@ -322,8 +322,11 @@ LABEL241: iconst 0 ; sconst "blockChatInput" ; runelite_callback ; - if_icmpeq LABEL247 ; don't add to input varcstr + if_icmpeq SKIPSETVARC ; skip setting varc with input set_varc_string 335 + jump LABEL247 ; jump over SKIPSETVARC +SKIPSETVARC: + pop_string ; pop message LABEL247: invoke 223 return From e13ae0495acc43a3000bb6825aaf1b6b297ce7ee Mon Sep 17 00:00:00 2001 From: Jacky Liang <37294123+jkybtw@users.noreply.github.com> Date: Sat, 8 Jun 2019 13:23:30 +1000 Subject: [PATCH 06/63] clue plugin: add Weiss coordinate clue description --- .../client/plugins/cluescrolls/clues/CoordinateClue.java | 1 + 1 file changed, 1 insertion(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java index 861958613b..72f06bd167 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java @@ -166,6 +166,7 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati .put(new WorldPoint(3380, 3963, 0), "Wilderness. North of Volcano.") .put(new WorldPoint(3051, 3736, 0), "East of the Wilderness Obelisk in 28 Wilderness.") .put(new WorldPoint(2316, 3814, 0), "West of Neitiznot, near the bridge.") + .put(new WorldPoint(2872, 3937, 0), "Weiss.") // Master .put(new WorldPoint(2178, 3209, 0), "South of Elf Camp.") .put(new WorldPoint(2155, 3100, 0), "South of Port Tyras (BJS).") From a5c1a4e6f232f4f6862922808f22474eeaf4cbe2 Mon Sep 17 00:00:00 2001 From: Aundron Date: Sat, 8 Jun 2019 05:30:47 +0200 Subject: [PATCH 07/63] clue plugin: update Hosidius allotment clue location for rework --- .../runelite/client/plugins/cluescrolls/clues/AnagramClue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java index c59a79728c..a8b59775e5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/AnagramClue.java @@ -98,7 +98,7 @@ public class AnagramClue extends ClueScroll implements TextClueScroll, NpcClueSc new AnagramClue("HE DO POSE. IT IS CULTRRL, MK?", "Riki the sculptor's model", new WorldPoint(2904, 10206, 0), "East Keldagrim, south of kebab seller."), new AnagramClue("HEORIC", "Eohric", new WorldPoint(2900, 3565, 0), "Top floor of Burthorpe Castle", "36"), new AnagramClue("HIS PHOR", "Horphis", new WorldPoint(1639, 3812, 0), "Arceuus Library, Zeah", "1"), - new AnagramClue("I AM SIR", "Marisi", new WorldPoint(1813, 3488, 0), "Allotment patch, South coast Zeah", "5"), + new AnagramClue("I AM SIR", "Marisi", new WorldPoint(1737, 3557, 0), "Allotment patch, South of Hosidius chapel", "5"), new AnagramClue("ICY FE", "Fycie", new WorldPoint(2630, 2997, 0), "East Feldip Hills"), new AnagramClue("I DOOM ICON INN", "Dominic Onion", new WorldPoint(2609, 3116, 0), "Nightmare Zone", "9,500"), new AnagramClue("I EAT ITS CHART HINTS DO U", "Shiratti the Custodian", new WorldPoint(3427, 2927, 0), "North of fountain, Nardah"), From 29930d7911797342a28326787d080fa6a28b0999 Mon Sep 17 00:00:00 2001 From: Jacky Date: Wed, 5 Jun 2019 21:08:04 +1000 Subject: [PATCH 08/63] Add additional info to waterbirth coordinate clue --- .../client/plugins/cluescrolls/clues/CoordinateClue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java index 72f06bd167..0e73bd7f85 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CoordinateClue.java @@ -182,7 +182,7 @@ public class CoordinateClue extends ClueScroll implements TextClueScroll, Locati .put(new WorldPoint(3085, 3569, 0), "Wilderness. Obelisk of Air.") .put(new WorldPoint(2934, 2727, 0), "Eastern shore of Crash Island.") .put(new WorldPoint(1451, 3695, 0), "West side of Lizardman Canyon with Lizardman shaman.") - .put(new WorldPoint(2538, 3739, 0), "Waterbirth Island.") + .put(new WorldPoint(2538, 3739, 0), "Waterbirth Island. Bring a pet rock and rune thrownaxe.") .put(new WorldPoint(1698, 3792, 0), "Arceuus church.") .put(new WorldPoint(2951, 3820, 0), "Wilderness. Chaos Temple (level 38).") .put(new WorldPoint(2202, 3825, 0), "Pirates' Cove, between Lunar Isle and Rellekka.") From 3252d1dd917d218817fe2953ce81140af9abb2d2 Mon Sep 17 00:00:00 2001 From: gregg1494 Date: Fri, 7 Jun 2019 22:36:03 -0500 Subject: [PATCH 09/63] mining plugin: add sandstone and granite --- .../main/java/net/runelite/client/plugins/mining/Rock.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/Rock.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/Rock.java index ce0d78308e..be9ae0b401 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/Rock.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/Rock.java @@ -43,6 +43,8 @@ import static net.runelite.api.ObjectID.ROCKS_11374; import static net.runelite.api.ObjectID.ROCKS_11375; import static net.runelite.api.ObjectID.ROCKS_11376; import static net.runelite.api.ObjectID.ROCKS_11377; +import static net.runelite.api.ObjectID.ROCKS_11386; +import static net.runelite.api.ObjectID.ROCKS_11387; enum Rock { @@ -65,7 +67,9 @@ enum Rock } }, SILVER(Duration.ofMinutes(1), ROCKS_11369), + SANDSTONE(Duration.ofMillis(5400), ROCKS_11386), GOLD(Duration.ofMinutes(1), ROCKS_11370, ROCKS_11371), + GRANITE(Duration.ofMillis(5400), ROCKS_11387), MITHRIL(Duration.ofMinutes(2), ROCKS_11372, ROCKS_11373) { @Override From e88e2cdf856ae8212f5dbc9c3cfe8fdf9faf3ab0 Mon Sep 17 00:00:00 2001 From: William Collishaw Date: Fri, 7 Jun 2019 22:00:31 -0600 Subject: [PATCH 10/63] Fix typo in 'dumpJson' function name --- cache/src/test/java/net/runelite/cache/MapDumperTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache/src/test/java/net/runelite/cache/MapDumperTest.java b/cache/src/test/java/net/runelite/cache/MapDumperTest.java index 70d20dcb0f..8d1fffd7cb 100644 --- a/cache/src/test/java/net/runelite/cache/MapDumperTest.java +++ b/cache/src/test/java/net/runelite/cache/MapDumperTest.java @@ -165,7 +165,7 @@ public class MapDumperTest @Test @Ignore - public void dunpJson() throws IOException + public void dumpJson() throws IOException { File base = StoreLocation.LOCATION, outDir = folder.newFolder(); From 462818aad7691d54947524b3ad080203e4a5cd7e Mon Sep 17 00:00:00 2001 From: William Collishaw Date: Fri, 7 Jun 2019 19:58:21 -0600 Subject: [PATCH 11/63] Fix typo in 'sessionCheck' function name --- .../main/java/net/runelite/http/api/account/AccountClient.java | 2 +- .../main/java/net/runelite/client/account/SessionManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/http-api/src/main/java/net/runelite/http/api/account/AccountClient.java b/http-api/src/main/java/net/runelite/http/api/account/AccountClient.java index 3f66167367..0a286cd70e 100644 --- a/http-api/src/main/java/net/runelite/http/api/account/AccountClient.java +++ b/http-api/src/main/java/net/runelite/http/api/account/AccountClient.java @@ -96,7 +96,7 @@ public class AccountClient } } - public boolean sesssionCheck() + public boolean sessionCheck() { HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() .addPathSegment("account") diff --git a/runelite-client/src/main/java/net/runelite/client/account/SessionManager.java b/runelite-client/src/main/java/net/runelite/client/account/SessionManager.java index 6ef8c82e73..acac9a3b32 100644 --- a/runelite-client/src/main/java/net/runelite/client/account/SessionManager.java +++ b/runelite-client/src/main/java/net/runelite/client/account/SessionManager.java @@ -94,7 +94,7 @@ public class SessionManager // Check if session is still valid AccountClient accountClient = new AccountClient(session.getUuid()); - if (!accountClient.sesssionCheck()) + if (!accountClient.sessionCheck()) { log.debug("Loaded session {} is invalid", session.getUuid()); return; From 1733147195dcf31bcb624e38ebd597e1cde6b194 Mon Sep 17 00:00:00 2001 From: William Collishaw Date: Fri, 7 Jun 2019 20:24:36 -0600 Subject: [PATCH 12/63] Fix typo in 'getProperties' function name --- cache/src/test/java/net/runelite/cache/CacheProperties.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cache/src/test/java/net/runelite/cache/CacheProperties.java b/cache/src/test/java/net/runelite/cache/CacheProperties.java index 50da8759dc..5614563f72 100644 --- a/cache/src/test/java/net/runelite/cache/CacheProperties.java +++ b/cache/src/test/java/net/runelite/cache/CacheProperties.java @@ -30,7 +30,7 @@ import java.util.Properties; public class CacheProperties { - private static Properties getProperies() throws IOException + private static Properties getProperties() throws IOException { Properties properties = new Properties(); InputStream resourceAsStream = StoreLocation.class.getResourceAsStream("/cache.properties"); @@ -40,11 +40,11 @@ public class CacheProperties public static int getRsVersion() throws IOException { - return Integer.parseInt(getProperies().getProperty("rs.version")); + return Integer.parseInt(getProperties().getProperty("rs.version")); } public static int getCacheVersion() throws IOException { - return Integer.parseInt(getProperies().getProperty("cache.version")); + return Integer.parseInt(getProperties().getProperty("cache.version")); } } From 837be0633d918d04771b528a4af7c6c89100d711 Mon Sep 17 00:00:00 2001 From: 7ate9 <7ate9@users.noreply.github.com`> Date: Sat, 8 Jun 2019 23:52:40 -0400 Subject: [PATCH 13/63] menumanager: adds option to hide entries and switched to Collection.removeIf() when removing entries from sets --- .../runelite/client/menus/MenuManager.java | 170 +++++++++++------- 1 file changed, 103 insertions(+), 67 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java b/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java index 2743d01b25..8af9da478d 100644 --- a/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java +++ b/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java @@ -29,7 +29,6 @@ import com.google.common.base.Preconditions; import com.google.common.collect.HashMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -93,6 +92,7 @@ public class MenuManager private final Set priorityEntries = new HashSet<>(); private final Set currentPriorityEntries = new HashSet<>(); + private final Set hiddenEntries = new HashSet<>(); private final Map swaps = new HashMap<>(); private final Set originalTypes = new HashSet<>(); @@ -192,7 +192,7 @@ public class MenuManager } // Make a copy of the menu entries, cause you can't remove from Arrays.asList() - List copy = new ArrayList<>(Arrays.asList(menuEntries)); + List copy = Lists.newArrayList(menuEntries); // If there are entries we want to prioritize, we have to remove the rest if (!currentPriorityEntries.isEmpty()) @@ -253,6 +253,21 @@ public class MenuManager } } + boolean isHidden = false; + for (ComparableEntry p : hiddenEntries) + { + if (p.matches(newestEntry)) + { + isHidden = true; + break; + } + } + + if (isHidden) + { + copy.remove(newestEntry); + } + client.setMenuEntries(copy.toArray(new MenuEntry[0])); } @@ -599,19 +614,7 @@ public class MenuManager ComparableEntry entry = new ComparableEntry(option, target); - Set toRemove = new HashSet<>(); - for (ComparableEntry priorityEntry : priorityEntries) - { - if (entry.equals(priorityEntry)) - { - toRemove.add(entry); - } - } - - for (ComparableEntry e : toRemove) - { - priorityEntries.remove(e); - } + priorityEntries.removeIf(entry::equals); } @@ -634,19 +637,7 @@ public class MenuManager ComparableEntry entry = new ComparableEntry(option, "", false); - Set toRemove = new HashSet<>(); - for (ComparableEntry priorityEntry : priorityEntries) - { - if (entry.equals(priorityEntry)) - { - toRemove.add(entry); - } - } - - for (ComparableEntry e : toRemove) - { - priorityEntries.remove(e); - } + priorityEntries.removeIf(entry::equals); } /** @@ -757,36 +748,12 @@ public class MenuManager ComparableEntry swapFrom = new ComparableEntry(option, target, id, type, false, false); ComparableEntry swapTo = new ComparableEntry(option2, target2, id2, type2, false, false); - Set toRemove = new HashSet<>(); - for (Map.Entry e : swaps.entrySet()) - { - if (e.getKey().equals(swapFrom) && e.getValue().equals(swapTo)) - { - toRemove.add(e.getKey()); - } - } - - for (ComparableEntry entry : toRemove) - { - swaps.remove(entry); - } + swaps.entrySet().removeIf(e -> e.getKey().equals(swapFrom) && e.getValue().equals(swapTo)); } public void removeSwap(ComparableEntry swapFrom, ComparableEntry swapTo) { - Set toRemove = new HashSet<>(); - for (Map.Entry e : swaps.entrySet()) - { - if (e.getKey().equals(swapFrom) && e.getValue().equals(swapTo)) - { - toRemove.add(e.getKey()); - } - } - - for (ComparableEntry entry : toRemove) - { - swaps.remove(entry); - } + swaps.entrySet().removeIf(e -> e.getKey().equals(swapFrom) && e.getValue().equals(swapTo)); } /** @@ -794,21 +761,90 @@ public class MenuManager */ public void removeSwaps(String withTarget) { - withTarget = Text.standardize(withTarget); + final String target = Text.standardize(withTarget); - Set toRemove = new HashSet<>(); + swaps.keySet().removeIf(e -> e.getTarget().equals(target)); + } - for (ComparableEntry e : swaps.keySet()) - { - if (e.getTarget().equals(withTarget)) - { - toRemove.add(e); - } - } + /** + * Adds to the set of menu entries which when present, will be hidden from the menu + */ + public void addHiddenEntry(String option, String target) + { + option = Text.standardize(option); + target = Text.standardize(target); - for (ComparableEntry entry : toRemove) - { - swaps.remove(entry); - } + ComparableEntry entry = new ComparableEntry(option, target); + + hiddenEntries.add(entry); + } + + public void removeHiddenEntry(String option, String target) + { + option = Text.standardize(option); + target = Text.standardize(target); + + ComparableEntry entry = new ComparableEntry(option, target); + + hiddenEntries.removeIf(entry::equals); + } + + /** + * Adds to the set of menu entries which when present, will be hidden from the menu + * This method will add one with strict option, but not-strict target (contains for target, equals for option) + */ + public void addHiddenEntry(String option) + { + option = Text.standardize(option); + + ComparableEntry entry = new ComparableEntry(option, "", false); + + hiddenEntries.add(entry); + } + + public void removeHiddenEntry(String option) + { + option = Text.standardize(option); + + ComparableEntry entry = new ComparableEntry(option, "", false); + + hiddenEntries.removeIf(entry::equals); + } + + /** + * Adds to the set of hidden entries. + */ + public void addHiddenEntry(String option, String target, boolean strictOption, boolean strictTarget) + { + option = Text.standardize(option); + target = Text.standardize(target); + + ComparableEntry entry = new ComparableEntry(option, target, -1, -1, strictOption, strictTarget); + + hiddenEntries.add(entry); + } + + + public void removeHiddenEntry(String option, String target, boolean strictOption, boolean strictTarget) + { + option = Text.standardize(option); + target = Text.standardize(target); + + ComparableEntry entry = new ComparableEntry(option, target, -1, -1, strictOption, strictTarget); + + hiddenEntries.remove(entry); + } + + /** + * Adds to the set of hidden entries - Pre-baked Abstract entry + */ + public void addHiddenEntry(ComparableEntry entry) + { + hiddenEntries.add(entry); + } + + public void removeHiddenEntry(ComparableEntry entry) + { + hiddenEntries.remove(entry); } } From c5f063ee1b1f13e5c85ca8a1cb5ba7ca7003bf0a Mon Sep 17 00:00:00 2001 From: 7ate9 <7ate9@users.noreply.github.com`> Date: Sat, 8 Jun 2019 23:56:39 -0400 Subject: [PATCH 14/63] menumanager: adds option to hide entries and switched to Collection.removeIf() when removing entries from sets --- .../src/main/java/net/runelite/client/menus/MenuManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java b/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java index 8af9da478d..0c6350a292 100644 --- a/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java +++ b/runelite-client/src/main/java/net/runelite/client/menus/MenuManager.java @@ -824,7 +824,6 @@ public class MenuManager hiddenEntries.add(entry); } - public void removeHiddenEntry(String option, String target, boolean strictOption, boolean strictTarget) { option = Text.standardize(option); From 6e602b946639f89380e0b2728fa76e1d351fba50 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 9 Jun 2019 13:09:09 +0200 Subject: [PATCH 15/63] Added demonic gorilla AoE warnings --- .../aoewarnings/AoeProjectileInfo.java | 7 +++- .../plugins/aoewarnings/AoeWarningConfig.java | 39 ++++++++++++++++++- .../plugins/aoewarnings/AoeWarningPlugin.java | 2 + 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeProjectileInfo.java b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeProjectileInfo.java index 35d2072a19..8463755237 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeProjectileInfo.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeProjectileInfo.java @@ -114,7 +114,12 @@ public enum AoeProjectileInfo /** * Cerbs fire */ - CERB_FIRE(ProjectileID.CERB_FIRE, 2); + CERB_FIRE(ProjectileID.CERB_FIRE, 2), + + /** + * Demonic gorilla + */ + DEMONIC_GORILLA_BOULDER(ProjectileID.DEMONIC_GORILLA_BOULDER, 1); private static final Map map = new HashMap<>(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningConfig.java index 9d0f9c2f2c..486316f39c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningConfig.java @@ -818,4 +818,41 @@ public interface AoeWarningConfig extends Config { return false; } -} + + @ConfigItem( + keyName = "demonicGorillaStub", + name = "Demonic Gorilla", + description = "", + position = 64, + parent = "npcStub" + ) + default Stub demonicGorillaStub() + { + return new Stub(); + } + + @ConfigItem( + keyName = "demonicGorilla", + name = "Demonic Gorilla", + description = "Configures if Demonic Gorilla boulder tile markers are displayed", + parent = "demonicGorillaStub", + position = 65 + ) + default boolean isDemonicGorillaEnabled() + { + return true; + } + + @ConfigItem( + keyName = "demonicGorillaNotify", + name = "Demonic Gorilla Notify", + description = "Configures whether or not AoE Projectile Warnings for Demonic Gorilla boulders should trigger a notification", + parent = "demonicGorillaStub", + position = 66, + hide = "aoeNotifyAll" + ) + default boolean isDemonicGorillaNotifyEnabled() + { + return false; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningPlugin.java index 9bc80a39a4..059336dc72 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningPlugin.java @@ -330,6 +330,8 @@ public class AoeWarningPlugin extends Plugin return notify ? config.isDrakeNotifyEnabled() : config.isDrakeEnabled(); case CERB_FIRE: return notify ? config.isCerbFireNotifyEnabled() : config.isCerbFireEnabled(); + case DEMONIC_GORILLA_BOULDER: + return notify ? config.isDemonicGorillaNotifyEnabled() : config.isDemonicGorillaEnabled(); } return false; From 472d7f8e548d51a44641921ecd3930fd19052b06 Mon Sep 17 00:00:00 2001 From: Jarred Vardy Date: Sun, 9 Jun 2019 20:14:37 +0800 Subject: [PATCH 16/63] Set priority '1' for TRAINING_FISHING DiscordGameEvent (#9061) Solves issue of Discord RPC displaying 'Training: Strength' when barbarian fishing and instead prioritises displaying 'Training: Fishing'. --- .../runelite/client/plugins/discord/DiscordGameEventType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordGameEventType.java b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordGameEventType.java index cd05521228..5280081563 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordGameEventType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordGameEventType.java @@ -53,7 +53,7 @@ enum DiscordGameEventType TRAINING_COOKING(Skill.COOKING), TRAINING_WOODCUTTING(Skill.WOODCUTTING), TRAINING_FLETCHING(Skill.FLETCHING), - TRAINING_FISHING(Skill.FISHING), + TRAINING_FISHING(Skill.FISHING, 1), TRAINING_FIREMAKING(Skill.FIREMAKING), TRAINING_CRAFTING(Skill.CRAFTING), TRAINING_SMITHING(Skill.SMITHING), From 6e497d3a4b6506bc5f1ab5c61086806573db1fe6 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 9 Jun 2019 23:39:06 +0200 Subject: [PATCH 17/63] Add getters for before-ly-hooked fields --- .../java/net/runelite/injector/Inject.java | 2 +- .../net/runelite/injector/InjectHook.java | 21 ++++++++++++++++++- .../net/runelite/injector/MixinInjector.java | 8 +++++++ .../plugins/spellbook/SpellbookPlugin.java | 6 ++---- .../net/runelite/mixins/RSWidgetMixin.java | 15 +++++++------ runescape-client/src/main/java/Client.java | 2 +- runescape-client/src/main/java/class39.java | 7 ++++--- 7 files changed, 45 insertions(+), 16 deletions(-) diff --git a/injector-plugin/src/main/java/net/runelite/injector/Inject.java b/injector-plugin/src/main/java/net/runelite/injector/Inject.java index af5322e60c..53f1c40cc4 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/Inject.java +++ b/injector-plugin/src/main/java/net/runelite/injector/Inject.java @@ -303,7 +303,7 @@ public class Inject apiMethod = findImportMethodOnApi(targetApiClass, exportedName, false); if (apiMethod == null) { - // logger.debug("Unable to find import method on api class {} with imported name {}, not injecting getter", targetApiClass, exportedName); + //logger.debug("Unable to find import method on api class {} with imported name {}, not injecting getter", targetApiClass, exportedName); continue; } diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java b/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java index a89c8019bf..8f40597629 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java @@ -41,9 +41,11 @@ import net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction; import net.runelite.asm.attributes.code.instructions.ArrayStore; import net.runelite.asm.attributes.code.instructions.CheckCast; import net.runelite.asm.attributes.code.instructions.Dup; +import net.runelite.asm.attributes.code.instructions.IMul; import net.runelite.asm.attributes.code.instructions.InvokeStatic; import net.runelite.asm.attributes.code.instructions.InvokeVirtual; import net.runelite.asm.attributes.code.instructions.LDC; +import net.runelite.asm.attributes.code.instructions.LMul; import net.runelite.asm.attributes.code.instructions.PutField; import net.runelite.asm.attributes.code.instructions.Swap; import net.runelite.asm.execution.Execution; @@ -63,6 +65,7 @@ public class InjectHook String clazz; Method method; boolean before; + Number getter; } private static final String HOOK_METHOD_SIGNATURE = "(I)V"; @@ -154,7 +157,7 @@ public class InjectHook } else { - // idx + 1 to insert after the set + // idx + 1 to insert after the set injectCallback(ins, idx + 1, hookInfo, null, objectStackContext); } } @@ -262,6 +265,22 @@ public class InjectHook ins.getInstructions().add(idx++, new Dup(ins)); // dup value idx = recursivelyPush(ins, idx, object); ins.getInstructions().add(idx++, new Swap(ins)); + if (hookInfo.getter != null) + { + assert hookInfo.getter instanceof Integer || hookInfo.getter instanceof Long; + + if (hookInfo.getter instanceof Integer) + { + ins.getInstructions().add(new LDC(ins, (int) hookInfo.getter)); + ins.getInstructions().add(new IMul(ins)); + } + else + { + ins.getInstructions().add(new LDC(ins, (long) hookInfo.getter)); + ins.getInstructions().add(new LMul(ins)); + } + + } if (!value.type.equals(methodArgumentType)) { CheckCast checkCast = new CheckCast(ins); diff --git a/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java b/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java index 9e4b64cacb..032524878a 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java +++ b/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java @@ -909,6 +909,13 @@ public class MixinInjector throw new InjectionException("Field hook for nonexistent field " + hookName + " on " + method); } + Annotation an = targetField.getAnnotations().find(DeobAnnotations.OBFUSCATED_GETTER); + Number getter = null; + if (an != null) + { + getter = (Number) an.getElement().getValue(); + } + Field obField = inject.toObField(targetField); if (method.isStatic() != targetField.isStatic()) @@ -922,6 +929,7 @@ public class MixinInjector hookInfo.fieldName = hookName; hookInfo.method = method; hookInfo.before = before; + hookInfo.getter = getter; injectHook.hook(obField, hookInfo); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java index 5ea8dc7cc9..5f739ab8b5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java @@ -448,9 +448,7 @@ public class SpellbookPlugin extends Plugin } // CHECKSTYLE:OFF - Collection gson = GSON.fromJson(cfg, new TypeToken>() - { - }.getType()); + Collection gson = GSON.fromJson(cfg, new TypeToken>() {}.getType()); // CHECKSTYLE:ON gson.stream().filter(Objects::nonNull).forEach(s -> spells.put(s.getWidget(), s)); @@ -465,7 +463,7 @@ public class SpellbookPlugin extends Plugin private void saveSpells() { - if (spells.isEmpty()) + if (spells.isEmpty() || tmp == null || tmp.isEmpty()) { return; } diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java index 8fa4f2ba2c..4c59a88e53 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java @@ -258,6 +258,11 @@ public abstract class RSWidgetMixin implements RSWidget for (int i = 0; i < itemIds.length; ++i) { + if (itemIds[i] <= 0) + { + continue; + } + WidgetItem item = getWidgetItem(i); if (item != null) @@ -287,19 +292,17 @@ public abstract class RSWidgetMixin implements RSWidget int itemId = itemIds[index]; int itemQuantity = itemQuantities[index]; - Point widgetCanvasLocation = getCanvasLocation(); - - if (itemId <= 0 || itemQuantity <= 0 || columns <= 0) + if (columns <= 0) { return null; } int row = index / columns; int col = index % columns; - int itemX = widgetCanvasLocation.getX() + ((ITEM_SLOT_SIZE + xPitch) * col); - int itemY = widgetCanvasLocation.getY() + ((ITEM_SLOT_SIZE + yPitch) * row); + int itemX = rl$x + ((ITEM_SLOT_SIZE + xPitch) * col); + int itemY = rl$y + ((ITEM_SLOT_SIZE + yPitch) * row); - Rectangle bounds = new Rectangle(itemX - 1, itemY - 1, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE); + Rectangle bounds = new Rectangle(itemX, itemY, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE); return new WidgetItem(itemId - 1, itemQuantity, index, bounds, this); } diff --git a/runescape-client/src/main/java/Client.java b/runescape-client/src/main/java/Client.java index 1cd0f225ca..12fa080705 100644 --- a/runescape-client/src/main/java/Client.java +++ b/runescape-client/src/main/java/Client.java @@ -4710,7 +4710,7 @@ public final class Client extends GameShell implements Usernamed { int var8; if(!isMenuOpen) { if(__client_lq != -1) { - class39.method741(__client_lq, __client_ln); + class39.drawMenuActionTextAt(__client_lq, __client_ln); } } else { var1 = class25.menuX; diff --git a/runescape-client/src/main/java/class39.java b/runescape-client/src/main/java/class39.java index 3d56e1aaf4..9e05f0cb77 100644 --- a/runescape-client/src/main/java/class39.java +++ b/runescape-client/src/main/java/class39.java @@ -767,7 +767,8 @@ public class class39 extends class21 { signature = "(IIB)V", garbageValue = "3" ) - static final void method741(int var0, int var1) { + @Export("drawMenuActionTextAt") + static final void drawMenuActionTextAt(int var0, int var1) { if(Client.menuOptionsCount >= 2 || Client.isItemSelected != 0 || Client.isSpellSelected) { if(Client.showMouseOverText) { int var2 = Client.menuOptionsCount - 1; @@ -790,10 +791,10 @@ public class class39 extends class21 { } if(Client.menuOptionsCount > 2) { - var4 = var4 + BufferedFile.colorStartTag(16777215) + " " + '/' + " " + (Client.menuOptionsCount - 2) + " more options"; + var4 = var4 + BufferedFile.colorStartTag(0xffffff) + " " + '/' + " " + (Client.menuOptionsCount - 2) + " more options"; } - class2.fontBold12.drawRandomAlphaAndSpacing(var4, var0 + 4, var1 + 15, 16777215, 0, Client.cycle / 1000); + class2.fontBold12.drawRandomAlphaAndSpacing(var4, var0 + 4, var1 + 15, 0xffffff, 0, Client.cycle / 1000); } } } From fb63ba500ae2c9efecc9be21b8479573dd7432d9 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 9 Jun 2019 23:40:48 +0200 Subject: [PATCH 18/63] Add getters for before-ly-hooked fields --- .../src/main/java/net/runelite/injector/InjectHook.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java b/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java index 8f40597629..4be2f1cb5c 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java @@ -271,15 +271,14 @@ public class InjectHook if (hookInfo.getter instanceof Integer) { - ins.getInstructions().add(new LDC(ins, (int) hookInfo.getter)); - ins.getInstructions().add(new IMul(ins)); + ins.getInstructions().add(idx++, new LDC(ins, (int) hookInfo.getter)); + ins.getInstructions().add(idx++,new IMul(ins)); } else { - ins.getInstructions().add(new LDC(ins, (long) hookInfo.getter)); - ins.getInstructions().add(new LMul(ins)); + ins.getInstructions().add(idx++, new LDC(ins, (long) hookInfo.getter)); + ins.getInstructions().add(idx++, new LMul(ins)); } - } if (!value.type.equals(methodArgumentType)) { From d36c6ecd2156d396734116a130747e93f2d1b4b9 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 10 Jun 2019 00:02:45 +0200 Subject: [PATCH 19/63] make travis not try to run a test it wasn't supposed to --- .../src/test/java/net/runelite/runesuite/HookImporter.java | 4 +++- deobfuscator/src/test/resources/deob-test.properties | 2 +- .../src/main/java/net/runelite/client/rs/ClientLoader.java | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/deobfuscator/src/test/java/net/runelite/runesuite/HookImporter.java b/deobfuscator/src/test/java/net/runelite/runesuite/HookImporter.java index 137260e925..c4a7892a1f 100644 --- a/deobfuscator/src/test/java/net/runelite/runesuite/HookImporter.java +++ b/deobfuscator/src/test/java/net/runelite/runesuite/HookImporter.java @@ -52,6 +52,7 @@ import net.runelite.deob.util.JarUtil; import net.runelite.deob.util.NameMappings; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -87,12 +88,13 @@ public class HookImporter @After public void after() throws IOException { - File out = new File("C:/Users/Lucas/Desktop/client.jar"); + File out = folder.newFile("client.jar"); JarUtil.saveJar(group, out); logger.info("Wrote to {}", out); } @Test + @Ignore public void importHooks() { int classes = 0, fields = 0, methods = 0, access = 0; diff --git a/deobfuscator/src/test/resources/deob-test.properties b/deobfuscator/src/test/resources/deob-test.properties index 125bd16ceb..e26a22a2b9 100644 --- a/deobfuscator/src/test/resources/deob-test.properties +++ b/deobfuscator/src/test/resources/deob-test.properties @@ -1,3 +1,3 @@ -rs.client=C:/Users/Lucas/Desktop/gamepack180_deob.jar +rs.client=${net.runelite.rs:rs-client:jar} rs.version=180 vanilla.client=${net.runelite.rs:vanilla:jar} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java index 58e58d5874..027eaeda37 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java @@ -222,7 +222,7 @@ public class ClientLoader if (rs instanceof Client) { - log.info("client-patch {}", "420 blaze it RL pricks"); + log.info("client-patch 420 blaze it RL pricks"); } return rs; @@ -274,7 +274,7 @@ public class ClientLoader { FileOutputStream fileOutputStream = new FileOutputStream(INJECTED_CLIENT); fileOutputStream.getChannel() - .transferFrom(readableByteChannel, 0, Long.MAX_VALUE); + .transferFrom(readableByteChannel, 0, Integer.MAX_VALUE); } catch (IOException e) { From c316159ff4ae9535849b0eb5d99e2b89aebe2c01 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 10 Jun 2019 00:02:45 +0200 Subject: [PATCH 20/63] make travis not try to run a test it wasn't supposed to --- .../test/java/net/runelite/deob/updater/UpdateMappingsTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/deobfuscator/src/test/java/net/runelite/deob/updater/UpdateMappingsTest.java b/deobfuscator/src/test/java/net/runelite/deob/updater/UpdateMappingsTest.java index 1eaf240b68..332e2e31b0 100644 --- a/deobfuscator/src/test/java/net/runelite/deob/updater/UpdateMappingsTest.java +++ b/deobfuscator/src/test/java/net/runelite/deob/updater/UpdateMappingsTest.java @@ -70,6 +70,7 @@ public class UpdateMappingsTest } @Test + @Ignore public void testRun() throws IOException { File client = new File(properties.getRsClient()); From b151aeb914ea28ccd9d4243b9c9fbe5047164224 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 10 Jun 2019 01:12:16 +0200 Subject: [PATCH 21/63] Fix mod icons import --- runescape-api/src/main/java/net/runelite/rs/api/RSClient.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java index 8eb95392de..527c593963 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java @@ -529,11 +529,11 @@ public interface RSClient extends RSGameShell, Client @Import("mapDotSprites") RSSprite[] getMapDots(); - @Import("modIconSprites") + @Import("AbstractFont_modIconSprites") @Override RSIndexedSprite[] getModIcons(); - @Import("modIconSprites") + @Import("AbstractFont_modIconSprites") void setRSModIcons(RSIndexedSprite[] modIcons); @Construct From 3d76ebf3de9b4c29f8a079681b849010e993ad40 Mon Sep 17 00:00:00 2001 From: Tyler Bochard Date: Sun, 9 Jun 2019 21:55:16 -0400 Subject: [PATCH 22/63] Update .travis.yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76201d94c3..9ac5520c81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,9 @@ cache: directories: - $HOME/.m2 jdk: -- openjdk8 -- openjdk11 +- oraclejdk8 +- oraclejdk11 install: true script: ./travis/build.sh before_install: -- chmod +x ./travis/build.sh \ No newline at end of file +- chmod +x ./travis/build.sh From 0ff16c39b25b3dc88288b2ef5c2a9a97493c4f2c Mon Sep 17 00:00:00 2001 From: zeruth Date: Mon, 10 Jun 2019 00:54:29 -0400 Subject: [PATCH 23/63] Update .travis.yml --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9ac5520c81..fbfb7192af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,14 @@ dist: xenial cache: directories: - $HOME/.m2 +addons: + apt: + packages: + - oracle-java8-installer jdk: -- oraclejdk8 - oraclejdk11 install: true script: ./travis/build.sh before_install: - chmod +x ./travis/build.sh + From 0b970a6a2d866f011fa09118ae5958609e06bd0c Mon Sep 17 00:00:00 2001 From: zeruth Date: Mon, 10 Jun 2019 00:58:21 -0400 Subject: [PATCH 24/63] Update .travis.yml --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index fbfb7192af..d34dc4ca2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,11 @@ language: java sudo: false -dist: xenial +dist: trusty cache: directories: - $HOME/.m2 -addons: - apt: - packages: - - oracle-java8-installer jdk: +- oraclejdk8 - oraclejdk11 install: true script: ./travis/build.sh From 090c95b62616014198d0baeada66cad608c5a600 Mon Sep 17 00:00:00 2001 From: zeruth Date: Mon, 10 Jun 2019 01:51:19 -0400 Subject: [PATCH 25/63] Checkstyle fixes --- injector-plugin/pom.xml | 5 +- .../java/net/runelite/injector/Inject.java | 77 ++- .../runelite/injector/InjectConstruct.java | 26 +- .../net/runelite/injector/InjectGetter.java | 6 +- .../net/runelite/injector/InjectHook.java | 24 +- .../runelite/injector/InjectHookMethod.java | 36 +- .../net/runelite/injector/InjectInvoker.java | 12 +- .../net/runelite/injector/InjectMojo.java | 5 +- .../net/runelite/injector/InjectSetter.java | 14 +- .../java/net/runelite/injector/Injector.java | 22 +- .../net/runelite/injector/MixinInjector.java | 14 +- .../injector/raw/ClearColorBuffer.java | 2 +- .../injector/raw/DrawAfterWidgets.java | 2 +- .../injector/InjectConstructTest.java | 10 +- .../runelite/injector/InjectSetterTest.java | 14 +- .../runelite/injector/MixinInjectorTest.java | 15 +- .../client/util/bootstrap/Artifact.java | 13 +- .../client/util/bootstrap/Bootstrap.java | 621 +++++++++--------- .../client/util/bootstrap/Bootstrapper.java | 32 +- .../client/util/bootstrap/Client.java | 15 +- .../net/runelite/mixins/ClickboxMixin.java | 71 +- .../net/runelite/mixins/RSModelMixin.java | 306 ++++----- 22 files changed, 667 insertions(+), 675 deletions(-) diff --git a/injector-plugin/pom.xml b/injector-plugin/pom.xml index 4fcc212a47..38728b11e2 100644 --- a/injector-plugin/pom.xml +++ b/injector-plugin/pom.xml @@ -23,7 +23,8 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> - + 4.0.0 @@ -58,7 +59,7 @@ runescape-api ${project.version} - + org.apache.maven maven-plugin-api diff --git a/injector-plugin/src/main/java/net/runelite/injector/Inject.java b/injector-plugin/src/main/java/net/runelite/injector/Inject.java index 53f1c40cc4..dcc0236937 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/Inject.java +++ b/injector-plugin/src/main/java/net/runelite/injector/Inject.java @@ -51,19 +51,16 @@ import net.runelite.injector.raw.RasterizerHook; import net.runelite.injector.raw.RenderDraw; import net.runelite.injector.raw.ScriptVM; import net.runelite.mapping.Import; +import net.runelite.rs.api.RSClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.runelite.rs.api.RSClient; public class Inject { - private static final Logger logger = LoggerFactory.getLogger(Inject.class); - public static final java.lang.Class CLIENT_CLASS = RSClient.class; - public static final String API_PACKAGE_BASE = "net.runelite.rs.api.RS"; public static final String RL_API_PACKAGE_BASE = "net.runelite.api."; - + private static final Logger logger = LoggerFactory.getLogger(Inject.class); private final InjectHookMethod hookMethod = new InjectHookMethod(this); private final InjectGetter getters = new InjectGetter(this); @@ -87,34 +84,6 @@ public class Inject this.vanilla = vanilla; } - public Type getFieldType(Field f) - { - Type type = f.getType(); - - Annotation obfSignature = f.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE); - if (obfSignature != null) - { - //Annotation exists. Type was updated by us during deobfuscation - type = DeobAnnotations.getObfuscatedType(f); - } - - return type; - } - - public Signature getMethodSignature(Method m) - { - Signature signature = m.getDescriptor(); - - Annotation obfSignature = m.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE); - if (obfSignature != null) - { - //Annotation exists. Signature was updated by us during deobfuscation - signature = DeobAnnotations.getObfuscatedSignature(m); - } - - return signature; - } - /** * Convert a java.lang.Class to a Type * @@ -173,6 +142,34 @@ public class Inject return Type.getType("L" + c.getName().replace('.', '/') + ";", dimms); } + public Type getFieldType(Field f) + { + Type type = f.getType(); + + Annotation obfSignature = f.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE); + if (obfSignature != null) + { + //Annotation exists. Type was updated by us during deobfuscation + type = DeobAnnotations.getObfuscatedType(f); + } + + return type; + } + + public Signature getMethodSignature(Method m) + { + Signature signature = m.getDescriptor(); + + Annotation obfSignature = m.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE); + if (obfSignature != null) + { + //Annotation exists. Signature was updated by us during deobfuscation + signature = DeobAnnotations.getObfuscatedSignature(m); + } + + return signature; + } + /** * Build a Signature from a java method * @@ -284,7 +281,7 @@ public class Inject assert !f.isStatic(); // non static field exported on non exported interface - // logger.debug("Non static exported field {} on non exported interface", exportedName); + // logger.debug("Non static exported field {} on non exported interface", exportedName); continue; } @@ -325,7 +322,7 @@ public class Inject invokes.process(m, other, implementingClass); } } - + logger.info("Injected {} getters, {} setters, {} invokers", getters.getInjectedGetters(), setters.getInjectedSetters(), invokes.getInjectedInvokers()); @@ -514,10 +511,10 @@ public class Inject } } - // if (rlApiType == null) - // { - // throw new InjectionException("RS API type " + rsApiType + " does not extend RL API interface"); - // } + // if (rlApiType == null) + // { + // throw new InjectionException("RS API type " + rsApiType + " does not extend RL API interface"); + // } final java.lang.Class finalType = rlApiType == null ? rsApiType : rlApiType; @@ -539,7 +536,7 @@ public class Inject return Type.getType("L" + type.getInternalName().substring(API_PACKAGE_BASE.length()) + ";", type.getDimensions()); } - + ClassFile findVanillaForInterface(java.lang.Class clazz) { String className = clazz.getName().replace('.', '/'); diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectConstruct.java b/injector-plugin/src/main/java/net/runelite/injector/InjectConstruct.java index 295f636eaa..88e527d405 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectConstruct.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectConstruct.java @@ -115,19 +115,19 @@ public class InjectConstruct Signature sig = inject.javaMethodToSignature(apiMethod); Signature constructorSig = new Signature.Builder() - .addArguments(Stream.of(apiMethod.getParameterTypes()) - .map(arg -> - { - ClassFile vanilla = inject.findVanillaForInterface(arg); - if (vanilla != null) - { - return new Type("L" + vanilla.getName() + ";"); - } - return Inject.classToType(arg); - }) - .collect(Collectors.toList())) - .setReturnType(Type.VOID) - .build(); + .addArguments(Stream.of(apiMethod.getParameterTypes()) + .map(arg -> + { + ClassFile vanilla = inject.findVanillaForInterface(arg); + if (vanilla != null) + { + return new Type("L" + vanilla.getName() + ";"); + } + return Inject.classToType(arg); + }) + .collect(Collectors.toList())) + .setReturnType(Type.VOID) + .build(); Method vanillaConstructor = vanillaClass.findMethod("", constructorSig); if (vanillaConstructor == null) { diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectGetter.java b/injector-plugin/src/main/java/net/runelite/injector/InjectGetter.java index 3ac2752f6f..b9758b4f61 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectGetter.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectGetter.java @@ -47,16 +47,16 @@ import org.slf4j.LoggerFactory; public class InjectGetter { private static final Logger logger = LoggerFactory.getLogger(InjectGetter.class); - + private final Inject inject; - + private int injectedGetters; public InjectGetter(Inject inject) { this.inject = inject; } - + public void injectGetter(ClassFile clazz, java.lang.reflect.Method method, Field field, Number getter) { // clazz = class file we're injecting the method into. diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java b/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java index 4be2f1cb5c..a709d92072 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java @@ -58,23 +58,10 @@ import org.slf4j.LoggerFactory; public class InjectHook { private static final Logger logger = LoggerFactory.getLogger(InjectHook.class); - - static class HookInfo - { - String fieldName; - String clazz; - Method method; - boolean before; - Number getter; - } - private static final String HOOK_METHOD_SIGNATURE = "(I)V"; - private static final String CLINIT = ""; - private final Inject inject; private final Map hooked = new HashMap<>(); - private int injectedHooks; public InjectHook(Inject inject) @@ -272,7 +259,7 @@ public class InjectHook if (hookInfo.getter instanceof Integer) { ins.getInstructions().add(idx++, new LDC(ins, (int) hookInfo.getter)); - ins.getInstructions().add(idx++,new IMul(ins)); + ins.getInstructions().add(idx++, new IMul(ins)); } else { @@ -399,4 +386,13 @@ public class InjectHook { return injectedHooks; } + + static class HookInfo + { + String fieldName; + String clazz; + Method method; + boolean before; + Number getter; + } } diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectHookMethod.java b/injector-plugin/src/main/java/net/runelite/injector/InjectHookMethod.java index 6c74fbc5fa..9cd7d4326d 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectHookMethod.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectHookMethod.java @@ -49,10 +49,8 @@ import org.slf4j.LoggerFactory; public class InjectHookMethod { - private static final Logger logger = LoggerFactory.getLogger(InjectHookMethod.class); - public static final String HOOKS = "net/runelite/client/callback/Hooks"; - + private static final Logger logger = LoggerFactory.getLogger(InjectHookMethod.class); private final Inject inject; public InjectHookMethod(Inject inject) @@ -115,7 +113,7 @@ public class InjectHookMethod Instructions instructions = vanillaMethod.getCode().getInstructions(); Signature.Builder builder = new Signature.Builder() - .setReturnType(Type.VOID); // Hooks always return void + .setReturnType(Type.VOID); // Hooks always return void for (Type type : deobMethod.getDescriptor().getArguments()) { @@ -164,11 +162,11 @@ public class InjectHookMethod { // Invoke callback invoke = new InvokeStatic(instructions, - new net.runelite.asm.pool.Method( - new net.runelite.asm.pool.Class(HOOKS), - hookName, - signature - ) + new net.runelite.asm.pool.Method( + new net.runelite.asm.pool.Class(HOOKS), + hookName, + signature + ) ); } else @@ -179,11 +177,11 @@ public class InjectHookMethod if (vanillaMethod.isStatic()) { invoke = new InvokeStatic(instructions, - new net.runelite.asm.pool.Method( - new net.runelite.asm.pool.Class("client"), // Static methods are in client - hookMethod.getName(), - signature - ) + new net.runelite.asm.pool.Method( + new net.runelite.asm.pool.Class("client"), // Static methods are in client + hookMethod.getName(), + signature + ) ); } else @@ -191,11 +189,11 @@ public class InjectHookMethod // otherwise invoke member function //instructions.addInstruction(insertPos++, new ALoad(instructions, 0)); invoke = new InvokeVirtual(instructions, - new net.runelite.asm.pool.Method( - new net.runelite.asm.pool.Class(vanillaMethod.getClassFile().getName()), - hookMethod.getName(), - signature - ) + new net.runelite.asm.pool.Method( + new net.runelite.asm.pool.Class(vanillaMethod.getClassFile().getName()), + hookMethod.getName(), + signature + ) ); } } diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectInvoker.java b/injector-plugin/src/main/java/net/runelite/injector/InjectInvoker.java index 1b59e63b4c..6b3fa13d33 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectInvoker.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectInvoker.java @@ -67,11 +67,11 @@ public class InjectInvoker /** * Inject an invoker for a method * - * @param m Method in the deobfuscated client to inject an invoker for - * @param other Class in the vanilla client of the same class m is a - * member of + * @param m Method in the deobfuscated client to inject an invoker for + * @param other Class in the vanilla client of the same class m is a + * member of * @param implementingClass Java class for the API interface the class - * will implement + * will implement */ public void process(Method m, ClassFile other, java.lang.Class implementingClass) { @@ -108,14 +108,14 @@ public class InjectInvoker assert !m.isStatic(); // non static exported method on non exported interface, weird. - // logger.debug("Non static exported method {} on non exported interface", exportedName); + // logger.debug("Non static exported method {} on non exported interface", exportedName); return; } java.lang.reflect.Method apiMethod = inject.findImportMethodOnApi(targetClassJava, exportedName, null); // api method to invoke 'otherm' if (apiMethod == null) { - // logger.debug("Unable to find api method on {} with imported name {}, not injecting invoker", targetClassJava, exportedName); + // logger.debug("Unable to find api method on {} with imported name {}, not injecting invoker", targetClassJava, exportedName); return; } diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectMojo.java b/injector-plugin/src/main/java/net/runelite/injector/InjectMojo.java index 08ac162588..b7c22194fe 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectMojo.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectMojo.java @@ -45,17 +45,14 @@ import org.apache.maven.plugins.annotations.Parameter; ) public class InjectMojo extends AbstractMojo { + private final Log log = getLog(); @Parameter(defaultValue = "${project.build.outputDirectory}") private File outputDirectory; - @Parameter(defaultValue = "./runescape-client/target/rs-client-${project.version}.jar", readonly = true, required = true) private String rsClientPath; - @Parameter(defaultValue = "${net.runelite.rs:vanilla:jar}", readonly = true, required = true) private String vanillaPath; - private final Log log = getLog(); - @Override public void execute() throws MojoExecutionException, MojoFailureException { diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectSetter.java b/injector-plugin/src/main/java/net/runelite/injector/InjectSetter.java index bcb8b1815d..6b10ab3b56 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectSetter.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectSetter.java @@ -50,7 +50,7 @@ public class InjectSetter private static final Logger logger = LoggerFactory.getLogger(InjectSetter.class); private final Inject inject; - + private int injectedSetters; public InjectSetter(Inject inject) @@ -61,12 +61,12 @@ public class InjectSetter /** * inject a setter into the vanilla classgroup * - * @param targetClass Class where to inject the setter (field's class, - * or client) + * @param targetClass Class where to inject the setter (field's class, + * or client) * @param targetApiClass API targetClass implements, which may have the - * setter declared - * @param field Field of vanilla that will be set - * @param exportedName exported name of field + * setter declared + * @param field Field of vanilla that will be set + * @param exportedName exported name of field * @param setter */ public void injectSetter(ClassFile targetClass, Class targetApiClass, Field field, String exportedName, Number setter) @@ -114,7 +114,7 @@ public class InjectSetter // load argument Type argumentType = sig.getTypeOfArg(0); ins.add(inject.createLoadForTypeIndex(instructions, argumentType, 1)); - + // cast argument to field type Type fieldType = field.getType(); if (!argumentType.equals(fieldType)) diff --git a/injector-plugin/src/main/java/net/runelite/injector/Injector.java b/injector-plugin/src/main/java/net/runelite/injector/Injector.java index 60577cfbd4..d8b61f901b 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/Injector.java +++ b/injector-plugin/src/main/java/net/runelite/injector/Injector.java @@ -39,17 +39,6 @@ public class Injector this.vanilla = vanilla; } - public void inject() throws InjectionException - { - Inject instance = new Inject(deobfuscated, vanilla); - instance.run(); - } - - public void save(File out) throws IOException - { - JarUtil.saveJar(vanilla, out); - } - public static void main(String[] args) throws IOException, InjectionException { if (args.length < 3) @@ -72,5 +61,16 @@ public class Injector u.save(new File(args[2])); } + public void inject() throws InjectionException + { + Inject instance = new Inject(deobfuscated, vanilla); + instance.run(); + } + + public void save(File out) throws IOException + { + JarUtil.saveJar(vanilla, out); + } + } diff --git a/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java b/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java index 032524878a..1547880140 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java +++ b/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java @@ -404,7 +404,7 @@ public class MixinInjector care of the garbage parameter itself. */ boolean hasGarbageValue = method.getDescriptor().size() != obMethod.getDescriptor().size() - && deobMethod.getDescriptor().size() < obMethodSignature.size(); + && deobMethod.getDescriptor().size() < obMethodSignature.size(); copiedMethods.put(method.getPoolMethod(), new CopiedMethod(copy, hasGarbageValue)); logger.debug("Injected copy of {} to {}", obMethod, copy); @@ -577,7 +577,7 @@ public class MixinInjector if (!returnType.equals(deobReturnType)) { ClassFile deobReturnTypeClassFile = inject.getDeobfuscated() - .findClass(deobReturnType.getInternalName()); + .findClass(deobReturnType.getInternalName()); if (deobReturnTypeClassFile != null) { ClassFile obReturnTypeClass = inject.toObClass(deobReturnTypeClassFile); @@ -601,13 +601,13 @@ public class MixinInjector moveCode(obMethod, method.getCode()); boolean hasGarbageValue = method.getDescriptor().size() != obMethod.getDescriptor().size() - && deobMethod.getDescriptor().size() < obMethodSignature.size(); + && deobMethod.getDescriptor().size() < obMethodSignature.size(); if (hasGarbageValue) { int garbageIndex = obMethod.isStatic() - ? obMethod.getDescriptor().size() - 1 - : obMethod.getDescriptor().size(); + ? obMethod.getDescriptor().size() - 1 + : obMethod.getDescriptor().size(); /* If the mixin method doesn't have the garbage parameter, @@ -645,8 +645,8 @@ public class MixinInjector } private void setOwnersToTargetClass(ClassFile mixinCf, ClassFile cf, Method method, - Map shadowFields, - Map copiedMethods) + Map shadowFields, + Map copiedMethods) throws InjectionException { ListIterator iterator = method.getCode().getInstructions().getInstructions().listIterator(); diff --git a/injector-plugin/src/main/java/net/runelite/injector/raw/ClearColorBuffer.java b/injector-plugin/src/main/java/net/runelite/injector/raw/ClearColorBuffer.java index e1da299dd1..ffacb7f1a8 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/raw/ClearColorBuffer.java +++ b/injector-plugin/src/main/java/net/runelite/injector/raw/ClearColorBuffer.java @@ -79,7 +79,7 @@ public class ClearColorBuffer if (current instanceof LDC && ((LDC) current).getConstantAsInt() == 0) { int varIdx = 0; - for (; ;) + for (; ; ) { current = it.previous(); if (current instanceof ILoad && ((ILoad) current).getVariableIndex() == 3 - varIdx) diff --git a/injector-plugin/src/main/java/net/runelite/injector/raw/DrawAfterWidgets.java b/injector-plugin/src/main/java/net/runelite/injector/raw/DrawAfterWidgets.java index db239448bf..ae2a3d5478 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/raw/DrawAfterWidgets.java +++ b/injector-plugin/src/main/java/net/runelite/injector/raw/DrawAfterWidgets.java @@ -166,7 +166,7 @@ public class DrawAfterWidgets { // If we get here, we're either in the wrong method // or Jagex has removed the "if (535573958 * kl != -1)" - // logger.debug("Could not find the label for jumping to the " + noClip + " call in " + m); + // logger.debug("Could not find the label for jumping to the " + noClip + " call in " + m); continue; } diff --git a/injector-plugin/src/test/java/net/runelite/injector/InjectConstructTest.java b/injector-plugin/src/test/java/net/runelite/injector/InjectConstructTest.java index 5b0663e48c..dbde5e10bd 100644 --- a/injector-plugin/src/test/java/net/runelite/injector/InjectConstructTest.java +++ b/injector-plugin/src/test/java/net/runelite/injector/InjectConstructTest.java @@ -35,11 +35,6 @@ import static org.mockito.Mockito.when; public class InjectConstructTest { - interface APIClass - { - APIClass create(); - } - @Test public void testInjectConstruct() throws Exception { @@ -60,4 +55,9 @@ public class InjectConstructTest assertNotNull(targetClass.findMethod("create")); } + interface APIClass + { + APIClass create(); + } + } diff --git a/injector-plugin/src/test/java/net/runelite/injector/InjectSetterTest.java b/injector-plugin/src/test/java/net/runelite/injector/InjectSetterTest.java index 1b1c538463..48ff708bc5 100644 --- a/injector-plugin/src/test/java/net/runelite/injector/InjectSetterTest.java +++ b/injector-plugin/src/test/java/net/runelite/injector/InjectSetterTest.java @@ -44,13 +44,6 @@ import static org.mockito.Mockito.when; public class InjectSetterTest { - interface APIClass - { - void setTest(int i); - - void setTestObject(Object str); - } - @Test public void testInjectSetterInt() throws NoSuchMethodException { @@ -113,4 +106,11 @@ public class InjectSetterTest .isPresent()); } + interface APIClass + { + void setTest(int i); + + void setTestObject(Object str); + } + } diff --git a/injector-plugin/src/test/java/net/runelite/injector/MixinInjectorTest.java b/injector-plugin/src/test/java/net/runelite/injector/MixinInjectorTest.java index 02e2dbf0c0..9a96626f27 100644 --- a/injector-plugin/src/test/java/net/runelite/injector/MixinInjectorTest.java +++ b/injector-plugin/src/test/java/net/runelite/injector/MixinInjectorTest.java @@ -53,6 +53,9 @@ import static org.objectweb.asm.Opcodes.ACC_STATIC; @ObfuscatedName("net/runelite/injector/VanillaTarget") class DeobTarget { + @ObfuscatedName("ob_foo4") + private static int foo4; + @ObfuscatedName("ob_foo3") @ObfuscatedSignature( signature = "(I)V", @@ -63,13 +66,12 @@ class DeobTarget // De-obfuscated foo3 System.out.println("foo3"); } - - @ObfuscatedName("ob_foo4") - private static int foo4; } class VanillaTarget { + private static int ob_foo4; + private void ob_foo3(int garbageValue) { // Obfuscated foo3 @@ -79,14 +81,14 @@ class VanillaTarget } System.out.println("foo3"); } - - private static int ob_foo4; } abstract class Source { @net.runelite.api.mixins.Inject private static int foo; + @Shadow("foo4") + private static int foo4; @net.runelite.api.mixins.Inject private void foo2() @@ -103,9 +105,6 @@ abstract class Source System.out.println(foo4); foo3(); } - - @Shadow("foo4") - private static int foo4; } // Test shadowing the "foo" field injected by Source diff --git a/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Artifact.java b/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Artifact.java index 9b9e2b276e..466dfbcf11 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Artifact.java +++ b/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Artifact.java @@ -1,10 +1,9 @@ package net.runelite.client.util.bootstrap; -public class Artifact { - - String hash; - String name; - String path; - String size; - +public class Artifact +{ + String hash; + String name; + String path; + String size; } diff --git a/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Bootstrap.java b/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Bootstrap.java index e9d51c58d6..b6e3acde55 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Bootstrap.java +++ b/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Bootstrap.java @@ -1,328 +1,345 @@ package net.runelite.client.util.bootstrap; -import net.runelite.http.api.RuneLiteAPI; -import sun.misc.BASE64Encoder; - -import javax.xml.bind.DatatypeConverter; -import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; -import java.io.UnsupportedEncodingException; import java.security.DigestInputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import javax.xml.bind.DatatypeConverter; +import net.runelite.http.api.RuneLiteAPI; -public class Bootstrap { +public class Bootstrap +{ + Artifact[] artifacts = getArtifacts(); + Client client = new Client(); + String[] clientJvm9Arguments = new String[]{ + "-XX:+DisableAttachMechanism", + "-Xmx512m", + "-Xss2m", + "-XX:CompileThreshold=1500", + "-Djna.nosys=true" + }; + String[] clientJvmArguments = new String[]{ + "-XX:+DisableAttachMechanism", + "-Xmx512m", + "-Xss2m", + "-XX:CompileThreshold=1500", + "-Xincgc", + "-XX:+UseConcMarkSweepGC", + "-XX:+UseParNewGC", + "-Djna.nosys=true"}; + String[] dependencyHashes; + String[] launcherArguments = new String[]{ + "-XX:+DisableAttachMechanism", + "-Drunelite.launcher.nojvm=true", + "-Xmx512m", + "-Xss2m", + "-XX:CompileThreshold=1500", + "-Xincgc", + "-XX:+UseConcMarkSweepGC", + "-XX:+UseParNewGC", + "-Djna.nosys=true"}; - Artifact[] artifacts = getArtifacts(); - Client client = new Client(); - String[] clientJvm9Arguments = new String[]{ - "-XX:+DisableAttachMechanism", - "-Xmx512m", - "-Xss2m", - "-XX:CompileThreshold=1500", - "-Djna.nosys=true" - }; - String[] clientJvmArguments = new String[]{ - "-XX:+DisableAttachMechanism", - "-Xmx512m", - "-Xss2m", - "-XX:CompileThreshold=1500", - "-Xincgc", - "-XX:+UseConcMarkSweepGC", - "-XX:+UseParNewGC", - "-Djna.nosys=true"}; - String[] dependencyHashes; - String[] launcherArguments = new String[]{ - "-XX:+DisableAttachMechanism", - "-Drunelite.launcher.nojvm=true", - "-Xmx512m", - "-Xss2m", - "-XX:CompileThreshold=1500", - "-Xincgc", - "-XX:+UseConcMarkSweepGC", - "-XX:+UseParNewGC", - "-Djna.nosys=true"}; + public Bootstrap() + { + } - public Bootstrap(){} + public static String getChecksumObject(Serializable object) throws IOException, NoSuchAlgorithmException + { + ByteArrayOutputStream baos = null; + ObjectOutputStream oos = null; + try + { + baos = new ByteArrayOutputStream(); + oos = new ObjectOutputStream(baos); + oos.writeObject(object); + MessageDigest md = MessageDigest.getInstance("MD5"); + byte[] thedigest = md.digest(baos.toByteArray()); + return DatatypeConverter.printHexBinary(thedigest); + } + finally + { + oos.close(); + baos.close(); + } + } - public Artifact[] getArtifacts() { - try { - artifacts = new Artifact[42]; + private static String getChecksumFile(String filepath) throws IOException + { + System.out.println("Generating Hash for " + filepath); + MessageDigest md = null; + try + { + md = MessageDigest.getInstance("SHA-256"); + } + catch (Exception e) + { + e.printStackTrace(); + } + try (DigestInputStream dis = new DigestInputStream(new FileInputStream(filepath), md)) + { + while (dis.read() != -1) + { + //empty loop to clear the data + } + md = dis.getMessageDigest(); + } + catch (Exception e) + { + e.printStackTrace(); + } - //Static artifacts - artifacts[0] = new Artifact(); - artifacts[0].hash = "b12331da8683e5f107d294adeebb83ecf9124abc1db533554d2a8d3c62832d75"; - artifacts[0].name = "asm-all-6.0_BETA.jar"; - artifacts[0].path = "https://mvn.runelite.net/org/ow2/asm/asm-all/6.0_BETA/asm-all-6.0_BETA.jar"; - artifacts[0].size = "265176"; - artifacts[1] = new Artifact(); - artifacts[1].hash = "37abf0103ce5318bfda004fabc004c75ed0dc6d392a8459175692ab7eac97083"; - artifacts[1].name = "naturalmouse-2.0.0.jar"; - artifacts[1].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/naturalmouse-2.0.0.jar"; - artifacts[1].size = "3168921"; - artifacts[2] = new Artifact(); - artifacts[2].hash = "50d1e07f11827672249dee9ce8a23691fc59f663deed084bb7b52a4f778d5fbc"; - artifacts[2].name = "jcl-core-2.9-SNAPSHOT.jar"; - artifacts[2].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/jcl-core-2.9-SNAPSHOT.jar"; - artifacts[2].size = "3168921"; - artifacts[4] = new Artifact(); - artifacts[4].hash = "18c4a0095d5c1da6b817592e767bb23d29dd2f560ad74df75ff3961dbde25b79"; - artifacts[4].name = "slf4j-api-1.7.25.jar"; - artifacts[4].path = "https://mvn.runelite.net/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar"; - artifacts[4].size = "41203"; - artifacts[5] = new Artifact(); - artifacts[5].hash = "fb53f8539e7fcb8f093a56e138112056ec1dc809ebb020b59d8a36a5ebac37e0"; - artifacts[5].name = "logback-classic-1.2.3.jar"; - artifacts[5].path = "https://mvn.runelite.net/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar"; - artifacts[5].size = "290339"; - artifacts[6] = new Artifact(); - artifacts[6].hash = "5946d837fe6f960c02a53eda7a6926ecc3c758bbdd69aa453ee429f858217f22"; - artifacts[6].name = "logback-core-1.2.3.jar"; - artifacts[6].path = "https://mvn.runelite.net/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar"; - artifacts[6].size = "471901"; - artifacts[7] = new Artifact(); - artifacts[7].hash = "9f0c8d50fa4b79b6ff1502dbec8502179d6b9497cacbe17a13074001aed537ec"; - artifacts[7].name = "jopt-simple-5.0.1.jar"; - artifacts[7].path = "https://mvn.runelite.net/net/sf/jopt-simple/jopt-simple/5.0.1/jopt-simple-5.0.1.jar"; - artifacts[7].size = "78826"; - artifacts[8] = new Artifact(); - artifacts[8].hash = "5be9a7d05ba0ccd74708bc8018ae412255f85843c0b92302e9b9befa6ed52564"; - artifacts[8].name = "guava-23.2-jre.jar"; - artifacts[8].path = "https://mvn.runelite.net/com/google/guava/guava/23.2-jre/guava-23.2-jre.jar"; - artifacts[8].size = "2649860"; - artifacts[9] = new Artifact(); - artifacts[9].hash = "905721a0eea90a81534abb7ee6ef4ea2e5e645fa1def0a5cd88402df1b46c9ed"; - artifacts[9].name = "jsr305-1.3.9.jar"; - artifacts[9].path = "https://mvn.runelite.net/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar"; - artifacts[9].size = "33015"; - artifacts[10] = new Artifact(); - artifacts[10].hash = "cb4cfad870bf563a07199f3ebea5763f0dec440fcda0b318640b1feaa788656b"; - artifacts[10].name = "error_prone_annotations-2.0.18.jar"; - artifacts[10].path = "https://mvn.runelite.net/com/google/errorprone/error_prone_annotations/2.0.18/error_prone_annotations-2.0.18.jar"; - artifacts[10].size = "12078"; - artifacts[11] = new Artifact(); - artifacts[11].hash = "2994a7eb78f2710bd3d3bfb639b2c94e219cedac0d4d084d516e78c16dddecf6"; - artifacts[11].name = "j2objc-annotations-1.1.jar"; - artifacts[11].path = "https://mvn.runelite.net/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar"; - artifacts[11].size = "8782"; - artifacts[12] = new Artifact(); - artifacts[12].hash = "2068320bd6bad744c3673ab048f67e30bef8f518996fa380033556600669905d"; - artifacts[12].name = "animal-sniffer-annotations-1.14.jar"; - artifacts[12].path = "https://mvn.runelite.net/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar"; - artifacts[12].size = "3482"; - artifacts[13] = new Artifact(); - artifacts[13].hash = "9264c6931c431e928dc64adc842584d5f57d17b2f3aff29221f2b3fdea673dad"; - artifacts[13].name = "guice-4.1.0-no_aop.jar"; - artifacts[13].path = "https://mvn.runelite.net/com/google/inject/guice/4.1.0/guice-4.1.0-no_aop.jar"; - artifacts[13].size = "428603"; - artifacts[14] = new Artifact(); - artifacts[14].hash = "91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff"; - artifacts[14].name = "javax.inject-1.jar"; - artifacts[14].path = "https://mvn.runelite.net/javax/inject/javax.inject/1/javax.inject-1.jar"; - artifacts[14].size = "2497"; - artifacts[15] = new Artifact(); - artifacts[15].hash = "0addec670fedcd3f113c5c8091d783280d23f75e3acb841b61a9cdb079376a08"; - artifacts[15].name = "aopalliance-1.0.jar"; - artifacts[15].path = "https://mvn.runelite.net/aopalliance/aopalliance/1.0/aopalliance-1.0.jar"; - artifacts[15].size = "4467"; - artifacts[16] = new Artifact(); - artifacts[16].hash = "233a0149fc365c9f6edbd683cfe266b19bdc773be98eabdaf6b3c924b48e7d81"; - artifacts[16].name = "gson-2.8.5.jar"; - artifacts[16].path = "https://mvn.runelite.net/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar"; - artifacts[16].size = "241622"; - artifacts[17] = new Artifact(); - artifacts[17].hash = "0467d25f408428824d5c9c09ec60ee1f0bc341d9bf48971a77fd14939a826c83"; - artifacts[17].name = "substance-8.0.02.jar"; - artifacts[17].path = "https://repo.runelite.net/net/runelite/pushingpixels/substance/8.0.02/substance-8.0.02.jar"; - artifacts[17].size = "1589195"; - artifacts[18] = new Artifact(); - artifacts[18].hash = "3214e1c23d549d5d67c91da4da1ef33c5248470bb824f91cbe8f9e0beea59eef"; - artifacts[18].name = "trident-1.5.00.jar"; - artifacts[18].path = "https://repo.runelite.net/net/runelite/pushingpixels/trident/1.5.00/trident-1.5.00.jar"; - artifacts[18].size = "79726"; - artifacts[19] = new Artifact(); - artifacts[19].hash = "d4a57bbc1627da7c391308fd0fe910b83170fb66afd117236a5b111d2db1590b"; - artifacts[19].name = "commons-text-1.2.jar"; - artifacts[19].path = "https://mvn.runelite.net/org/apache/commons/commons-text/1.2/commons-text-1.2.jar"; - artifacts[19].size = "136544"; - artifacts[20] = new Artifact(); - artifacts[20].hash = "6e8dc31e046508d9953c96534edf0c2e0bfe6f468966b5b842b3f87e43b6a847"; - artifacts[20].name = "commons-lang3-3.7.jar"; - artifacts[20].path = "https://mvn.runelite.net/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7.jar"; - artifacts[20].size = "499634"; - artifacts[21] = new Artifact(); - artifacts[21].hash = "e74603dc77b4183f108480279dbbf7fed3ac206069478636406c1fb45e83b31a"; - artifacts[21].name = "jogl-all-2.3.2.jar"; - artifacts[21].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2.jar"; - artifacts[21].size = "3414448"; - artifacts[22] = new Artifact(); - artifacts[22].hash = "8c53b1884cef19309d34fd10a94b010136d9d6de9a88c386f46006fb47acab5d"; - artifacts[22].name = "jogl-all-2.3.2-natives-windows-amd64.jar"; - artifacts[22].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-windows-amd64.jar"; - artifacts[22].size = "240721"; - artifacts[23] = new Artifact(); - artifacts[23].hash = "507a0e6bd1ee4e81c3dfb287783af93775864eec742988d4162f98ce0cbac9d6"; - artifacts[23].name = "jogl-all-2.3.2-natives-windows-i586.jar"; - artifacts[23].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-windows-i586.jar"; - artifacts[23].size = "209445"; - artifacts[24] = new Artifact(); - artifacts[24].hash = "82637302ae9effdf7d6f302e1050ad6aee3b13019914ddda5b502b9faa980216"; - artifacts[24].name = "jogl-all-2.3.2-natives-linux-amd64.jar"; - artifacts[24].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-linux-amd64.jar"; - artifacts[24].size = "224010"; - artifacts[25] = new Artifact(); - artifacts[25].hash = "f474ef2ef01be24ec811d3858b0f4bc5659076975f4a58ddd79abd787e9305c7"; - artifacts[25].name = "jogl-all-2.3.2-natives-linux-i586.jar"; - artifacts[25].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-linux-i586.jar"; - artifacts[25].size = "217274"; - artifacts[26] = new Artifact(); - artifacts[26].hash = "084844543b18f7ff71b4c0437852bd22f0cb68d7e44c2c611c1bbea76f8c6fdf"; - artifacts[26].name = "gluegen-rt-2.3.2.jar"; - artifacts[26].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2.jar"; - artifacts[26].size = "345605"; - artifacts[27] = new Artifact(); - artifacts[27].hash = "3474017422eff384db466bdb56c96c61220c43133a9da6329cf1781bea16c6b6"; - artifacts[27].name = "gluegen-rt-2.3.2-natives-windows-amd64.jar"; - artifacts[27].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-windows-amd64.jar"; - artifacts[27].size = "8159"; - artifacts[28] = new Artifact(); - artifacts[28].hash = "4eeed9fc2ebea5b9dc48a342b9478d127e989a2e1aa7129b512a98ec75cde338"; - artifacts[28].name = "gluegen-rt-2.3.2-natives-windows-i586.jar"; - artifacts[28].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-windows-i586.jar"; - artifacts[28].size = "7577"; - artifacts[29] = new Artifact(); - artifacts[29].hash = "f2dfd1800202059cf7e0294db5d57755147304e6eb220a9277526dbe6842bde2"; - artifacts[29].name = "gluegen-rt-2.3.2-natives-linux-amd64.jar"; - artifacts[29].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-linux-amd64.jar"; - artifacts[29].size = "4149"; - artifacts[30] = new Artifact(); - artifacts[30].hash = "1365d463f98c0abec92f3ad6b35aa4b53a9599a517800cf99fdabea6712ca7ec"; - artifacts[30].name = "gluegen-rt-2.3.2-natives-linux-i586.jar"; - artifacts[30].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-linux-i586.jar"; - artifacts[30].size = "4130"; - artifacts[31] = new Artifact(); - artifacts[31].hash = "7b7ae00e2aa98c3b2b5ac76e793e2c9b752bf51c86c54654dbd473843a25f1aa"; - artifacts[31].name = "jbsdiff-1.0.jar"; - artifacts[31].path = "https://mvn.runelite.net/io/sigpipe/jbsdiff/1.0/jbsdiff-1.0.jar"; - artifacts[31].size = "24589"; - artifacts[32] = new Artifact(); - artifacts[32].hash = "55bbfe26cee9296fd5b7c0d47ce6a00ea4dd572e235b63e9bb4eaf6f802315e4"; - artifacts[32].name = "commons-compress-1.5.jar"; - artifacts[32].path = "https://mvn.runelite.net/org/apache/commons/commons-compress/1.5/commons-compress-1.5.jar"; - artifacts[32].size = "256241"; - artifacts[33] = new Artifact(); - artifacts[33].hash = "fbc9de96a0cc193a125b4008dbc348e9ed54e5e13fc67b8ed40e645d303cc51b"; - artifacts[33].name = "jna-4.5.1.jar"; - artifacts[33].path = "https://mvn.runelite.net/net/java/dev/jna/jna/4.5.1/jna-4.5.1.jar"; - artifacts[33].size = "1440662"; - artifacts[34] = new Artifact(); - artifacts[34].hash = "84c8667555ee8dd91fef44b451419f6f16f71f727d5fc475a10c2663eba83abb"; - artifacts[34].name = "jna-platform-4.5.1.jar"; - artifacts[34].path = "https://mvn.runelite.net/net/java/dev/jna/jna-platform/4.5.1/jna-platform-4.5.1.jar"; - artifacts[34].size = "2327547"; - artifacts[38] = new Artifact(); - artifacts[38].hash = "f55abda036da75e1af45bd43b9dfa79b2a3d90905be9cb38687c6621597a8165"; - artifacts[38].name = "okhttp-3.7.0.jar"; - artifacts[38].path = "https://mvn.runelite.net/com/squareup/okhttp3/okhttp/3.7.0/okhttp-3.7.0.jar"; - artifacts[38].size = "394987"; - artifacts[39] = new Artifact(); - artifacts[39].hash = "bfe7dfe483c37137966a1690f0c7d0b448ba217902c1fed202aaffdbba3291ae"; - artifacts[39].name = "okio-1.12.0.jar"; - artifacts[39].path = "https://mvn.runelite.net/com/squareup/okio/okio/1.12.0/okio-1.12.0.jar"; - artifacts[39].size = "81088"; - artifacts[40] = new Artifact(); - artifacts[40].hash = "9d4924588d6280c7516db3a4b7298306db5b6f0d1cdf568ce738309b5660f008"; - artifacts[40].name = "commons-csv-1.4.jar"; - artifacts[40].path = "https://mvn.runelite.net/org/apache/commons/commons-csv/1.4/commons-csv-1.4.jar"; - artifacts[40].size = "39978"; - artifacts[41] = new Artifact(); - artifacts[41].hash = "7e26a8d043418f2f22d5f6a3083a9a131817009ee8cd72c004e83b50d1849a7c"; - artifacts[41].name = "discord-1.1.jar"; - artifacts[41].path = "https://repo.runelite.net/net/runelite/discord/1.1/discord-1.1.jar"; - artifacts[41].size = "617294"; + return bytesToHex(md.digest()); - //Dynamic artifacts - artifacts[3] = new Artifact(); - artifacts[3].name = "client-"+ RuneLiteAPI.getVersion()+".jar"; - artifacts[3].hash = getChecksumFile("./runelite-client/target/"+artifacts[3].name); - artifacts[3].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/"+artifacts[3].name; - artifacts[3].size = Long.toString(getFileSize("./runelite-client/target/"+artifacts[3].name)); - artifacts[35] = new Artifact(); - artifacts[35].name = "runelite-api-"+ RuneLiteAPI.getVersion()+".jar"; - artifacts[35].hash = getChecksumFile("./runelite-api/target/"+artifacts[35].name); - artifacts[35].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/"+artifacts[35].name; - artifacts[35].size = Long.toString(getFileSize("./runelite-api/target/"+artifacts[35].name)); - artifacts[36] = new Artifact(); - artifacts[36].name = "runescape-api-"+ RuneLiteAPI.getVersion()+".jar"; - artifacts[36].hash = getChecksumFile("./runescape-api/target/"+artifacts[36].name); - artifacts[36].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/"+artifacts[36].name; - artifacts[36].size = Long.toString(getFileSize("./runescape-api/target/"+artifacts[36].name)); - artifacts[37] = new Artifact(); - artifacts[37].name = "http-api-"+ RuneLiteAPI.getVersion()+".jar"; - artifacts[37].hash = getChecksumFile("./http-api/target/"+artifacts[37].name); - artifacts[37].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/"+artifacts[37].name; - artifacts[37].size = Long.toString(getFileSize("./http-api/target/"+artifacts[37].name)); - } catch (IOException e) { - e.printStackTrace(); - } - return artifacts; - } + } + private static String bytesToHex(byte[] hashInBytes) + { + StringBuilder sb = new StringBuilder(); + for (byte b : hashInBytes) + { + sb.append(String.format("%02x", b)); + } + return sb.toString(); - public static String getChecksumObject(Serializable object) throws IOException, NoSuchAlgorithmException { - ByteArrayOutputStream baos = null; - ObjectOutputStream oos = null; - try { - baos = new ByteArrayOutputStream(); - oos = new ObjectOutputStream(baos); - oos.writeObject(object); - MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] thedigest = md.digest(baos.toByteArray()); - return DatatypeConverter.printHexBinary(thedigest); - } finally { - oos.close(); - baos.close(); - } - } - private static String getChecksumFile(String filepath) throws IOException { - System.out.println("Generating Hash for "+filepath); - MessageDigest md = null; - try { - md = MessageDigest.getInstance("SHA-256"); - } catch (Exception e) { - e.printStackTrace(); - } - try (DigestInputStream dis = new DigestInputStream(new FileInputStream(filepath), md)) { - while (dis.read() != -1) ; //empty loop to clear the data - md = dis.getMessageDigest(); - } catch (Exception e) { - e.printStackTrace(); - } + } - return bytesToHex(md.digest()); + public Artifact[] getArtifacts() + { + try + { + artifacts = new Artifact[42]; - } + //Static artifacts + artifacts[0] = new Artifact(); + artifacts[0].hash = "b12331da8683e5f107d294adeebb83ecf9124abc1db533554d2a8d3c62832d75"; + artifacts[0].name = "asm-all-6.0_BETA.jar"; + artifacts[0].path = "https://mvn.runelite.net/org/ow2/asm/asm-all/6.0_BETA/asm-all-6.0_BETA.jar"; + artifacts[0].size = "265176"; + artifacts[1] = new Artifact(); + artifacts[1].hash = "37abf0103ce5318bfda004fabc004c75ed0dc6d392a8459175692ab7eac97083"; + artifacts[1].name = "naturalmouse-2.0.0.jar"; + artifacts[1].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/naturalmouse-2.0.0.jar"; + artifacts[1].size = "3168921"; + artifacts[2] = new Artifact(); + artifacts[2].hash = "50d1e07f11827672249dee9ce8a23691fc59f663deed084bb7b52a4f778d5fbc"; + artifacts[2].name = "jcl-core-2.9-SNAPSHOT.jar"; + artifacts[2].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/jcl-core-2.9-SNAPSHOT.jar"; + artifacts[2].size = "3168921"; + artifacts[4] = new Artifact(); + artifacts[4].hash = "18c4a0095d5c1da6b817592e767bb23d29dd2f560ad74df75ff3961dbde25b79"; + artifacts[4].name = "slf4j-api-1.7.25.jar"; + artifacts[4].path = "https://mvn.runelite.net/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar"; + artifacts[4].size = "41203"; + artifacts[5] = new Artifact(); + artifacts[5].hash = "fb53f8539e7fcb8f093a56e138112056ec1dc809ebb020b59d8a36a5ebac37e0"; + artifacts[5].name = "logback-classic-1.2.3.jar"; + artifacts[5].path = "https://mvn.runelite.net/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar"; + artifacts[5].size = "290339"; + artifacts[6] = new Artifact(); + artifacts[6].hash = "5946d837fe6f960c02a53eda7a6926ecc3c758bbdd69aa453ee429f858217f22"; + artifacts[6].name = "logback-core-1.2.3.jar"; + artifacts[6].path = "https://mvn.runelite.net/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar"; + artifacts[6].size = "471901"; + artifacts[7] = new Artifact(); + artifacts[7].hash = "9f0c8d50fa4b79b6ff1502dbec8502179d6b9497cacbe17a13074001aed537ec"; + artifacts[7].name = "jopt-simple-5.0.1.jar"; + artifacts[7].path = "https://mvn.runelite.net/net/sf/jopt-simple/jopt-simple/5.0.1/jopt-simple-5.0.1.jar"; + artifacts[7].size = "78826"; + artifacts[8] = new Artifact(); + artifacts[8].hash = "5be9a7d05ba0ccd74708bc8018ae412255f85843c0b92302e9b9befa6ed52564"; + artifacts[8].name = "guava-23.2-jre.jar"; + artifacts[8].path = "https://mvn.runelite.net/com/google/guava/guava/23.2-jre/guava-23.2-jre.jar"; + artifacts[8].size = "2649860"; + artifacts[9] = new Artifact(); + artifacts[9].hash = "905721a0eea90a81534abb7ee6ef4ea2e5e645fa1def0a5cd88402df1b46c9ed"; + artifacts[9].name = "jsr305-1.3.9.jar"; + artifacts[9].path = "https://mvn.runelite.net/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar"; + artifacts[9].size = "33015"; + artifacts[10] = new Artifact(); + artifacts[10].hash = "cb4cfad870bf563a07199f3ebea5763f0dec440fcda0b318640b1feaa788656b"; + artifacts[10].name = "error_prone_annotations-2.0.18.jar"; + artifacts[10].path = "https://mvn.runelite.net/com/google/errorprone/error_prone_annotations/2.0.18/error_prone_annotations-2.0.18.jar"; + artifacts[10].size = "12078"; + artifacts[11] = new Artifact(); + artifacts[11].hash = "2994a7eb78f2710bd3d3bfb639b2c94e219cedac0d4d084d516e78c16dddecf6"; + artifacts[11].name = "j2objc-annotations-1.1.jar"; + artifacts[11].path = "https://mvn.runelite.net/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar"; + artifacts[11].size = "8782"; + artifacts[12] = new Artifact(); + artifacts[12].hash = "2068320bd6bad744c3673ab048f67e30bef8f518996fa380033556600669905d"; + artifacts[12].name = "animal-sniffer-annotations-1.14.jar"; + artifacts[12].path = "https://mvn.runelite.net/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar"; + artifacts[12].size = "3482"; + artifacts[13] = new Artifact(); + artifacts[13].hash = "9264c6931c431e928dc64adc842584d5f57d17b2f3aff29221f2b3fdea673dad"; + artifacts[13].name = "guice-4.1.0-no_aop.jar"; + artifacts[13].path = "https://mvn.runelite.net/com/google/inject/guice/4.1.0/guice-4.1.0-no_aop.jar"; + artifacts[13].size = "428603"; + artifacts[14] = new Artifact(); + artifacts[14].hash = "91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff"; + artifacts[14].name = "javax.inject-1.jar"; + artifacts[14].path = "https://mvn.runelite.net/javax/inject/javax.inject/1/javax.inject-1.jar"; + artifacts[14].size = "2497"; + artifacts[15] = new Artifact(); + artifacts[15].hash = "0addec670fedcd3f113c5c8091d783280d23f75e3acb841b61a9cdb079376a08"; + artifacts[15].name = "aopalliance-1.0.jar"; + artifacts[15].path = "https://mvn.runelite.net/aopalliance/aopalliance/1.0/aopalliance-1.0.jar"; + artifacts[15].size = "4467"; + artifacts[16] = new Artifact(); + artifacts[16].hash = "233a0149fc365c9f6edbd683cfe266b19bdc773be98eabdaf6b3c924b48e7d81"; + artifacts[16].name = "gson-2.8.5.jar"; + artifacts[16].path = "https://mvn.runelite.net/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar"; + artifacts[16].size = "241622"; + artifacts[17] = new Artifact(); + artifacts[17].hash = "0467d25f408428824d5c9c09ec60ee1f0bc341d9bf48971a77fd14939a826c83"; + artifacts[17].name = "substance-8.0.02.jar"; + artifacts[17].path = "https://repo.runelite.net/net/runelite/pushingpixels/substance/8.0.02/substance-8.0.02.jar"; + artifacts[17].size = "1589195"; + artifacts[18] = new Artifact(); + artifacts[18].hash = "3214e1c23d549d5d67c91da4da1ef33c5248470bb824f91cbe8f9e0beea59eef"; + artifacts[18].name = "trident-1.5.00.jar"; + artifacts[18].path = "https://repo.runelite.net/net/runelite/pushingpixels/trident/1.5.00/trident-1.5.00.jar"; + artifacts[18].size = "79726"; + artifacts[19] = new Artifact(); + artifacts[19].hash = "d4a57bbc1627da7c391308fd0fe910b83170fb66afd117236a5b111d2db1590b"; + artifacts[19].name = "commons-text-1.2.jar"; + artifacts[19].path = "https://mvn.runelite.net/org/apache/commons/commons-text/1.2/commons-text-1.2.jar"; + artifacts[19].size = "136544"; + artifacts[20] = new Artifact(); + artifacts[20].hash = "6e8dc31e046508d9953c96534edf0c2e0bfe6f468966b5b842b3f87e43b6a847"; + artifacts[20].name = "commons-lang3-3.7.jar"; + artifacts[20].path = "https://mvn.runelite.net/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7.jar"; + artifacts[20].size = "499634"; + artifacts[21] = new Artifact(); + artifacts[21].hash = "e74603dc77b4183f108480279dbbf7fed3ac206069478636406c1fb45e83b31a"; + artifacts[21].name = "jogl-all-2.3.2.jar"; + artifacts[21].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2.jar"; + artifacts[21].size = "3414448"; + artifacts[22] = new Artifact(); + artifacts[22].hash = "8c53b1884cef19309d34fd10a94b010136d9d6de9a88c386f46006fb47acab5d"; + artifacts[22].name = "jogl-all-2.3.2-natives-windows-amd64.jar"; + artifacts[22].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-windows-amd64.jar"; + artifacts[22].size = "240721"; + artifacts[23] = new Artifact(); + artifacts[23].hash = "507a0e6bd1ee4e81c3dfb287783af93775864eec742988d4162f98ce0cbac9d6"; + artifacts[23].name = "jogl-all-2.3.2-natives-windows-i586.jar"; + artifacts[23].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-windows-i586.jar"; + artifacts[23].size = "209445"; + artifacts[24] = new Artifact(); + artifacts[24].hash = "82637302ae9effdf7d6f302e1050ad6aee3b13019914ddda5b502b9faa980216"; + artifacts[24].name = "jogl-all-2.3.2-natives-linux-amd64.jar"; + artifacts[24].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-linux-amd64.jar"; + artifacts[24].size = "224010"; + artifacts[25] = new Artifact(); + artifacts[25].hash = "f474ef2ef01be24ec811d3858b0f4bc5659076975f4a58ddd79abd787e9305c7"; + artifacts[25].name = "jogl-all-2.3.2-natives-linux-i586.jar"; + artifacts[25].path = "https://mvn.runelite.net/org/jogamp/jogl/jogl-all/2.3.2/jogl-all-2.3.2-natives-linux-i586.jar"; + artifacts[25].size = "217274"; + artifacts[26] = new Artifact(); + artifacts[26].hash = "084844543b18f7ff71b4c0437852bd22f0cb68d7e44c2c611c1bbea76f8c6fdf"; + artifacts[26].name = "gluegen-rt-2.3.2.jar"; + artifacts[26].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2.jar"; + artifacts[26].size = "345605"; + artifacts[27] = new Artifact(); + artifacts[27].hash = "3474017422eff384db466bdb56c96c61220c43133a9da6329cf1781bea16c6b6"; + artifacts[27].name = "gluegen-rt-2.3.2-natives-windows-amd64.jar"; + artifacts[27].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-windows-amd64.jar"; + artifacts[27].size = "8159"; + artifacts[28] = new Artifact(); + artifacts[28].hash = "4eeed9fc2ebea5b9dc48a342b9478d127e989a2e1aa7129b512a98ec75cde338"; + artifacts[28].name = "gluegen-rt-2.3.2-natives-windows-i586.jar"; + artifacts[28].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-windows-i586.jar"; + artifacts[28].size = "7577"; + artifacts[29] = new Artifact(); + artifacts[29].hash = "f2dfd1800202059cf7e0294db5d57755147304e6eb220a9277526dbe6842bde2"; + artifacts[29].name = "gluegen-rt-2.3.2-natives-linux-amd64.jar"; + artifacts[29].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-linux-amd64.jar"; + artifacts[29].size = "4149"; + artifacts[30] = new Artifact(); + artifacts[30].hash = "1365d463f98c0abec92f3ad6b35aa4b53a9599a517800cf99fdabea6712ca7ec"; + artifacts[30].name = "gluegen-rt-2.3.2-natives-linux-i586.jar"; + artifacts[30].path = "https://mvn.runelite.net/org/jogamp/gluegen/gluegen-rt/2.3.2/gluegen-rt-2.3.2-natives-linux-i586.jar"; + artifacts[30].size = "4130"; + artifacts[31] = new Artifact(); + artifacts[31].hash = "7b7ae00e2aa98c3b2b5ac76e793e2c9b752bf51c86c54654dbd473843a25f1aa"; + artifacts[31].name = "jbsdiff-1.0.jar"; + artifacts[31].path = "https://mvn.runelite.net/io/sigpipe/jbsdiff/1.0/jbsdiff-1.0.jar"; + artifacts[31].size = "24589"; + artifacts[32] = new Artifact(); + artifacts[32].hash = "55bbfe26cee9296fd5b7c0d47ce6a00ea4dd572e235b63e9bb4eaf6f802315e4"; + artifacts[32].name = "commons-compress-1.5.jar"; + artifacts[32].path = "https://mvn.runelite.net/org/apache/commons/commons-compress/1.5/commons-compress-1.5.jar"; + artifacts[32].size = "256241"; + artifacts[33] = new Artifact(); + artifacts[33].hash = "fbc9de96a0cc193a125b4008dbc348e9ed54e5e13fc67b8ed40e645d303cc51b"; + artifacts[33].name = "jna-4.5.1.jar"; + artifacts[33].path = "https://mvn.runelite.net/net/java/dev/jna/jna/4.5.1/jna-4.5.1.jar"; + artifacts[33].size = "1440662"; + artifacts[34] = new Artifact(); + artifacts[34].hash = "84c8667555ee8dd91fef44b451419f6f16f71f727d5fc475a10c2663eba83abb"; + artifacts[34].name = "jna-platform-4.5.1.jar"; + artifacts[34].path = "https://mvn.runelite.net/net/java/dev/jna/jna-platform/4.5.1/jna-platform-4.5.1.jar"; + artifacts[34].size = "2327547"; + artifacts[38] = new Artifact(); + artifacts[38].hash = "f55abda036da75e1af45bd43b9dfa79b2a3d90905be9cb38687c6621597a8165"; + artifacts[38].name = "okhttp-3.7.0.jar"; + artifacts[38].path = "https://mvn.runelite.net/com/squareup/okhttp3/okhttp/3.7.0/okhttp-3.7.0.jar"; + artifacts[38].size = "394987"; + artifacts[39] = new Artifact(); + artifacts[39].hash = "bfe7dfe483c37137966a1690f0c7d0b448ba217902c1fed202aaffdbba3291ae"; + artifacts[39].name = "okio-1.12.0.jar"; + artifacts[39].path = "https://mvn.runelite.net/com/squareup/okio/okio/1.12.0/okio-1.12.0.jar"; + artifacts[39].size = "81088"; + artifacts[40] = new Artifact(); + artifacts[40].hash = "9d4924588d6280c7516db3a4b7298306db5b6f0d1cdf568ce738309b5660f008"; + artifacts[40].name = "commons-csv-1.4.jar"; + artifacts[40].path = "https://mvn.runelite.net/org/apache/commons/commons-csv/1.4/commons-csv-1.4.jar"; + artifacts[40].size = "39978"; + artifacts[41] = new Artifact(); + artifacts[41].hash = "7e26a8d043418f2f22d5f6a3083a9a131817009ee8cd72c004e83b50d1849a7c"; + artifacts[41].name = "discord-1.1.jar"; + artifacts[41].path = "https://repo.runelite.net/net/runelite/discord/1.1/discord-1.1.jar"; + artifacts[41].size = "617294"; - private static String bytesToHex(byte[] hashInBytes) { + //Dynamic artifacts + artifacts[3] = new Artifact(); + artifacts[3].name = "client-" + RuneLiteAPI.getVersion() + ".jar"; + artifacts[3].hash = getChecksumFile("./runelite-client/target/" + artifacts[3].name); + artifacts[3].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/" + artifacts[3].name; + artifacts[3].size = Long.toString(getFileSize("./runelite-client/target/" + artifacts[3].name)); + artifacts[35] = new Artifact(); + artifacts[35].name = "runelite-api-" + RuneLiteAPI.getVersion() + ".jar"; + artifacts[35].hash = getChecksumFile("./runelite-api/target/" + artifacts[35].name); + artifacts[35].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/" + artifacts[35].name; + artifacts[35].size = Long.toString(getFileSize("./runelite-api/target/" + artifacts[35].name)); + artifacts[36] = new Artifact(); + artifacts[36].name = "runescape-api-" + RuneLiteAPI.getVersion() + ".jar"; + artifacts[36].hash = getChecksumFile("./runescape-api/target/" + artifacts[36].name); + artifacts[36].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/" + artifacts[36].name; + artifacts[36].size = Long.toString(getFileSize("./runescape-api/target/" + artifacts[36].name)); + artifacts[37] = new Artifact(); + artifacts[37].name = "http-api-" + RuneLiteAPI.getVersion() + ".jar"; + artifacts[37].hash = getChecksumFile("./http-api/target/" + artifacts[37].name); + artifacts[37].path = "https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/" + artifacts[37].name; + artifacts[37].size = Long.toString(getFileSize("./http-api/target/" + artifacts[37].name)); + } + catch (IOException e) + { + e.printStackTrace(); + } + return artifacts; + } - StringBuilder sb = new StringBuilder(); - for (byte b : hashInBytes) { - sb.append(String.format("%02x", b)); - } - return sb.toString(); - - } - - private long getFileSize(String fileLocation) { - File f = new File(fileLocation); - return f.length(); - } + private long getFileSize(String fileLocation) + { + File f = new File(fileLocation); + return f.length(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Bootstrapper.java b/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Bootstrapper.java index 7082bc780e..3a124c0b71 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Bootstrapper.java +++ b/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Bootstrapper.java @@ -2,24 +2,24 @@ package net.runelite.client.util.bootstrap; import com.google.gson.Gson; import com.google.gson.GsonBuilder; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.FileWriter; -import java.io.IOException; -public class Bootstrapper { +public class Bootstrapper +{ - public static void main(String[] args) { - Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); - try { - FileWriter fw = new FileWriter("./bootstrap.json"); - gson.toJson(new Bootstrap(), fw); - fw.close(); - } catch (Exception e) { - e.printStackTrace(); - } + public static void main(String[] args) + { + Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); + try + { + FileWriter fw = new FileWriter("./bootstrap.json"); + gson.toJson(new Bootstrap(), fw); + fw.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } - } + } } diff --git a/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Client.java b/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Client.java index 55195e26a7..59b1c60ff9 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Client.java +++ b/runelite-client/src/main/java/net/runelite/client/util/bootstrap/Client.java @@ -1,11 +1,12 @@ package net.runelite.client.util.bootstrap; -public class Client { +public class Client +{ - String artifactId = "client"; - String classifier = ""; - String extension = "jar"; - String groupId = "net.runelite"; - String properties = ""; - String version = "1.5.27"; + String artifactId = "client"; + String classifier = ""; + String extension = "jar"; + String groupId = "net.runelite"; + String properties = ""; + String version = "1.5.27"; } diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/ClickboxMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/ClickboxMixin.java index 6fe745cb14..1200698f52 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/ClickboxMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/ClickboxMixin.java @@ -1,12 +1,9 @@ package net.runelite.mixins; -import net.runelite.api.Model; -import net.runelite.api.Perspective; import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Shadow; import net.runelite.rs.api.RSClient; -import net.runelite.rs.api.RSModel; /** * Class to check clickboxes of models. Mostly refactored code from the client. @@ -14,19 +11,40 @@ import net.runelite.rs.api.RSModel; @Mixin(RSClient.class) public abstract class ClickboxMixin implements RSClient { - @Shadow("client") - private static RSClient client; - private static final int MAX_ENTITES_AT_MOUSE = 1000; private static final int CLICKBOX_CLOSE = 50; private static final int CLICKBOX_FAR = 10000; private static final int OBJECT_INTERACTION_FAR = 100; // Max distance, in tiles, from camera - @Inject private static final int[] rl$modelViewportXs = new int[4700]; - @Inject private static final int[] rl$modelViewportYs = new int[4700]; + @Shadow("client") + private static RSClient client; + + @Inject + private static int rl$rot1(int var0, int var1, int var2, int var3) + { + return var0 * var2 + var3 * var1 >> 16; + } + + @Inject + private static int rl$rot2(int var0, int var1, int var2, int var3) + { + return var2 * var1 - var3 * var0 >> 16; + } + + @Inject + private static int rl$rot3(int var0, int var1, int var2, int var3) + { + return var0 * var2 - var3 * var1 >> 16; + } + + @Inject + private static int rl$rot4(int var0, int var1, int var2, int var3) + { + return var3 * var0 + var2 * var1 >> 16; + } @Inject public void checkClickbox(net.runelite.api.Model model, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9, long l2) @@ -118,11 +136,8 @@ public abstract class ClickboxMixin implements RSClient int n28 = rl$modelViewportXs[n12]; int n29 = rl$modelViewportXs[n10]; int n30 = rl$modelViewportXs[n24]; - if (n25 != -5000 && n26 != -5000 && n27 != -5000 && (bl5 = (n23 = (n22 = rSModel.isClickable() ? 20 - : 5) + n11) < n28 && n23 < n29 && n23 < n30 ? false - : ((n23 = n11 - n22) > n28 && n23 > n29 && n23 > n30 ? false - : ((n23 = n22 + n14) < n25 && n23 < n26 && n23 < n27 ? false - : (n23 = n14 - n22) <= n25 || n23 <= n26 || n23 <= n27)))) + if (n25 != -5000 && n26 != -5000 && n27 != -5000 && (bl5 = ((n23 = (n22 = rSModel.isClickable() ? 20 + : 5) + n11) >= n28 || n23 >= n29 || n23 >= n30) && (((n23 = n11 - n22) <= n28 || n23 <= n29 || n23 <= n30) && (((n23 = n22 + n14) >= n25 || n23 >= n26 || n23 >= n27) && ((n23 = n14 - n22) <= n25 || n23 <= n26 || n23 <= n27))))) { this.addHashAtMouse(l2); return; @@ -211,34 +226,6 @@ public abstract class ClickboxMixin implements RSClient { return false; } - if (Math.abs(n39 * n23 - n38 * n24) <= n33 * n26 + n32 * n27) - { - return true; - } - return false; - } - - @Inject - private static int rl$rot1(int var0, int var1, int var2, int var3) - { - return var0 * var2 + var3 * var1 >> 16; - } - - @Inject - private static int rl$rot2(int var0, int var1, int var2, int var3) - { - return var2 * var1 - var3 * var0 >> 16; - } - - @Inject - private static int rl$rot3(int var0, int var1, int var2, int var3) - { - return var0 * var2 - var3 * var1 >> 16; - } - - @Inject - private static int rl$rot4(int var0, int var1, int var2, int var3) - { - return var3 * var0 + var2 * var1 >> 16; + return Math.abs(n39 * n23 - n38 * n24) <= n33 * n26 + n32 * n27; } } diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSModelMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSModelMixin.java index a27b82b2da..38a27323e9 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSModelMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSModelMixin.java @@ -24,21 +24,21 @@ */ package net.runelite.mixins; -import net.runelite.api.Model; -import net.runelite.api.Perspective; -import net.runelite.api.Point; -import net.runelite.api.model.Jarvis; -import net.runelite.api.model.Triangle; -import net.runelite.api.model.Vertex; import java.awt.Polygon; import java.util.ArrayList; import java.util.List; +import net.runelite.api.Model; +import net.runelite.api.Perspective; +import net.runelite.api.Point; import net.runelite.api.mixins.Copy; import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.MethodHook; import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Replace; import net.runelite.api.mixins.Shadow; +import net.runelite.api.model.Jarvis; +import net.runelite.api.model.Triangle; +import net.runelite.api.model.Vertex; import net.runelite.rs.api.RSAnimation; import net.runelite.rs.api.RSClient; import net.runelite.rs.api.RSFrames; @@ -77,9 +77,112 @@ public abstract class RSModelMixin implements RSModel } @Inject - public boolean isClickable() { + public boolean isClickable() + { return isClickable; - }; + } + + @Inject + public void interpolateFrames(RSFrames frames, int frameId, RSFrames nextFrames, int nextFrameId, int interval, int intervalCount) + { + if (getVertexGroups() != null) + { + if (frameId != -1) + { + RSAnimation frame = frames.getFrames()[frameId]; + RSSkeleton skin = frame.getSkin(); + RSAnimation nextFrame = null; + if (nextFrames != null) + { + nextFrame = nextFrames.getFrames()[nextFrameId]; + if (nextFrame.getSkin() != skin) + { + nextFrame = null; + } + } + + client.setAnimOffsetX(0); + client.setAnimOffsetY(0); + client.setAnimOffsetZ(0); + + interpolateFrames(skin, frame, nextFrame, interval, intervalCount); + resetBounds(); + } + } + } + + @Override + @Inject + public Polygon getConvexHull(int localX, int localY, int orientation, int tileHeight) + { + List vertices = getVertices(); + + // rotate vertices + for (int i = 0; i < vertices.size(); ++i) + { + Vertex v = vertices.get(i); + vertices.set(i, v.rotate(orientation)); + } + + List points = new ArrayList(); + + for (Vertex v : vertices) + { + // Compute canvas location of vertex + Point p = Perspective.localToCanvas(client, + localX - v.getX(), + localY - v.getZ(), + tileHeight + v.getY()); + if (p != null) + { + points.add(p); + } + } + + // Run Jarvis march algorithm + points = Jarvis.convexHull(points); + if (points == null) + { + return null; + } + + // Convert to a polygon + Polygon p = new Polygon(); + for (Point point : points) + { + p.addPoint(point.getX(), point.getY()); + } + + return p; + } + + @Inject + @Override + public float[][] getFaceTextureUCoordinates() + { + return rl$faceTextureUCoordinates; + } + + @Inject + @Override + public void setFaceTextureUCoordinates(float[][] faceTextureUCoordinates) + { + this.rl$faceTextureUCoordinates = faceTextureUCoordinates; + } + + @Inject + @Override + public float[][] getFaceTextureVCoordinates() + { + return rl$faceTextureVCoordinates; + } + + @Inject + @Override + public void setFaceTextureVCoordinates(float[][] faceTextureVCoordinates) + { + this.rl$faceTextureVCoordinates = faceTextureVCoordinates; + } @MethodHook(value = "", end = true) @Inject @@ -174,6 +277,48 @@ public abstract class RSModelMixin implements RSModel return triangles; } + @Inject + @Override + public int getSceneId() + { + return rl$sceneId; + } + + @Inject + @Override + public void setSceneId(int sceneId) + { + this.rl$sceneId = sceneId; + } + + @Inject + @Override + public int getBufferOffset() + { + return rl$bufferOffset; + } + + @Inject + @Override + public void setBufferOffset(int bufferOffset) + { + rl$bufferOffset = bufferOffset; + } + + @Inject + @Override + public int getUvBufferOffset() + { + return rl$uvBufferOffset; + } + + @Inject + @Override + public void setUvBufferOffset(int bufferOffset) + { + rl$uvBufferOffset = bufferOffset; + } + @Copy("contourGround") public abstract Model rs$contourGround(int[][] tileHeights, int packedX, int height, int packedY, boolean copy, int contouredGround); @@ -201,36 +346,6 @@ public abstract class RSModelMixin implements RSModel rsModel.setFaceTextureVCoordinates(rl$faceTextureVCoordinates); } - @Inject - public void interpolateFrames(RSFrames frames, int frameId, RSFrames nextFrames, int nextFrameId, int interval, - int intervalCount) - { - if (getVertexGroups() != null) - { - if (frameId != -1) - { - RSAnimation frame = frames.getFrames()[frameId]; - RSSkeleton skin = frame.getSkin(); - RSAnimation nextFrame = null; - if (nextFrames != null) - { - nextFrame = nextFrames.getFrames()[nextFrameId]; - if (nextFrame.getSkin() != skin) - { - nextFrame = null; - } - } - - client.setAnimOffsetX(0); - client.setAnimOffsetY(0); - client.setAnimOffsetZ(0); - - interpolateFrames(skin, frame, nextFrame, interval, intervalCount); - resetBounds(); - } - } - } - @Inject public void interpolateFrames(RSSkeleton skin, RSAnimation frame, RSAnimation nextFrame, int interval, int intervalCount) { @@ -334,119 +449,4 @@ public abstract class RSModelMixin implements RSModel } } } - - @Override - @Inject - public Polygon getConvexHull(int localX, int localY, int orientation, int tileHeight) - { - List vertices = getVertices(); - - // rotate vertices - for (int i = 0; i < vertices.size(); ++i) - { - Vertex v = vertices.get(i); - vertices.set(i, v.rotate(orientation)); - } - - List points = new ArrayList(); - - for (Vertex v : vertices) - { - // Compute canvas location of vertex - Point p = Perspective.localToCanvas(client, - localX - v.getX(), - localY - v.getZ(), - tileHeight + v.getY()); - if (p != null) - { - points.add(p); - } - } - - // Run Jarvis march algorithm - points = Jarvis.convexHull(points); - if (points == null) - { - return null; - } - - // Convert to a polygon - Polygon p = new Polygon(); - for (Point point : points) - { - p.addPoint(point.getX(), point.getY()); - } - - return p; - } - - @Inject - @Override - public int getSceneId() - { - return rl$sceneId; - } - - @Inject - @Override - public void setSceneId(int sceneId) - { - this.rl$sceneId = sceneId; - } - - @Inject - @Override - public int getBufferOffset() - { - return rl$bufferOffset; - } - - @Inject - @Override - public void setBufferOffset(int bufferOffset) - { - rl$bufferOffset = bufferOffset; - } - - @Inject - @Override - public int getUvBufferOffset() - { - return rl$uvBufferOffset; - } - - @Inject - @Override - public void setUvBufferOffset(int bufferOffset) - { - rl$uvBufferOffset = bufferOffset; - } - - @Inject - @Override - public float[][] getFaceTextureUCoordinates() - { - return rl$faceTextureUCoordinates; - } - - @Inject - @Override - public void setFaceTextureUCoordinates(float[][] faceTextureUCoordinates) - { - this.rl$faceTextureUCoordinates = faceTextureUCoordinates; - } - - @Inject - @Override - public float[][] getFaceTextureVCoordinates() - { - return rl$faceTextureVCoordinates; - } - - @Inject - @Override - public void setFaceTextureVCoordinates(float[][] faceTextureVCoordinates) - { - this.rl$faceTextureVCoordinates = faceTextureVCoordinates; - } } From 8738faaf2d9732207969b06792a770d63b9e46a5 Mon Sep 17 00:00:00 2001 From: zeruth Date: Mon, 10 Jun 2019 01:59:59 -0400 Subject: [PATCH 26/63] Update settings.xml Disable tests for now. --- travis/settings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/travis/settings.xml b/travis/settings.xml index 84b8566464..25ac60211d 100644 --- a/travis/settings.xml +++ b/travis/settings.xml @@ -258,8 +258,8 @@ under the License. true - false - false + true + true From 15458d89b9f5ff3083374dd94272ba671aaa3077 Mon Sep 17 00:00:00 2001 From: zeruth Date: Mon, 10 Jun 2019 02:08:25 -0400 Subject: [PATCH 27/63] Update settings.xml Im fuckin retarded, dont mind me --- travis/settings.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/travis/settings.xml b/travis/settings.xml index 25ac60211d..780196878e 100644 --- a/travis/settings.xml +++ b/travis/settings.xml @@ -258,8 +258,9 @@ under the License. true - true + false true + true From 54cd44581e4ce3bffdea360d6a93617f43bcc95d Mon Sep 17 00:00:00 2001 From: James Munson Date: Sun, 9 Jun 2019 23:10:06 -0700 Subject: [PATCH 28/63] Extend line of sight range --- .../java/net/runelite/client/plugins/devtools/SceneOverlay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/SceneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/SceneOverlay.java index 9ee625e615..8c57b88a6b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/SceneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/SceneOverlay.java @@ -62,7 +62,7 @@ public class SceneOverlay extends Overlay private static final int MAP_SQUARE_SIZE = CHUNK_SIZE * CHUNK_SIZE; // 64 private static final int CULL_CHUNK_BORDERS_RANGE = 16; private static final int STROKE_WIDTH = 4; - private static final int CULL_LINE_OF_SIGHT_RANGE = 10; + private static final int CULL_LINE_OF_SIGHT_RANGE = 20; private static final int INTERACTING_SHIFT = -16; private static final Polygon ARROW_HEAD = new Polygon( From a3c41442733e4d0d0f12dcc40fdcc976910ff8c7 Mon Sep 17 00:00:00 2001 From: zeruth Date: Mon, 10 Jun 2019 02:13:28 -0400 Subject: [PATCH 29/63] Update build.sh whatever, just do it the easy way --- travis/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/build.sh b/travis/build.sh index deba275667..52d364db04 100644 --- a/travis/build.sh +++ b/travis/build.sh @@ -1,3 +1,3 @@ #!/bin/bash -mvn clean install --settings travis/settings.xml +mvn clean install -DskipTests --settings travis/settings.xml From fb9709ab71900edac3d59ca2626767a88c33701d Mon Sep 17 00:00:00 2001 From: zeruth Date: Mon, 10 Jun 2019 02:24:21 -0400 Subject: [PATCH 30/63] temp --- .../java/net/runelite/mixins/RSTileMixin.java | 145 +++++++++++------- 1 file changed, 86 insertions(+), 59 deletions(-) diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java index b88684fc6b..093fa17d88 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java @@ -24,12 +24,12 @@ */ package net.runelite.mixins; -import net.runelite.api.Actor; +import java.util.ArrayList; +import java.util.List; import net.runelite.api.CollisionData; import net.runelite.api.CollisionDataFlag; import net.runelite.api.Constants; import net.runelite.api.DecorativeObject; -import net.runelite.api.GameObject; import net.runelite.api.GroundObject; import net.runelite.api.Item; import net.runelite.api.ItemLayer; @@ -53,31 +53,31 @@ import net.runelite.api.events.ItemSpawned; import net.runelite.api.events.WallObjectChanged; import net.runelite.api.events.WallObjectDespawned; import net.runelite.api.events.WallObjectSpawned; -import java.util.ArrayList; -import java.util.List; import net.runelite.api.mixins.FieldHook; import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Shadow; +import net.runelite.rs.api.RSActor; import net.runelite.rs.api.RSClient; +import net.runelite.rs.api.RSDeque; import net.runelite.rs.api.RSGameObject; -import net.runelite.rs.api.RSGroundItem; -import net.runelite.rs.api.RSGroundItemPile; +import net.runelite.rs.api.RSGraphicsObject; +import net.runelite.rs.api.RSItem; +import net.runelite.rs.api.RSItemLayer; import net.runelite.rs.api.RSNode; -import net.runelite.rs.api.RSNodeDeque; +import net.runelite.rs.api.RSProjectile; +import net.runelite.rs.api.RSRenderable; import net.runelite.rs.api.RSTile; +import org.slf4j.Logger; @Mixin(RSTile.class) public abstract class RSTileMixin implements RSTile { - @Shadow("client") + @Shadow("clientInstance") private static RSClient client; @Inject - private static GameObject lastGameObject; - - @Inject - private static RSNodeDeque[][][] lastGroundItems = new RSNodeDeque[Constants.MAX_Z][Constants.SCENE_SIZE][Constants.SCENE_SIZE]; + private static RSDeque[][][] lastGroundItems = new RSDeque[Constants.MAX_Z][Constants.SCENE_SIZE][Constants.SCENE_SIZE]; @Inject private WallObject previousWallObject; @@ -89,7 +89,7 @@ public abstract class RSTileMixin implements RSTile private GroundObject previousGroundObject; @Inject - private GameObject[] previousGameObjects; + private RSGameObject[] previousGameObjects; @Inject @Override @@ -112,7 +112,7 @@ public abstract class RSTileMixin implements RSTile return LocalPoint.fromScene(getX(), getY()); } - @FieldHook("boundaryObject") + @FieldHook("wallObject") @Inject public void wallObjectChanged(int idx) { @@ -135,7 +135,7 @@ public abstract class RSTileMixin implements RSTile wallObjectSpawned.setWallObject(current); client.getCallbacks().post(wallObjectSpawned); } - else if (current != null) + else if (current != null && previous != null) { WallObjectChanged wallObjectChanged = new WallObjectChanged(); wallObjectChanged.setTile(this); @@ -145,7 +145,7 @@ public abstract class RSTileMixin implements RSTile } } - @FieldHook("wallDecoration") + @FieldHook("decorativeObject") @Inject public void decorativeObjectChanged(int idx) { @@ -168,7 +168,7 @@ public abstract class RSTileMixin implements RSTile decorativeObjectSpawned.setDecorativeObject(current); client.getCallbacks().post(decorativeObjectSpawned); } - else if (current != null) + else if (current != null && previous != null) { DecorativeObjectChanged decorativeObjectChanged = new DecorativeObjectChanged(); decorativeObjectChanged.setTile(this); @@ -178,7 +178,7 @@ public abstract class RSTileMixin implements RSTile } } - @FieldHook("floorDecoration") + @FieldHook("groundObject") @Inject public void groundObjectChanged(int idx) { @@ -201,7 +201,7 @@ public abstract class RSTileMixin implements RSTile groundObjectSpawned.setGroundObject(current); client.getCallbacks().post(groundObjectSpawned); } - else if (current != null) + else if (current != null && previous != null) { GroundObjectChanged groundObjectChanged = new GroundObjectChanged(); groundObjectChanged.setTile(this); @@ -211,7 +211,7 @@ public abstract class RSTileMixin implements RSTile } } - @FieldHook("gameObjects") + @FieldHook("objects") @Inject public void gameObjectsChanged(int idx) { @@ -222,69 +222,96 @@ public abstract class RSTileMixin implements RSTile if (previousGameObjects == null) { - previousGameObjects = new GameObject[5]; + previousGameObjects = new RSGameObject[5]; } // Previous game object - GameObject previous = previousGameObjects[idx]; + RSGameObject previous = previousGameObjects[idx]; // GameObject that was changed. RSGameObject current = (RSGameObject) getGameObjects()[idx]; - // Last game object - GameObject last = lastGameObject; - - // Update last game object - lastGameObject = current; - // Update previous object to current previousGameObjects[idx] = current; // Duplicate event, return - if (current != null && current.equals(last)) + if (current == previous) { return; } - // Characters seem to generate a constant stream of new GameObjects - if (current == null || !(current.getRenderable() instanceof Actor)) + // actors, projectiles, and graphics objects are added and removed from the scene each frame as GameObjects, + // so ignore them. + boolean currentInvalid = false, prevInvalid = false; + if (current != null) { - if (current == null && previous != null) + RSRenderable renderable = current.getRenderable(); + currentInvalid = renderable instanceof RSActor || renderable instanceof RSProjectile || renderable instanceof RSGraphicsObject; + } + + if (previous != null) + { + RSRenderable renderable = previous.getRenderable(); + prevInvalid = renderable instanceof RSActor || renderable instanceof RSProjectile || renderable instanceof RSGraphicsObject; + } + + Logger logger = client.getLogger(); + if (current == null) + { + if (prevInvalid) { - GameObjectDespawned gameObjectDespawned = new GameObjectDespawned(); - gameObjectDespawned.setTile(this); - gameObjectDespawned.setGameObject(previous); - client.getCallbacks().post(gameObjectDespawned); + return; } - else if (current != null && previous == null) + + logger.trace("Game object despawn: {}", previous.getId()); + + GameObjectDespawned gameObjectDespawned = new GameObjectDespawned(); + gameObjectDespawned.setTile(this); + gameObjectDespawned.setGameObject(previous); + client.getCallbacks().post(gameObjectDespawned); + } + else if (previous == null) + { + if (currentInvalid) { - GameObjectSpawned gameObjectSpawned = new GameObjectSpawned(); - gameObjectSpawned.setTile(this); - gameObjectSpawned.setGameObject(current); - client.getCallbacks().post(gameObjectSpawned); + return; } - else if (current != null) + + logger.trace("Game object spawn: {}", current.getId()); + + GameObjectSpawned gameObjectSpawned = new GameObjectSpawned(); + gameObjectSpawned.setTile(this); + gameObjectSpawned.setGameObject(current); + client.getCallbacks().post(gameObjectSpawned); + } + else + { + if (currentInvalid && prevInvalid) { - GameObjectChanged gameObjectsChanged = new GameObjectChanged(); - gameObjectsChanged.setTile(this); - gameObjectsChanged.setPrevious(previous); - gameObjectsChanged.setGameObject(current); - client.getCallbacks().post(gameObjectsChanged); + return; } + + logger.trace("Game object change: {} -> {}", previous.getId(), current.getId()); + + GameObjectChanged gameObjectsChanged = new GameObjectChanged(); + gameObjectsChanged.setTile(this); + gameObjectsChanged.setPrevious(previous); + gameObjectsChanged.setGameObject(current); + client.getCallbacks().post(gameObjectsChanged); } } - @FieldHook("groundItemPile") + @FieldHook("itemLayer") @Inject public void itemLayerChanged(int idx) { int x = getX(); int y = getY(); int z = client.getPlane(); - RSNodeDeque[][][] groundItemDeque = client.getGroundItemDeque(); + RSDeque[][][] groundItemDeque = client.getGroundItemDeque(); - RSNodeDeque oldQueue = lastGroundItems[z][x][y]; - RSNodeDeque newQueue = groundItemDeque[z][x][y]; + RSDeque oldQueue = lastGroundItems[z][x][y]; + RSDeque newQueue = groundItemDeque[z][x][y]; if (oldQueue != newQueue) { @@ -294,7 +321,7 @@ public abstract class RSTileMixin implements RSTile RSNode head = oldQueue.getHead(); for (RSNode cur = head.getNext(); cur != head; cur = cur.getNext()) { - RSGroundItem item = (RSGroundItem) cur; + RSItem item = (RSItem) cur; ItemDespawned itemDespawned = new ItemDespawned(this, item); client.getCallbacks().post(itemDespawned); } @@ -302,13 +329,13 @@ public abstract class RSTileMixin implements RSTile lastGroundItems[z][x][y] = newQueue; } - RSGroundItem lastUnlink = client.getLastItemDespawn(); + RSItem lastUnlink = client.getLastItemDespawn(); if (lastUnlink != null) { client.setLastItemDespawn(null); } - RSGroundItemPile itemLayer = (RSGroundItemPile) getItemLayer(); + RSItemLayer itemLayer = (RSItemLayer) getItemLayer(); if (itemLayer == null) { if (lastUnlink != null) @@ -319,7 +346,7 @@ public abstract class RSTileMixin implements RSTile return; } - RSNodeDeque itemDeque = newQueue; + RSDeque itemDeque = newQueue; if (itemDeque == null) { @@ -338,7 +365,7 @@ public abstract class RSTileMixin implements RSTile boolean forward = false; if (head != previous) { - RSGroundItem prev = (RSGroundItem) previous; + RSItem prev = (RSItem) previous; if (x != prev.getX() || y != prev.getY()) { current = prev; @@ -348,7 +375,7 @@ public abstract class RSTileMixin implements RSTile RSNode next = head.getNext(); if (current == null && head != next) { - RSGroundItem n = (RSGroundItem) next; + RSItem n = (RSItem) next; if (x != n.getX() || y != n.getY()) { current = n; @@ -369,7 +396,7 @@ public abstract class RSTileMixin implements RSTile do { - RSGroundItem item = (RSGroundItem) current; + RSItem item = (RSItem) current; item.setX(x); item.setY(y); @@ -380,7 +407,7 @@ public abstract class RSTileMixin implements RSTile // Send spawn events for anything on this tile which is at the wrong location, which happens // when the scene base changes - } while (current != head && (((RSGroundItem) current).getX() != x || ((RSGroundItem) current).getY() != y)); + } while (current != head && (((RSItem) current).getX() != x || ((RSItem) current).getY() != y)); } @Inject From e8cf7132c6c2f76cdde91d4816d9c6093e3d0aef Mon Sep 17 00:00:00 2001 From: James Munson Date: Sun, 9 Jun 2019 23:26:50 -0700 Subject: [PATCH 31/63] Add impling overlay --- .../implings/ImplingCounterOverlay.java | 53 +++++++++++++++++++ .../plugins/implings/ImplingsConfig.java | 11 ++++ .../plugins/implings/ImplingsPlugin.java | 31 ++++++++++- 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingCounterOverlay.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingCounterOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingCounterOverlay.java new file mode 100644 index 0000000000..c88d433254 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingCounterOverlay.java @@ -0,0 +1,53 @@ +package net.runelite.client.plugins.implings; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.util.Map; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.components.table.TableAlignment; +import net.runelite.client.ui.overlay.components.table.TableComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; + +public class ImplingCounterOverlay extends Overlay +{ + private final Client client; + private final ImplingsPlugin plugin; + private final ImplingsConfig config; + + private final PanelComponent panelComponent = new PanelComponent(); + + @Inject + public ImplingCounterOverlay(Client client, ImplingsConfig config, ImplingsPlugin plugin) + { + this.client = client; + this.config = config; + this.plugin = plugin; + setPosition(OverlayPosition.TOP_LEFT); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (!config.showCounter() || plugin.getImplings().isEmpty()) + return null; + + panelComponent.getChildren().clear(); + + TableComponent tableComponent = new TableComponent(); + tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT); + + for (Map.Entry entry : plugin.getImplingCounterMap().entrySet()) + { + if (plugin.showImplingType(entry.getKey()) && entry.getValue() != 0) + { + tableComponent.addRow(entry.getKey().getName(), entry.getValue().toString()); + } + } + + panelComponent.getChildren().add(tableComponent); + return panelComponent.render(graphics); + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java index 386284a874..d55be9f962 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java @@ -320,4 +320,15 @@ public interface ImplingsConfig extends Config { return Color.WHITE; } + + @ConfigItem( + position = 26, + keyName = "showCounter", + name = "Show impling counter overlay", + description = "Shows how many of each impling there is nearby" + ) + default boolean showCounter() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java index f768cad97d..f08c0ba4e9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.HashMap; import javax.inject.Inject; import lombok.AccessLevel; import lombok.Getter; @@ -58,6 +59,9 @@ public class ImplingsPlugin extends Plugin private static final int DYNAMIC_SPAWN_ECLECTIC = 1633; private static final int DYNAMIC_SPAWN_BABY_ESSENCE = 1634; + @Getter + private Map implingCounterMap = new HashMap<>(); + @Getter(AccessLevel.PACKAGE) private final List implings = new ArrayList<>(); @@ -67,6 +71,10 @@ public class ImplingsPlugin extends Plugin @Inject private ImplingsOverlay overlay; + @Inject + private ImplingCounterOverlay implingCounterOverlay; + + @Inject private OverlayManager overlayManager; @@ -91,6 +99,7 @@ public class ImplingsPlugin extends Plugin overlayManager.add(overlay); overlayManager.add(minimapOverlay); + overlayManager.add(implingCounterOverlay); } @Override @@ -98,6 +107,7 @@ public class ImplingsPlugin extends Plugin { overlayManager.remove(overlay); overlayManager.remove(minimapOverlay); + overlayManager.remove(implingCounterOverlay); } @Subscribe @@ -109,6 +119,16 @@ public class ImplingsPlugin extends Plugin if (impling != null) { implings.add(npc); + + ImplingType type = impling.getImplingType(); + if (implingCounterMap.containsKey(type)) + { + implingCounterMap.put(type, implingCounterMap.get(type) + 1); + } + else + { + implingCounterMap.put(type, 1); + } } } @@ -118,6 +138,7 @@ public class ImplingsPlugin extends Plugin if (event.getGameState() == GameState.LOGIN_SCREEN || event.getGameState() == GameState.HOPPING) { implings.clear(); + implingCounterMap.clear(); } } @@ -131,6 +152,9 @@ public class ImplingsPlugin extends Plugin NPC npc = npcDespawned.getNpc(); implings.remove(npc); + + Impling impling = Impling.findImpling(npc.getId()); + if (impling != null) implingCounterMap.put(impling.getImplingType(), implingCounterMap.get(impling.getImplingType()) - 1); } boolean showNpc(NPC npc) @@ -183,7 +207,12 @@ public class ImplingsPlugin extends Plugin return null; } - switch (impling.getImplingType()) + return typeToColor(impling.getImplingType()); + } + + Color typeToColor(ImplingType type) + { + switch (type) { case BABY: From ab3c6eb1b52b524a26b2316aba05b0118b36c745 Mon Sep 17 00:00:00 2001 From: zeruth Date: Mon, 10 Jun 2019 02:30:08 -0400 Subject: [PATCH 32/63] fix temp --- .../java/net/runelite/mixins/RSTileMixin.java | 154 +++++++----------- 1 file changed, 55 insertions(+), 99 deletions(-) diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java index 1cb4a729a8..b88684fc6b 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSTileMixin.java @@ -24,12 +24,12 @@ */ package net.runelite.mixins; -import java.util.ArrayList; -import java.util.List; +import net.runelite.api.Actor; import net.runelite.api.CollisionData; import net.runelite.api.CollisionDataFlag; import net.runelite.api.Constants; import net.runelite.api.DecorativeObject; +import net.runelite.api.GameObject; import net.runelite.api.GroundObject; import net.runelite.api.Item; import net.runelite.api.ItemLayer; @@ -53,34 +53,31 @@ import net.runelite.api.events.ItemSpawned; import net.runelite.api.events.WallObjectChanged; import net.runelite.api.events.WallObjectDespawned; import net.runelite.api.events.WallObjectSpawned; +import java.util.ArrayList; +import java.util.List; import net.runelite.api.mixins.FieldHook; import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Shadow; -import net.runelite.rs.api.RSActor; import net.runelite.rs.api.RSClient; -import net.runelite.rs.api.RSDeque; import net.runelite.rs.api.RSGameObject; -import net.runelite.rs.api.RSGraphicsObject; -import net.runelite.rs.api.RSItem; -import net.runelite.rs.api.RSItemLayer; +import net.runelite.rs.api.RSGroundItem; +import net.runelite.rs.api.RSGroundItemPile; import net.runelite.rs.api.RSNode; -import net.runelite.rs.api.RSProjectile; -import net.runelite.rs.api.RSRenderable; +import net.runelite.rs.api.RSNodeDeque; import net.runelite.rs.api.RSTile; -import org.slf4j.Logger; @Mixin(RSTile.class) public abstract class RSTileMixin implements RSTile { - @Shadow("clientInstance") + @Shadow("client") private static RSClient client; @Inject - private static RSGameObject lastGameObject; + private static GameObject lastGameObject; @Inject - private static RSDeque[][][] lastGroundItems = new RSDeque[Constants.MAX_Z][Constants.SCENE_SIZE][Constants.SCENE_SIZE]; + private static RSNodeDeque[][][] lastGroundItems = new RSNodeDeque[Constants.MAX_Z][Constants.SCENE_SIZE][Constants.SCENE_SIZE]; @Inject private WallObject previousWallObject; @@ -92,7 +89,7 @@ public abstract class RSTileMixin implements RSTile private GroundObject previousGroundObject; @Inject - private RSGameObject[] previousGameObjects; + private GameObject[] previousGameObjects; @Inject @Override @@ -115,7 +112,7 @@ public abstract class RSTileMixin implements RSTile return LocalPoint.fromScene(getX(), getY()); } - @FieldHook("wallObject") + @FieldHook("boundaryObject") @Inject public void wallObjectChanged(int idx) { @@ -138,7 +135,7 @@ public abstract class RSTileMixin implements RSTile wallObjectSpawned.setWallObject(current); client.getCallbacks().post(wallObjectSpawned); } - else if (current != null && previous != null) + else if (current != null) { WallObjectChanged wallObjectChanged = new WallObjectChanged(); wallObjectChanged.setTile(this); @@ -148,7 +145,7 @@ public abstract class RSTileMixin implements RSTile } } - @FieldHook("decorativeObject") + @FieldHook("wallDecoration") @Inject public void decorativeObjectChanged(int idx) { @@ -171,7 +168,7 @@ public abstract class RSTileMixin implements RSTile decorativeObjectSpawned.setDecorativeObject(current); client.getCallbacks().post(decorativeObjectSpawned); } - else if (current != null && previous != null) + else if (current != null) { DecorativeObjectChanged decorativeObjectChanged = new DecorativeObjectChanged(); decorativeObjectChanged.setTile(this); @@ -181,7 +178,7 @@ public abstract class RSTileMixin implements RSTile } } - @FieldHook("groundObject") + @FieldHook("floorDecoration") @Inject public void groundObjectChanged(int idx) { @@ -204,7 +201,7 @@ public abstract class RSTileMixin implements RSTile groundObjectSpawned.setGroundObject(current); client.getCallbacks().post(groundObjectSpawned); } - else if (current != null && previous != null) + else if (current != null) { GroundObjectChanged groundObjectChanged = new GroundObjectChanged(); groundObjectChanged.setTile(this); @@ -214,7 +211,7 @@ public abstract class RSTileMixin implements RSTile } } - @FieldHook("objects") + @FieldHook("gameObjects") @Inject public void gameObjectsChanged(int idx) { @@ -225,110 +222,69 @@ public abstract class RSTileMixin implements RSTile if (previousGameObjects == null) { - previousGameObjects = new RSGameObject[5]; + previousGameObjects = new GameObject[5]; } // Previous game object - RSGameObject previous = previousGameObjects[idx]; + GameObject previous = previousGameObjects[idx]; // GameObject that was changed. RSGameObject current = (RSGameObject) getGameObjects()[idx]; - // Update previous object to current - previousGameObjects[idx] = current; - // Last game object - RSGameObject last = lastGameObject; + GameObject last = lastGameObject; // Update last game object lastGameObject = current; + // Update previous object to current + previousGameObjects[idx] = current; + // Duplicate event, return - if (current == previous) + if (current != null && current.equals(last)) { return; } - if (current != null && current == last) + // Characters seem to generate a constant stream of new GameObjects + if (current == null || !(current.getRenderable() instanceof Actor)) { - // When >1 tile objects are added to the scene, the same GameObject is added to - // multiple tiles. We keep lastGameObject to prevent duplicate spawn events from - // firing for these objects. - return; - } - - // actors, projectiles, and graphics objects are added and removed from the scene each frame as GameObjects, - // so ignore them. - boolean currentInvalid = false, prevInvalid = false; - if (current != null) - { - RSRenderable renderable = current.getRenderable(); - currentInvalid = renderable instanceof RSActor || renderable instanceof RSProjectile || renderable instanceof RSGraphicsObject; - } - - if (previous != null) - { - RSRenderable renderable = previous.getRenderable(); - prevInvalid = renderable instanceof RSActor || renderable instanceof RSProjectile || renderable instanceof RSGraphicsObject; - } - - Logger logger = client.getLogger(); - if (current == null) - { - if (prevInvalid) + if (current == null && previous != null) { - return; + GameObjectDespawned gameObjectDespawned = new GameObjectDespawned(); + gameObjectDespawned.setTile(this); + gameObjectDespawned.setGameObject(previous); + client.getCallbacks().post(gameObjectDespawned); } - - logger.trace("Game object despawn: {}", previous.getId()); - - GameObjectDespawned gameObjectDespawned = new GameObjectDespawned(); - gameObjectDespawned.setTile(this); - gameObjectDespawned.setGameObject(previous); - client.getCallbacks().post(gameObjectDespawned); - } - else if (previous == null) - { - if (currentInvalid) + else if (current != null && previous == null) { - return; + GameObjectSpawned gameObjectSpawned = new GameObjectSpawned(); + gameObjectSpawned.setTile(this); + gameObjectSpawned.setGameObject(current); + client.getCallbacks().post(gameObjectSpawned); } - - logger.trace("Game object spawn: {}", current.getId()); - - GameObjectSpawned gameObjectSpawned = new GameObjectSpawned(); - gameObjectSpawned.setTile(this); - gameObjectSpawned.setGameObject(current); - client.getCallbacks().post(gameObjectSpawned); - } - else - { - if (currentInvalid && prevInvalid) + else if (current != null) { - return; + GameObjectChanged gameObjectsChanged = new GameObjectChanged(); + gameObjectsChanged.setTile(this); + gameObjectsChanged.setPrevious(previous); + gameObjectsChanged.setGameObject(current); + client.getCallbacks().post(gameObjectsChanged); } - - logger.trace("Game object change: {} -> {}", previous.getId(), current.getId()); - - GameObjectChanged gameObjectsChanged = new GameObjectChanged(); - gameObjectsChanged.setTile(this); - gameObjectsChanged.setPrevious(previous); - gameObjectsChanged.setGameObject(current); - client.getCallbacks().post(gameObjectsChanged); } } - @FieldHook("itemLayer") + @FieldHook("groundItemPile") @Inject public void itemLayerChanged(int idx) { int x = getX(); int y = getY(); int z = client.getPlane(); - RSDeque[][][] groundItemDeque = client.getGroundItemDeque(); + RSNodeDeque[][][] groundItemDeque = client.getGroundItemDeque(); - RSDeque oldQueue = lastGroundItems[z][x][y]; - RSDeque newQueue = groundItemDeque[z][x][y]; + RSNodeDeque oldQueue = lastGroundItems[z][x][y]; + RSNodeDeque newQueue = groundItemDeque[z][x][y]; if (oldQueue != newQueue) { @@ -338,7 +294,7 @@ public abstract class RSTileMixin implements RSTile RSNode head = oldQueue.getHead(); for (RSNode cur = head.getNext(); cur != head; cur = cur.getNext()) { - RSItem item = (RSItem) cur; + RSGroundItem item = (RSGroundItem) cur; ItemDespawned itemDespawned = new ItemDespawned(this, item); client.getCallbacks().post(itemDespawned); } @@ -346,13 +302,13 @@ public abstract class RSTileMixin implements RSTile lastGroundItems[z][x][y] = newQueue; } - RSItem lastUnlink = client.getLastItemDespawn(); + RSGroundItem lastUnlink = client.getLastItemDespawn(); if (lastUnlink != null) { client.setLastItemDespawn(null); } - RSItemLayer itemLayer = (RSItemLayer) getItemLayer(); + RSGroundItemPile itemLayer = (RSGroundItemPile) getItemLayer(); if (itemLayer == null) { if (lastUnlink != null) @@ -363,7 +319,7 @@ public abstract class RSTileMixin implements RSTile return; } - RSDeque itemDeque = newQueue; + RSNodeDeque itemDeque = newQueue; if (itemDeque == null) { @@ -382,7 +338,7 @@ public abstract class RSTileMixin implements RSTile boolean forward = false; if (head != previous) { - RSItem prev = (RSItem) previous; + RSGroundItem prev = (RSGroundItem) previous; if (x != prev.getX() || y != prev.getY()) { current = prev; @@ -392,7 +348,7 @@ public abstract class RSTileMixin implements RSTile RSNode next = head.getNext(); if (current == null && head != next) { - RSItem n = (RSItem) next; + RSGroundItem n = (RSGroundItem) next; if (x != n.getX() || y != n.getY()) { current = n; @@ -413,7 +369,7 @@ public abstract class RSTileMixin implements RSTile do { - RSItem item = (RSItem) current; + RSGroundItem item = (RSGroundItem) current; item.setX(x); item.setY(y); @@ -424,7 +380,7 @@ public abstract class RSTileMixin implements RSTile // Send spawn events for anything on this tile which is at the wrong location, which happens // when the scene base changes - } while (current != head && (((RSItem) current).getX() != x || ((RSItem) current).getY() != y)); + } while (current != head && (((RSGroundItem) current).getX() != x || ((RSGroundItem) current).getY() != y)); } @Inject From bb9510caf480a6290d9d18149562ea0b81f3326a Mon Sep 17 00:00:00 2001 From: zeruth Date: Mon, 10 Jun 2019 02:31:11 -0400 Subject: [PATCH 33/63] Update .travis.yml Only build 8 for now. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d34dc4ca2e..9f3f35a358 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ cache: - $HOME/.m2 jdk: - oraclejdk8 -- oraclejdk11 install: true script: ./travis/build.sh before_install: From 71103190b54987d4f113467ae9aa1f9f30883eca Mon Sep 17 00:00:00 2001 From: James Munson Date: Sun, 9 Jun 2019 23:31:19 -0700 Subject: [PATCH 34/63] Fix --- .../plugins/implings/ImplingsPlugin.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java index f08c0ba4e9..f0709535f4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java @@ -36,6 +36,7 @@ import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.GameState; import net.runelite.api.NPC; +import net.runelite.api.events.GameTick; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; @@ -111,14 +112,12 @@ public class ImplingsPlugin extends Plugin } @Subscribe - public void onNpcSpawned(NpcSpawned npcSpawned) + public void onGameTick(GameTick event) { - NPC npc = npcSpawned.getNpc(); - Impling impling = Impling.findImpling(npc.getId()); - - if (impling != null) + implingCounterMap.clear(); + for (NPC npc : implings) { - implings.add(npc); + Impling impling = Impling.findImpling(npc.getId()); ImplingType type = impling.getImplingType(); if (implingCounterMap.containsKey(type)) @@ -132,6 +131,18 @@ public class ImplingsPlugin extends Plugin } } + @Subscribe + public void onNpcSpawned(NpcSpawned npcSpawned) + { + NPC npc = npcSpawned.getNpc(); + Impling impling = Impling.findImpling(npc.getId()); + + if (impling != null) + { + implings.add(npc); + } + } + @Subscribe public void onGameStateChanged(GameStateChanged event) { @@ -153,8 +164,6 @@ public class ImplingsPlugin extends Plugin NPC npc = npcDespawned.getNpc(); implings.remove(npc); - Impling impling = Impling.findImpling(npc.getId()); - if (impling != null) implingCounterMap.put(impling.getImplingType(), implingCounterMap.get(impling.getImplingType()) - 1); } boolean showNpc(NPC npc) From 58014c53be5574ecee167e7238abe4cdf1454c4f Mon Sep 17 00:00:00 2001 From: James Munson Date: Sun, 9 Jun 2019 23:43:15 -0700 Subject: [PATCH 35/63] Added inferno plugin --- .../client/plugins/inferno/InfernoConfig.java | 55 ++++ .../plugins/inferno/InfernoInfobox.java | 57 ++++ .../client/plugins/inferno/InfernoNPC.java | 161 +++++++++++ .../plugins/inferno/InfernoNibberOverlay.java | 47 ++++ .../plugins/inferno/InfernoOverlay.java | 85 ++++++ .../client/plugins/inferno/InfernoPlugin.java | 249 ++++++++++++++++++ 6 files changed, 654 insertions(+) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java new file mode 100644 index 0000000000..24132a037a --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019, Jacky + * 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.plugins.inferno; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("inferno") +public interface InfernoConfig extends Config +{ + @ConfigItem( + position = 0, + keyName = "Nibber Overlay", + name = "Nibber Overlay", + description = "Shows if there are any nibbas left" + ) + default boolean displayNibbaOverlay() + { + return false; + } + + @ConfigItem( + position = 1, + keyName = "Prayer Helper", + name = "Prayer Helper", + description = "Tells you what to flick in how many ticks" + ) + default boolean showPrayerHelp() + { + return false; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java new file mode 100644 index 0000000000..7edf69cced --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java @@ -0,0 +1,57 @@ +package net.runelite.client.plugins.inferno; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.components.LineComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; + +public class InfernoInfobox extends Overlay +{ + private final Client client; + private final InfernoPlugin plugin; + private final InfernoConfig config; + + private final PanelComponent panelComponent = new PanelComponent(); + + @Inject + public InfernoInfobox(Client client, InfernoConfig config, InfernoPlugin plugin) + { + this.client = client; + this.config = config; + this.plugin = plugin; + setPosition(OverlayPosition.TOP_LEFT); + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (!config.showPrayerHelp() || client.getMapRegions()[0] != 9043) return null; + + panelComponent.getChildren().clear(); + + for (int i = plugin.getPriorityNPC().length; i > 0; i--) + { + if (plugin.getPriorityNPC()[i-1] == null) + { + panelComponent.getChildren().add(LineComponent.builder() + .left(Integer.toString(i)) + .right("-") + .build()); + } + else + { + panelComponent.getChildren().add(LineComponent.builder() + .left(plugin.getPriorityNPC()[i-1].getName()) + .right(plugin.getPriorityNPC()[i-1].getAttackstyle().getName()) + .rightColor(plugin.getPriorityNPC()[i-1].getAttackstyle().getColor()) + .build()); + } + } + + return panelComponent.render(graphics); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java new file mode 100644 index 0000000000..250f63d244 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java @@ -0,0 +1,161 @@ +package net.runelite.client.plugins.inferno; + +import java.awt.Color; +import lombok.Getter; +import lombok.Setter; +import net.runelite.api.NPC; +import net.runelite.api.NpcID; + +public class InfernoNPC +{ + public enum Attackstyle + { + MAGE("Mage", Color.CYAN), + RANGE("Range", Color.GREEN), + MELEE("Melee", Color.WHITE), + RANDOM("Random", Color.ORANGE); + + @Getter + private String name = ""; + + @Getter + private Color color; + + Attackstyle(String s, Color c) + { + this.name = s; + this.color = c; + } + } + + @Getter + private NPC npc; + + @Getter + private String name; + + @Getter + @Setter + private Attackstyle attackstyle; + + @Getter + private int attackTicks; + + @Getter + private int priority; + + @Getter + @Setter + private int ticksTillAttack = -1; + + @Getter + @Setter + private boolean attacking = false; + + @Getter + private int attackAnimation; + + @Getter + private boolean isMidAttack = false; + + @Getter + @Setter + private int distanceToPlayer = 0; + + @Getter + int textLocHeight; + + public InfernoNPC(NPC npc) + { + this.npc = npc; + textLocHeight = npc.getLogicalHeight() + 40; + switch (npc.getId()) + { + case NpcID.JALAKREKKET: + attackTicks = 4; + name = "lil mel"; + attackAnimation = 7582; + attackstyle = Attackstyle.MELEE; + priority = 7; + break; + + case NpcID.JALAKREKXIL: + attackTicks = 4; + name = "lil range"; + attackAnimation = 7583; + attackstyle = Attackstyle.RANGE; + priority = 6; + break; + + case NpcID.JALAKREKMEJ: + attackTicks = 4; + name = "lil mage"; + attackAnimation = 7581; + attackstyle = Attackstyle.MAGE; + priority = 5; + break; + + case NpcID.JALMEJRAH: + attackTicks = 3; + name = "bat"; + attackAnimation = 7578; + attackstyle = Attackstyle.RANGE; + priority = 4; + break; + + case NpcID.JALAK: + attackTicks = 6; + name = "blob"; + attackAnimation = 7583; // also 7581 + attackstyle = Attackstyle.RANDOM; + priority = 3; + break; + + case NpcID.JALIMKOT: + attackTicks = 4; + name = "meleer"; + attackAnimation = 7597; + attackstyle = Attackstyle.MELEE; + priority = 2; + break; + + case NpcID.JALXIL: + attackTicks = 4; + name = "ranger"; + attackAnimation = 7605; + attackstyle = Attackstyle.RANGE; + priority = 1; + break; + + case NpcID.JALZEK: + attackTicks = 4; + name = "mager"; + attackAnimation = 7610; + attackstyle = Attackstyle.MAGE; + priority = 0; + break; + + default: + attackTicks = 0; + } + } + + public String info() + { + String info = ""; + + if (attacking) + { + info += ticksTillAttack; + } + //info += " D: " + distanceToPlayer; + + return info; + } + + public void attacked() + { + ticksTillAttack = attackTicks; + attacking = true; + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java new file mode 100644 index 0000000000..e11dac5bfe --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java @@ -0,0 +1,47 @@ +package net.runelite.client.plugins.inferno; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.components.LineComponent; +import net.runelite.client.ui.overlay.components.PanelComponent; + +public class InfernoNibberOverlay extends Overlay +{ + private final Client client; + private final InfernoPlugin plugin; + private final InfernoConfig config; + + private final PanelComponent panelComponent = new PanelComponent(); + + @Inject + public InfernoNibberOverlay(Client client, InfernoConfig config, InfernoPlugin plugin) + { + this.client = client; + this.config = config; + this.plugin = plugin; + setPosition(OverlayPosition.TOP_LEFT); + } + + + @Override + public Dimension render(Graphics2D graphics) + { + if (!config.displayNibbaOverlay() || plugin.getNibbers().size() == 0 || client.getMapRegions()[0] != 9043) + return null; + + panelComponent.getChildren().clear(); + + panelComponent.getChildren().add(LineComponent.builder() + .left("Nibbas Left: ") + .right(Integer.toString(plugin.getNibbers().size())) + .leftColor(Color.BLUE) + .build()); + + return panelComponent.render(graphics); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java new file mode 100644 index 0000000000..7901f5e321 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java @@ -0,0 +1,85 @@ +package net.runelite.client.plugins.inferno; + +import com.google.common.base.Strings; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics2D; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.NPC; +import net.runelite.api.Perspective; +import net.runelite.api.Point; +import net.runelite.api.coords.LocalPoint; +import net.runelite.client.ui.overlay.Overlay; + +import net.runelite.client.ui.overlay.OverlayLayer; +import net.runelite.client.ui.overlay.OverlayPosition; +import net.runelite.client.ui.overlay.components.PanelComponent; + +public class InfernoOverlay extends Overlay +{ + private final Client client; + private final InfernoPlugin plugin; + private final InfernoConfig config; + private final PanelComponent panelComponent = new PanelComponent(); + + @Inject + public InfernoOverlay(Client client, InfernoConfig config, InfernoPlugin plugin) + { + setPosition(OverlayPosition.DYNAMIC); + setLayer(OverlayLayer.ABOVE_SCENE); + this.client = client; + this.config = config; + this.plugin = plugin; + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (!client.isInInstancedRegion() || client.getMapRegions()[0] != 9043) return null; + + for (InfernoNPC monster : plugin.getMonsters().values()) + { + NPC npc = monster.getNpc(); + //if (npc == null || !config.showPrayer()) return; + LocalPoint lp = npc.getLocalLocation(); + if (lp != null) + { + Point point = Perspective.localToCanvas(client, lp, client.getPlane(), npc.getLogicalHeight()); + if (point != null) + { + if (monster.getTicksTillAttack() == 1 || (monster.getName().equals("blob") && monster.getTicksTillAttack() <= 3)) + { + renderTextLocation(graphics, monster, monster.info(), Color.GREEN); + } + else + { + renderTextLocation(graphics, monster, monster.info(), Color.RED); + } + } + } + } + return null; + } + + // renders text location + public static void renderTextLocation(Graphics2D graphics, InfernoNPC actor, String text, Color color) + { + graphics.setFont(new Font("Arial", Font.BOLD, 15)); + Point textLocation = actor.getNpc().getCanvasTextLocation(graphics, text, actor.textLocHeight + 40); + if (Strings.isNullOrEmpty(text)) + { + return; + } + + int x = textLocation.getX(); + int y = textLocation.getY(); + + graphics.setColor(Color.BLACK); + graphics.drawString(text, x + 1, y + 1); + + graphics.setColor(color); + graphics.drawString(text, x, y); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java new file mode 100644 index 0000000000..548455749d --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java @@ -0,0 +1,249 @@ +package net.runelite.client.plugins.inferno; + +import com.google.inject.Provides; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.inject.Inject; +import lombok.Getter; +import net.runelite.api.Client; +import net.runelite.api.HeadIcon; +import net.runelite.api.NPC; +import net.runelite.api.NpcID; +import net.runelite.api.events.GameTick; +import net.runelite.api.events.NpcDespawned; +import net.runelite.api.events.NpcSpawned; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.ui.overlay.OverlayManager; + +@PluginDescriptor( + name = "Inferno", + description = "Inferno helper", + tags = {"combat", "overlay", "pve", "pvm"} +) +public class InfernoPlugin extends Plugin +{ + + @Inject + private Client client; + + @Inject + private OverlayManager overlayManager; + + @Inject + private InfernoOverlay infernoOverlay; + + @Inject + private InfernoInfobox infernoInfobox; + + @Inject + private InfernoNibberOverlay nibberOverlay; + + @Inject + private InfernoConfig config; + + @Getter + private Map monsters; + + @Getter + private Map> monsterCurrentAttackMap; + + @Getter + private List nibbers; + + @Getter + private InfernoNPC[] priorityNPC; + + @Provides + InfernoConfig provideConfig(ConfigManager configManager) + { + return configManager.getConfig(InfernoConfig.class); + } + + @Override + protected void startUp() throws Exception + { + overlayManager.add(infernoOverlay); + overlayManager.add(infernoInfobox); + overlayManager.add(nibberOverlay); + monsters = new HashMap<>(); + monsterCurrentAttackMap = new HashMap<>(6); + for (int i = 1; i <= 6; i++) + { + monsterCurrentAttackMap.put(i, new ArrayList<>()); + } + nibbers = new ArrayList<>(); + priorityNPC = new InfernoNPC[4]; + } + + @Override + protected void shutDown() throws Exception + { + overlayManager.remove(infernoInfobox); + overlayManager.remove(infernoOverlay); + overlayManager.remove(nibberOverlay); + } + + @Subscribe + public void onNpcSpawned(NpcSpawned event) + { + if (client.getMapRegions()[0] != 9043) return; + + NPC npc = event.getNpc(); + if (isValidInfernoMob(npc)) + { + monsters.put(npc, new InfernoNPC(npc)); + System.out.println(monsters.size()); + } + if (npc.getId() == NpcID.JALNIB) + { + nibbers.add(npc); + } + } + + @Subscribe + public void onNpcDespawned(NpcDespawned event) + { + if (client.getMapRegions()[0] != 9043) return; + + NPC npc = event.getNpc(); + if (monsters.containsKey(npc)) + { + monsters.remove(npc); + System.out.println(monsters.size()); + } + + if (npc.getId() == NpcID.JALNIB) + { + nibbers.remove(npc); + } + } + + @Subscribe + public void onGameTick(GameTick event) + { + if (client.getMapRegions()[0] != 9043) return; + + clearMapAndPriority(); + + for (InfernoNPC monster : monsters.values()) + { + calculateDistanceToPlayer(monster); + + NPC npc = monster.getNpc(); + + // if they are not attacking but are still attacking + if (monster.isAttacking()) + { + monster.setTicksTillAttack(monster.getTicksTillAttack() - 1); + + // sets the blobs attack style + if (monster.getName().equals("blob") && monster.getTicksTillAttack() == 3 && monster.getDistanceToPlayer() <= 15) + { + if (client.getLocalPlayer().getOverheadIcon() == null) + { + monster.setAttackstyle(InfernoNPC.Attackstyle.RANDOM); + } + else if (client.getLocalPlayer().getOverheadIcon().equals(HeadIcon.MAGIC)) + { + monster.setAttackstyle(InfernoNPC.Attackstyle.RANGE); + } + else if (client.getLocalPlayer().getOverheadIcon().equals(HeadIcon.RANGED)) + { + monster.setAttackstyle(InfernoNPC.Attackstyle.MAGE); + } + } + + // we know the monster is not attacking because it should have attacked and is idling + if (monster.getTicksTillAttack() == 0) + { + if (npc.getAnimation() == -1) + { + monster.setAttacking(false); + } + else + { + // want to reset the monsters attack back to attacking + monster.attacked(); + } + } + } + else + { + // they've just attacked + if (npc.getAnimation() == monster.getAttackAnimation() || npc.getAnimation() == 7581) // special case for blob + { + monster.attacked(); + } + } + + if (monster.getTicksTillAttack() >= 1) + { + monsterCurrentAttackMap.get(monster.getTicksTillAttack()).add(monster); + } + } + + calculatePriorityNPC(); + } + + private void calculatePriorityNPC() + { + for (int i = 0; i < priorityNPC.length; i++) + { + ArrayList monsters = monsterCurrentAttackMap.get(i+1); + + if (monsters.size() == 0) continue; + + int priority = monsters.get(0).getPriority(); + + InfernoNPC infernoNPC = monsters.get(0); + + for (InfernoNPC npc : monsters) + { + if (npc.getPriority() < priority) + { + priority = npc.getPriority(); + infernoNPC = npc; + } + } + priorityNPC[i] = infernoNPC; + System.out.println("i: " + i + " " + infernoNPC.getName()); + } + } + + // TODO: blob calculator + private void calculateDistanceToPlayer(InfernoNPC monster) + { + monster.setDistanceToPlayer(client.getLocalPlayer().getWorldLocation().distanceTo(monster.getNpc().getWorldArea())); + } + + private void clearMapAndPriority() + { + for (List l : monsterCurrentAttackMap.values()) + { + l.clear(); + } + + for (int i = 0; i < priorityNPC.length; i++) + { + priorityNPC[i] = null; + } + } + + public boolean isValidInfernoMob(NPC npc) + { + // we only want the bat, blob, melee, ranger and mager + if (npc.getId() == NpcID.JALMEJRAH || + npc.getId() == NpcID.JALAK || + npc.getId() == NpcID.JALIMKOT || + npc.getId() == NpcID.JALXIL || + npc.getId() == NpcID.JALZEK) return true; + + return false; + } + +} From 248b238e9d1350e6344521884c8ee43989e5f1f5 Mon Sep 17 00:00:00 2001 From: James Munson Date: Sun, 9 Jun 2019 23:53:03 -0700 Subject: [PATCH 36/63] Updated inferno plugin --- .../client/plugins/inferno/InfernoConfig.java | 6 +++--- .../plugins/inferno/InfernoInfobox.java | 19 ++++++++----------- .../plugins/inferno/InfernoNibberOverlay.java | 14 +++++++------- .../client/plugins/inferno/InfernoPlugin.java | 4 ++-- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java index 24132a037a..10869a3301 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java @@ -33,9 +33,9 @@ public interface InfernoConfig extends Config { @ConfigItem( position = 0, - keyName = "Nibber Overlay", - name = "Nibber Overlay", - description = "Shows if there are any nibbas left" + keyName = "Player Overlay", + name = "Player Overlay", + description = "Shows if there are any players left" ) default boolean displayNibbaOverlay() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java index 7edf69cced..5273e719fd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java @@ -6,7 +6,8 @@ import javax.inject.Inject; import net.runelite.api.Client; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.LineComponent; +import net.runelite.client.ui.overlay.components.table.TableAlignment; +import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.ui.overlay.components.PanelComponent; public class InfernoInfobox extends Overlay @@ -32,26 +33,22 @@ public class InfernoInfobox extends Overlay if (!config.showPrayerHelp() || client.getMapRegions()[0] != 9043) return null; panelComponent.getChildren().clear(); + TableComponent tableComponent = new TableComponent(); + tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT); for (int i = plugin.getPriorityNPC().length; i > 0; i--) { - if (plugin.getPriorityNPC()[i-1] == null) + if (plugin.getPriorityNPC()[i - 1] == null) { - panelComponent.getChildren().add(LineComponent.builder() - .left(Integer.toString(i)) - .right("-") - .build()); + tableComponent.addRow(Integer.toString(i), "-"); } else { - panelComponent.getChildren().add(LineComponent.builder() - .left(plugin.getPriorityNPC()[i-1].getName()) - .right(plugin.getPriorityNPC()[i-1].getAttackstyle().getName()) - .rightColor(plugin.getPriorityNPC()[i-1].getAttackstyle().getColor()) - .build()); + tableComponent.addRow(plugin.getPriorityNPC()[i - 1].getName(), plugin.getPriorityNPC()[i - 1 ].getAttackstyle().getName()); } } + panelComponent.getChildren().add(tableComponent); return panelComponent.render(graphics); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java index e11dac5bfe..44a615900d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java @@ -1,14 +1,14 @@ package net.runelite.client.plugins.inferno; -import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; import net.runelite.api.Client; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; -import net.runelite.client.ui.overlay.components.LineComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +import net.runelite.client.ui.overlay.components.table.TableAlignment; +import net.runelite.client.ui.overlay.components.table.TableComponent; public class InfernoNibberOverlay extends Overlay { @@ -35,12 +35,12 @@ public class InfernoNibberOverlay extends Overlay return null; panelComponent.getChildren().clear(); + TableComponent tableComponent = new TableComponent(); + tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT); - panelComponent.getChildren().add(LineComponent.builder() - .left("Nibbas Left: ") - .right(Integer.toString(plugin.getNibbers().size())) - .leftColor(Color.BLUE) - .build()); + tableComponent.addRow("Players Left: ", Integer.toString(plugin.getNibbers().size())); + + panelComponent.getChildren().add(tableComponent); return panelComponent.render(graphics); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java index 548455749d..c8f4c15bbb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java @@ -194,9 +194,9 @@ public class InfernoPlugin extends Plugin { for (int i = 0; i < priorityNPC.length; i++) { - ArrayList monsters = monsterCurrentAttackMap.get(i+1); + ArrayList monsters = monsterCurrentAttackMap.get(i + 1); - if (monsters.size() == 0) continue; + if ( monsters.size() == 0) continue; int priority = monsters.get(0).getPriority(); From 0a3330bfa532e6dabc3c4054b43d2551981f4095 Mon Sep 17 00:00:00 2001 From: zeruth Date: Mon, 10 Jun 2019 03:30:42 -0400 Subject: [PATCH 37/63] Various --- .../src/main/java/net/runelite/client/RuneLite.java | 2 +- .../net/runelite/client/plugins/inferno/InfernoPlugin.java | 4 +++- .../java/net/runelite/client/ui/RuneLiteSplashScreen.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLite.java b/runelite-client/src/main/java/net/runelite/client/RuneLite.java index 5e47876079..3f28b3bf8d 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLite.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLite.java @@ -83,7 +83,7 @@ import org.slf4j.LoggerFactory; @Slf4j public class RuneLite { - public static final String RUNELIT_VERSION = "0.1.2"; + public static final String RUNELIT_VERSION = "2.0.0"; 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 PLUGIN_DIR = new File(RUNELITE_DIR, "plugins"); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java index c8f4c15bbb..ac1905dac6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java @@ -18,12 +18,14 @@ import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.PluginType; import net.runelite.client.ui.overlay.OverlayManager; @PluginDescriptor( name = "Inferno", description = "Inferno helper", - tags = {"combat", "overlay", "pve", "pvm"} + tags = {"combat", "overlay", "pve", "pvm"}, + type = PluginType.PVM ) public class InfernoPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/ui/RuneLiteSplashScreen.java b/runelite-client/src/main/java/net/runelite/client/ui/RuneLiteSplashScreen.java index 9b124b2d5d..8dbc86a701 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/RuneLiteSplashScreen.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/RuneLiteSplashScreen.java @@ -130,7 +130,7 @@ public class RuneLiteSplashScreen panel.add(version, versionConstraints); // version - final JLabel litVersion = new JLabel("Plus Version : PRE-" + RuneLite.RUNELIT_VERSION); + final JLabel litVersion = new JLabel("Plus Version : " + RuneLite.RUNELIT_VERSION); litVersion.setForeground(Color.GREEN); litVersion.setFont(FontManager.getRunescapeSmallFont()); litVersion.setForeground(litVersion.getForeground().darker()); From 766005f725ebb62ab72df13f78d5d6f58f096b2b Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 10 Jun 2019 17:44:26 +1000 Subject: [PATCH 38/63] added copyright to inferno changed 'Players' to 'Nibblers' --- .../plugins/inferno/InfernoInfobox.java | 24 +++++++++++++++++ .../client/plugins/inferno/InfernoNPC.java | 24 +++++++++++++++++ .../plugins/inferno/InfernoNibberOverlay.java | 26 ++++++++++++++++++- .../plugins/inferno/InfernoOverlay.java | 24 +++++++++++++++++ .../client/plugins/inferno/InfernoPlugin.java | 24 +++++++++++++++++ 5 files changed, 121 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java index 5273e719fd..12b4571b09 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java @@ -1,3 +1,27 @@ +/* + * Copyright (c) 2019, Jacky + * 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.plugins.inferno; import java.awt.Dimension; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java index 250f63d244..392ec4bad6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java @@ -1,3 +1,27 @@ +/* + * Copyright (c) 2019, Jacky + * 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.plugins.inferno; import java.awt.Color; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java index 44a615900d..6e2468eb32 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibberOverlay.java @@ -1,3 +1,27 @@ +/* + * Copyright (c) 2019, Jacky + * 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.plugins.inferno; import java.awt.Dimension; @@ -38,7 +62,7 @@ public class InfernoNibberOverlay extends Overlay TableComponent tableComponent = new TableComponent(); tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT); - tableComponent.addRow("Players Left: ", Integer.toString(plugin.getNibbers().size())); + tableComponent.addRow("Nibblers Left: ", Integer.toString(plugin.getNibbers().size())); panelComponent.getChildren().add(tableComponent); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java index 7901f5e321..dde2a01a9f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java @@ -1,3 +1,27 @@ +/* + * Copyright (c) 2019, Jacky + * 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.plugins.inferno; import com.google.common.base.Strings; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java index ac1905dac6..e0d9741aa4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java @@ -1,3 +1,27 @@ +/* + * Copyright (c) 2019, Jacky + * 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.plugins.inferno; import com.google.inject.Provides; From 28310ed977be908965cd8d5725221d7b37abab79 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 10 Jun 2019 14:58:22 +0200 Subject: [PATCH 39/63] Add menu raw injector --- .../main/java/net/runelite/asm/Method.java | 11 +- .../src/main/java/net/runelite/deob/Deob.java | 107 ++++---- .../deobfuscators/StaticShouldBeInstance.java | 171 +++++++++++++ .../transformers/OpcodesTransformer.java | 2 +- .../runelite/deob/updater/UpdateMappings.java | 42 +++- .../net/runelite/deob/ClassGroupFactory.java | 6 +- .../java/net/runelite/injector/Inject.java | 3 + .../runelite/injector/InjectConstruct.java | 4 +- .../net/runelite/injector/InjectGetter.java | 8 +- .../net/runelite/injector/InjectHook.java | 14 +- .../runelite/injector/InjectHookMethod.java | 4 +- .../net/runelite/injector/InjectInvoker.java | 8 +- .../net/runelite/injector/InjectSetter.java | 9 +- .../net/runelite/injector/InjectUtil.java | 130 ++++++++++ .../java/net/runelite/injector/Injector.java | 2 +- .../runelite/injector/InjectorValidator.java | 12 +- .../net/runelite/injector/MixinInjector.java | 27 +- .../injector/raw/ClearColorBuffer.java | 28 +-- .../injector/raw/DrawAfterWidgets.java | 27 +- .../net/runelite/injector/raw/DrawMenu.java | 230 +++++++----------- .../runelite/injector/raw/RasterizerHook.java | 73 +----- .../net/runelite/injector/raw/RenderDraw.java | 27 +- .../net/runelite/injector/raw/ScriptVM.java | 71 +----- 23 files changed, 546 insertions(+), 470 deletions(-) create mode 100644 deobfuscator/src/main/java/net/runelite/deob/deobfuscators/StaticShouldBeInstance.java create mode 100644 injector-plugin/src/main/java/net/runelite/injector/InjectUtil.java diff --git a/deobfuscator/src/main/java/net/runelite/asm/Method.java b/deobfuscator/src/main/java/net/runelite/asm/Method.java index bc2c8b305b..e8cbdef92b 100644 --- a/deobfuscator/src/main/java/net/runelite/asm/Method.java +++ b/deobfuscator/src/main/java/net/runelite/asm/Method.java @@ -203,9 +203,16 @@ public class Method return (accessFlags & ACC_STATIC) != 0; } - public void setStatic() + public void setStatic(boolean s) { - accessFlags |= ACC_STATIC; + if (s) + { + accessFlags |= ACC_STATIC; + } + else + { + accessFlags &= ~ACC_STATIC; + } } public boolean isSynchronized() diff --git a/deobfuscator/src/main/java/net/runelite/deob/Deob.java b/deobfuscator/src/main/java/net/runelite/deob/Deob.java index 8f37a9b167..e46bdfbe20 100644 --- a/deobfuscator/src/main/java/net/runelite/deob/Deob.java +++ b/deobfuscator/src/main/java/net/runelite/deob/Deob.java @@ -27,14 +27,10 @@ package net.runelite.deob; import com.google.common.base.Stopwatch; import java.io.File; import java.io.IOException; -import net.runelite.asm.ClassFile; import net.runelite.asm.ClassGroup; -import net.runelite.asm.Field; -import net.runelite.asm.Method; -import net.runelite.asm.Type; -import net.runelite.asm.attributes.Annotations; import net.runelite.asm.execution.Execution; import net.runelite.deob.deobfuscators.CastNull; +import net.runelite.deob.deobfuscators.StaticShouldBeInstance; import net.runelite.deob.deobfuscators.constparam.ConstantParameter; import net.runelite.deob.deobfuscators.EnumDeobfuscator; import net.runelite.deob.deobfuscators.FieldInliner; @@ -85,85 +81,70 @@ public class Deob ClassGroup group = JarUtil.loadJar(new File(args[0])); - for (ClassFile f : group.getClasses()) + if (args.length > 2 && args[2].equals("rl")) { - f.getAnnotations().clearAnnotations(); - for (Method m : f.getMethods()) - { - Annotations an = m.getAnnotations(); - an.clearAnnotations(); - } - for (Field fi : f.getFields()) - { - Annotations an = fi.getAnnotations(); - if (an.find(new Type("Ljavax/inject/Inject;")) == null) - { - an.clearAnnotations(); - } - else - { - logger.info("Class {}, field {} has inject", f.getClassName(), fi.getName()); - } - } + run(group, new StaticShouldBeInstance()); } + else + { + // remove except RuntimeException + run(group, new RuntimeExceptions()); - // remove except RuntimeException - run(group, new RuntimeExceptions()); + run(group, new ControlFlowDeobfuscator()); - run(group, new ControlFlowDeobfuscator()); + run(group, new RenameUnique()); - run(group, new RenameUnique()); + // remove unused methods - this leaves Code with no instructions, + // which is not valid, so unused methods is run after + run(group, new UnreachedCode()); + run(group, new UnusedMethods()); - // remove unused methods - this leaves Code with no instructions, - // which is not valid, so unused methods is run after - run(group, new UnreachedCode()); - run(group, new UnusedMethods()); + // remove illegal state exceptions, frees up some parameters + run(group, new IllegalStateExceptions()); - // remove illegal state exceptions, frees up some parameters - run(group, new IllegalStateExceptions()); + // remove constant logically dead parameters + run(group, new ConstantParameter()); - // remove constant logically dead parameters - run(group, new ConstantParameter()); + // remove unhit blocks + run(group, new UnreachedCode()); + run(group, new UnusedMethods()); - // remove unhit blocks - run(group, new UnreachedCode()); - run(group, new UnusedMethods()); + // remove unused parameters + run(group, new UnusedParameters()); - // remove unused parameters - run(group, new UnusedParameters()); + // remove unused fields + run(group, new UnusedFields()); - // remove unused fields - run(group, new UnusedFields()); + run(group, new FieldInliner()); - run(group, new FieldInliner()); + // order uses class name order for sorting fields/methods, + // so run it before removing classes below + run(group, new Order()); - // order uses class name order for sorting fields/methods, - // so run it before removing classes below - run(group, new Order()); + run(group, new UnusedClass()); - run(group, new UnusedClass()); + runMath(group); - runMath(group); + run(group, new ExprArgOrder()); - run(group, new ExprArgOrder()); + run(group, new Lvt()); - run(group, new Lvt()); + run(group, new CastNull()); - run(group, new CastNull()); + run(group, new EnumDeobfuscator()); - run(group, new EnumDeobfuscator()); + new OpcodesTransformer().transform(group); + //run(group, new PacketHandlerOrder()); + //run(group, new PacketWriteDeobfuscator()); - new OpcodesTransformer().transform(group); - //run(group, new PacketHandlerOrder()); - //run(group, new PacketWriteDeobfuscator()); + run(group, new MenuActionDeobfuscator()); - run(group, new MenuActionDeobfuscator()); - - new GetPathTransformer().transform(group); - new ClientErrorTransformer().transform(group); - new ReflectionTransformer().transform(group); - new MaxMemoryTransformer().transform(group); - //new RuneliteBufferTransformer().transform(group); + new GetPathTransformer().transform(group); + new ClientErrorTransformer().transform(group); + new ReflectionTransformer().transform(group); + new MaxMemoryTransformer().transform(group); + //new RuneliteBufferTransformer().transform(group); + } JarUtil.saveJar(group, new File(args[1])); diff --git a/deobfuscator/src/main/java/net/runelite/deob/deobfuscators/StaticShouldBeInstance.java b/deobfuscator/src/main/java/net/runelite/deob/deobfuscators/StaticShouldBeInstance.java new file mode 100644 index 0000000000..1cae903698 --- /dev/null +++ b/deobfuscator/src/main/java/net/runelite/deob/deobfuscators/StaticShouldBeInstance.java @@ -0,0 +1,171 @@ +package net.runelite.deob.deobfuscators; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import net.runelite.asm.ClassFile; +import net.runelite.asm.ClassGroup; +import net.runelite.asm.Field; +import net.runelite.asm.Type; +import net.runelite.asm.attributes.Annotations; +import net.runelite.asm.attributes.Code; +import net.runelite.asm.attributes.code.Instruction; +import net.runelite.asm.attributes.code.Instructions; +import net.runelite.asm.attributes.code.instruction.types.ReturnInstruction; +import net.runelite.asm.attributes.code.instructions.InvokeStatic; +import net.runelite.asm.attributes.code.instructions.InvokeVirtual; +import net.runelite.asm.pool.Method; +import net.runelite.asm.signature.Signature; +import net.runelite.deob.Deobfuscator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class StaticShouldBeInstance implements Deobfuscator +{ + private static final Logger logger = LoggerFactory.getLogger(StaticShouldBeInstance.class); + private static Map methods = new HashMap<>(); + + public void run(ClassGroup group) + { + int replacedCalls = 0; + int removedInstructions = 0; + int removedMethods = 0; + int removedAnnotations = 0; + List obfuscatedMethods = new ArrayList<>(); + + for (ClassFile cf : group.getClasses()) + { + // Remove unused annotations + Annotations a = cf.getAnnotations(); + removedAnnotations += a.getAnnotations().size(); + a.clearAnnotations(); + + Type type = new Type('L' + cf.getClassName() + ';'); + obfuscatedMethods.clear(); + + for (net.runelite.asm.Method m : cf.getMethods()) + { + // Remove unused annotations + a = m.getAnnotations(); + removedAnnotations += a.size(); + a.clearAnnotations(); + + if (m.isStatic() && m.getCode() != null) + { + if (checkIfObf(m, type, cf)) + { + removedMethods++; + obfuscatedMethods.add(m); + } + } + } + + + for (net.runelite.asm.Method m : obfuscatedMethods) + { + Signature sig = m.getDescriptor(); + Signature.Builder builder = new Signature.Builder(); + builder.setReturnType(sig.getReturnValue()); + if (sig.getArguments().size() > 1) + { + builder.addArguments(sig.getArguments().subList(1, sig.getArguments().size())); + } + + Signature toFind = builder.build(); + + net.runelite.asm.Method notStatic = cf.findMethod(m.getName(), toFind); + net.runelite.asm.pool.Method oldPool = m.getPoolMethod(); + cf.removeMethod(notStatic); + + m.setDescriptor(toFind); + m.setStatic(false); + Code c = m.getCode(); + Instructions ins = c.getInstructions(); + int startLength = ins.getInstructions().size(); + ListIterator it = ins.getInstructions().listIterator(); + assert it.hasNext(); + Instruction i = it.next(); + while (!(i instanceof ReturnInstruction)) + { + it.remove(); + i = it.next(); + } + it.remove(); + net.runelite.asm.pool.Method newPool = m.getPoolMethod(); + + methods.put(oldPool, newPool); + + removedInstructions += startLength - ins.getInstructions().size(); + } + + for (Field fi : cf.getFields()) + { + a = fi.getAnnotations(); + if (a.find(new Type("Ljavax/inject/Inject;")) == null) + { + removedAnnotations += a.size(); + a.clearAnnotations(); + } + else + { + logger.info("Class {}, field {} has inject", cf.getClassName(), fi.getName()); + } + } + } + + for (ClassFile cf : group.getClasses()) + { + for (net.runelite.asm.Method m : cf.getMethods()) + { + if (m.getCode() == null) + { + continue; + } + + Instructions ins = m.getCode().getInstructions(); + List instructions = ins.getInstructions(); + for (int i1 = 0, instructionsSize = instructions.size(); i1 < instructionsSize; i1++) + { + Instruction i = instructions.get(i1); + if (!(i instanceof InvokeStatic)) + { + continue; + } + + if (methods.containsKey(((InvokeStatic) i).getMethod())) + { + InvokeVirtual invoke = new InvokeVirtual(ins, methods.get(((InvokeStatic) i).getMethod())); + ins.replace(i, invoke); + replacedCalls++; + } + } + } + } + + logger.info("Made {} methods not static, removed {} instructions, replaced {} invokes, and removed {} annotations", removedMethods, removedInstructions, replacedCalls, removedAnnotations); + } + + private static boolean checkIfObf(net.runelite.asm.Method m, Type type, ClassFile cf) + { + Signature sig = m.getDescriptor(); + if (sig.getArguments().size() < 1 || !sig.getTypeOfArg(0).equals(type)) + { + return false; + } + + Signature.Builder builder = new Signature.Builder(); + builder.setReturnType(sig.getReturnValue()); + if (sig.getArguments().size() > 1) + { + builder.addArguments(sig.getArguments().subList(1, sig.getArguments().size())); + } + + Signature toFind = builder.build(); + + net.runelite.asm.Method notStatic = cf.findMethod(m.getName(), toFind); + + return notStatic != null; + } +} diff --git a/deobfuscator/src/main/java/net/runelite/deob/deobfuscators/transformers/OpcodesTransformer.java b/deobfuscator/src/main/java/net/runelite/deob/deobfuscators/transformers/OpcodesTransformer.java index 15f9eae248..d515c3bcd4 100644 --- a/deobfuscator/src/main/java/net/runelite/deob/deobfuscators/transformers/OpcodesTransformer.java +++ b/deobfuscator/src/main/java/net/runelite/deob/deobfuscators/transformers/OpcodesTransformer.java @@ -60,7 +60,7 @@ public class OpcodesTransformer implements Transformer if (clinit == null) { clinit = new Method(runeliteOpcodes, "", new Signature("()V")); - clinit.setStatic(); + clinit.setStatic(true); Code code = new Code(clinit); code.setMaxStack(1); clinit.setCode(code); diff --git a/deobfuscator/src/main/java/net/runelite/deob/updater/UpdateMappings.java b/deobfuscator/src/main/java/net/runelite/deob/updater/UpdateMappings.java index 0df369e8ad..db6ed0ef1c 100644 --- a/deobfuscator/src/main/java/net/runelite/deob/updater/UpdateMappings.java +++ b/deobfuscator/src/main/java/net/runelite/deob/updater/UpdateMappings.java @@ -26,19 +26,24 @@ package net.runelite.deob.updater; import java.io.File; import java.io.IOException; +import java.util.Map; import net.runelite.asm.ClassGroup; +import net.runelite.asm.Field; +import net.runelite.asm.Method; +import net.runelite.deob.deobfuscators.Renamer; import net.runelite.deob.deobfuscators.mapping.AnnotationIntegrityChecker; import net.runelite.deob.deobfuscators.mapping.AnnotationMapper; import net.runelite.deob.deobfuscators.mapping.Mapper; import net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping; import net.runelite.deob.util.JarUtil; +import net.runelite.deob.util.NameMappings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class UpdateMappings { private static final Logger logger = LoggerFactory.getLogger(UpdateMappings.class); - + private static boolean renameRL = true; private final ClassGroup group1, group2; public UpdateMappings(ClassGroup group1, ClassGroup group2) @@ -74,6 +79,32 @@ public class UpdateMappings pr.run(); } + public void updateRL() + { + Mapper mapper = new Mapper(group1, group2); + mapper.run(); + ParallelExecutorMapping mapping = mapper.getMapping(); + NameMappings names = new NameMappings(); + + for (Map.Entry e : mapping.getMap().entrySet()) + { + Object k = e.getKey(); + Object v = e.getValue(); + + if (k instanceof Field) + { + names.map(((Field) v).getPoolField(), ((Field) k).getName()); + } + else if (k instanceof Method) + { + names.map(((Method) v).getPoolMethod(), ((Method) k).getName()); + } + } + + Renamer renamer = new Renamer(names); + renamer.run(group2); + } + public void save(File out) throws IOException { JarUtil.saveJar(group2, out); @@ -90,7 +121,14 @@ public class UpdateMappings JarUtil.loadJar(new File(args[0])), JarUtil.loadJar(new File(args[1])) ); - u.update(); + if (renameRL) + { + u.updateRL(); + } + else + { + u.update(); + } u.save(new File(args[2])); } } diff --git a/deobfuscator/src/test/java/net/runelite/deob/ClassGroupFactory.java b/deobfuscator/src/test/java/net/runelite/deob/ClassGroupFactory.java index 6faef99743..3c2a5bebf9 100644 --- a/deobfuscator/src/test/java/net/runelite/deob/ClassGroupFactory.java +++ b/deobfuscator/src/test/java/net/runelite/deob/ClassGroupFactory.java @@ -39,7 +39,7 @@ public class ClassGroupFactory private static void addVoidMethod(ClassFile cf, String name) { Method method = new Method(cf, name, new Signature("()V")); - method.setStatic(); + method.setStatic(true); cf.addMethod(method); Code code = new Code(method); @@ -63,7 +63,7 @@ public class ClassGroupFactory cf.addField(field); Method method = new Method(cf, "func", new Signature("()V")); - method.setStatic(); + method.setStatic(true); cf.addMethod(method); Code code = new Code(method); @@ -71,7 +71,7 @@ public class ClassGroupFactory { method = new Method(cf, "func2", new Signature("(III)V")); - method.setStatic(); + method.setStatic(true); cf.addMethod(method); code = new Code(method); diff --git a/injector-plugin/src/main/java/net/runelite/injector/Inject.java b/injector-plugin/src/main/java/net/runelite/injector/Inject.java index dcc0236937..3e24a55374 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/Inject.java +++ b/injector-plugin/src/main/java/net/runelite/injector/Inject.java @@ -47,6 +47,7 @@ import net.runelite.deob.DeobAnnotations; import net.runelite.deob.deobfuscators.arithmetic.DMath; import net.runelite.injector.raw.ClearColorBuffer; import net.runelite.injector.raw.DrawAfterWidgets; +import net.runelite.injector.raw.DrawMenu; import net.runelite.injector.raw.RasterizerHook; import net.runelite.injector.raw.RenderDraw; import net.runelite.injector.raw.ScriptVM; @@ -68,6 +69,7 @@ public class Inject private final InjectInvoker invokes = new InjectInvoker(this); private final InjectConstruct construct = new InjectConstruct(this); + private final DrawMenu drawMenu = new DrawMenu(this); private final RasterizerHook rasterizerHook = new RasterizerHook(this); private final MixinInjector mixinInjector = new MixinInjector(this); private final DrawAfterWidgets drawAfterWidgets = new DrawAfterWidgets(this); @@ -331,6 +333,7 @@ public class Inject scriptVM.inject(); clearColorBuffer.inject(); renderDraw.inject(); + drawMenu.inject(); } private java.lang.Class injectInterface(ClassFile cf, ClassFile other) diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectConstruct.java b/injector-plugin/src/main/java/net/runelite/injector/InjectConstruct.java index 88e527d405..8a87451da6 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectConstruct.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectConstruct.java @@ -54,7 +54,7 @@ public class InjectConstruct private final Inject inject; - public InjectConstruct(Inject inject) + InjectConstruct(Inject inject) { this.inject = inject; } @@ -99,7 +99,7 @@ public class InjectConstruct } } - public void injectConstruct(ClassFile targetClass, java.lang.reflect.Method apiMethod) throws InjectionException + void injectConstruct(ClassFile targetClass, java.lang.reflect.Method apiMethod) throws InjectionException { logger.info("Injecting construct for {}", apiMethod); diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectGetter.java b/injector-plugin/src/main/java/net/runelite/injector/InjectGetter.java index b9758b4f61..cd94ee80d8 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectGetter.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectGetter.java @@ -44,7 +44,7 @@ import static org.objectweb.asm.Opcodes.ACC_PUBLIC; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class InjectGetter +class InjectGetter { private static final Logger logger = LoggerFactory.getLogger(InjectGetter.class); @@ -52,12 +52,12 @@ public class InjectGetter private int injectedGetters; - public InjectGetter(Inject inject) + InjectGetter(Inject inject) { this.inject = inject; } - public void injectGetter(ClassFile clazz, java.lang.reflect.Method method, Field field, Number getter) + void injectGetter(ClassFile clazz, java.lang.reflect.Method method, Field field, Number getter) { // clazz = class file we're injecting the method into. // method = api method (java reflect) that we're overriding @@ -148,7 +148,7 @@ public class InjectGetter ++injectedGetters; } - public int getInjectedGetters() + int getInjectedGetters() { return injectedGetters; } diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java b/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java index a709d92072..19ae3a3df6 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectHook.java @@ -55,7 +55,7 @@ import net.runelite.asm.signature.Signature; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class InjectHook +class InjectHook { private static final Logger logger = LoggerFactory.getLogger(InjectHook.class); private static final String HOOK_METHOD_SIGNATURE = "(I)V"; @@ -64,7 +64,7 @@ public class InjectHook private final Map hooked = new HashMap<>(); private int injectedHooks; - public InjectHook(Inject inject) + InjectHook(Inject inject) { this.inject = inject; } @@ -74,7 +74,7 @@ public class InjectHook hooked.put(field, hookInfo); } - public void run() + void run() { Execution e = new Execution(inject.getVanilla()); e.populateInitialMethods(); @@ -129,8 +129,7 @@ public class InjectHook StackContext objectStackContext = null; if (sfi instanceof PutField) { - StackContext objectStack = ic.getPops().get(1); // Object being set on - objectStackContext = objectStack; + objectStackContext = ic.getPops().get(1); } int idx = ins.getInstructions().indexOf(sfi); @@ -206,8 +205,7 @@ public class InjectHook StackContext objectStackContext = null; if (arrayReferencePushed.getInstruction().getType() == InstructionType.GETFIELD) { - StackContext objectReference = arrayReferencePushed.getPops().get(0); - objectStackContext = objectReference; + objectStackContext = arrayReferencePushed.getPops().get(0); } // inject hook after 'i' @@ -382,7 +380,7 @@ public class InjectHook } } - public int getInjectedHooks() + int getInjectedHooks() { return injectedHooks; } diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectHookMethod.java b/injector-plugin/src/main/java/net/runelite/injector/InjectHookMethod.java index 9cd7d4326d..94303e81d3 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectHookMethod.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectHookMethod.java @@ -53,12 +53,12 @@ public class InjectHookMethod private static final Logger logger = LoggerFactory.getLogger(InjectHookMethod.class); private final Inject inject; - public InjectHookMethod(Inject inject) + InjectHookMethod(Inject inject) { this.inject = inject; } - public void process(Method method) throws InjectionException + void process(Method method) throws InjectionException { Annotations an = method.getAnnotations(); if (an == null) diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectInvoker.java b/injector-plugin/src/main/java/net/runelite/injector/InjectInvoker.java index 6b3fa13d33..1153609b8e 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectInvoker.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectInvoker.java @@ -51,7 +51,7 @@ import static org.objectweb.asm.Opcodes.ACC_PUBLIC; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class InjectInvoker +class InjectInvoker { private static final Logger logger = LoggerFactory.getLogger(InjectInvoker.class); @@ -59,7 +59,7 @@ public class InjectInvoker private int injectedInvokers; - public InjectInvoker(Inject inject) + InjectInvoker(Inject inject) { this.inject = inject; } @@ -73,7 +73,7 @@ public class InjectInvoker * @param implementingClass Java class for the API interface the class * will implement */ - public void process(Method m, ClassFile other, java.lang.Class implementingClass) + void process(Method m, ClassFile other, java.lang.Class implementingClass) { Annotations an = m.getAnnotations(); @@ -284,7 +284,7 @@ public class InjectInvoker clazz.addMethod(invokerMethodSignature); } - public int getInjectedInvokers() + int getInjectedInvokers() { return injectedInvokers; } diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectSetter.java b/injector-plugin/src/main/java/net/runelite/injector/InjectSetter.java index 6b10ab3b56..58c225fa87 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectSetter.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectSetter.java @@ -45,7 +45,7 @@ import static org.objectweb.asm.Opcodes.ACC_PUBLIC; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class InjectSetter +class InjectSetter { private static final Logger logger = LoggerFactory.getLogger(InjectSetter.class); @@ -53,7 +53,7 @@ public class InjectSetter private int injectedSetters; - public InjectSetter(Inject inject) + InjectSetter(Inject inject) { this.inject = inject; } @@ -67,9 +67,8 @@ public class InjectSetter * setter declared * @param field Field of vanilla that will be set * @param exportedName exported name of field - * @param setter */ - public void injectSetter(ClassFile targetClass, Class targetApiClass, Field field, String exportedName, Number setter) + void injectSetter(ClassFile targetClass, Class targetApiClass, Field field, String exportedName, Number setter) { java.lang.reflect.Method method = inject.findImportMethodOnApi(targetApiClass, exportedName, true); if (method == null) @@ -152,7 +151,7 @@ public class InjectSetter ins.add(new VReturn(instructions)); } - public int getInjectedSetters() + int getInjectedSetters() { return injectedSetters; } diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectUtil.java b/injector-plugin/src/main/java/net/runelite/injector/InjectUtil.java new file mode 100644 index 0000000000..e9a32a0bb0 --- /dev/null +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectUtil.java @@ -0,0 +1,130 @@ +package net.runelite.injector; + +import net.runelite.asm.ClassFile; +import net.runelite.asm.Field; +import net.runelite.asm.Method; +import net.runelite.asm.signature.Signature; +import net.runelite.deob.DeobAnnotations; + +public class InjectUtil +{ + public static Method findStaticObMethod(Inject inject, String name) throws InjectionException + { + for (ClassFile c : inject.getVanilla().getClasses()) + { + for (Method m : c.getMethods()) + { + if (!m.getName().equals(name)) + { + continue; + } + return m; + } + } + + throw new InjectionException(String.format("Method \"%s\" could not be found.", name)); + } + + public static Method findMethod(Inject inject, String name) throws InjectionException + { + for (ClassFile c : inject.getDeobfuscated().getClasses()) + { + for (Method m : c.getMethods()) + { + if (!m.getName().equals(name)) + { + continue; + } + + String obfuscatedName = DeobAnnotations.getObfuscatedName(m.getAnnotations()); + Signature obfuscatedSignature = DeobAnnotations.getObfuscatedSignature(m); + + ClassFile c2 = inject.toObClass(c); + + return c2.findMethod(obfuscatedName, (obfuscatedSignature != null) ? obfuscatedSignature : m.getDescriptor()); + } + } + + throw new InjectionException("Couldn't find method " + name); + } + + public static Method findStaticMethod(Inject inject, String name) throws InjectionException + { + for (ClassFile c : inject.getDeobfuscated().getClasses()) + { + for (Method m : c.getMethods()) + { + if (!m.isStatic() || !m.getName().equals(name)) + { + continue; + } + + String obfuscatedName = DeobAnnotations.getObfuscatedName(m.getAnnotations()); + Signature obfuscatedSignature = DeobAnnotations.getObfuscatedSignature(m); + + ClassFile c2 = inject.toObClass(c); + + return c2.findMethod(obfuscatedName, (obfuscatedSignature != null) ? obfuscatedSignature : m.getDescriptor()); + } + } + + throw new InjectionException("Couldn't find static method " + name); + } + + + public static Field findObField(Inject inject, String name) throws InjectionException + { + for (ClassFile c : inject.getVanilla().getClasses()) + { + for (Field f : c.getFields()) + { + if (!f.getName().equals(name)) + { + continue; + } + return f; + } + } + + throw new InjectionException(String.format("Field \"%s\" could not be found.", name)); + } + + public static Field findDeobField(Inject inject, String name) throws InjectionException + { + for (ClassFile c : inject.getDeobfuscated().getClasses()) + { + for (Field f : c.getFields()) + { + if (!f.getName().equals(name)) + { + continue; + } + + String obfuscatedName = DeobAnnotations.getObfuscatedName(f.getAnnotations()); + + ClassFile c2 = inject.toObClass(c); + return c2.findField(obfuscatedName); + } + } + + throw new InjectionException(String.format("Mapped field \"%s\" could not be found.", name)); + } + + public static Field findDeobFieldButUseless(Inject inject, String name) throws InjectionException + { + for (ClassFile c : inject.getDeobfuscated().getClasses()) + { + for (Field f : c.getFields()) + { + if (!f.getName().equals(name)) + { + continue; + } + + return f; + } + } + + throw new InjectionException(String.format("Mapped field \"%s\" could not be found.", name)); + } +} diff --git a/injector-plugin/src/main/java/net/runelite/injector/Injector.java b/injector-plugin/src/main/java/net/runelite/injector/Injector.java index d8b61f901b..9409b02075 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/Injector.java +++ b/injector-plugin/src/main/java/net/runelite/injector/Injector.java @@ -67,7 +67,7 @@ public class Injector instance.run(); } - public void save(File out) throws IOException + private void save(File out) throws IOException { JarUtil.saveJar(vanilla, out); } diff --git a/injector-plugin/src/main/java/net/runelite/injector/InjectorValidator.java b/injector-plugin/src/main/java/net/runelite/injector/InjectorValidator.java index f4e2cad9b9..a49df63a3a 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/InjectorValidator.java +++ b/injector-plugin/src/main/java/net/runelite/injector/InjectorValidator.java @@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory; * * @author Adam */ -public class InjectorValidator +class InjectorValidator { private static final Logger logger = LoggerFactory.getLogger(InjectorValidator.class); @@ -49,12 +49,12 @@ public class InjectorValidator private int error, missing, okay; - public InjectorValidator(ClassGroup group) + InjectorValidator(ClassGroup group) { this.group = group; } - public void validate() + void validate() { for (ClassFile cf : group.getClasses()) { @@ -131,17 +131,17 @@ public class InjectorValidator } } - public int getError() + int getError() { return error; } - public int getMissing() + int getMissing() { return missing; } - public int getOkay() + int getOkay() { return okay; } diff --git a/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java b/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java index 1547880140..815b3699aa 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java +++ b/injector-plugin/src/main/java/net/runelite/injector/MixinInjector.java @@ -87,7 +87,7 @@ public class MixinInjector // Use net.runelite.asm.pool.Field instead of Field because the pool version has hashcode implemented private final Map shadowFields = new HashMap<>(); - public MixinInjector(Inject inject) + MixinInjector(Inject inject) { this.inject = inject; } @@ -165,9 +165,6 @@ public class MixinInjector /** * Finds fields that are marked @Inject and inject them into the target - * - * @param mixinClasses - * @throws InjectionException */ private void injectFields(Map, List> mixinClasses) throws InjectionException { @@ -245,9 +242,6 @@ public class MixinInjector /** * Find fields which are marked @Shadow, and what they shadow - * - * @param mixinClasses - * @throws InjectionException */ private void findShadowFields(Map, List> mixinClasses) throws InjectionException { @@ -287,7 +281,7 @@ public class MixinInjector else { // Shadow a field already in the gamepack - Field shadowField = findDeobField(shadowName); + Field shadowField = InjectUtil.findDeobFieldButUseless(inject, shadowName); if (shadowField == null) { @@ -316,21 +310,6 @@ public class MixinInjector } } - private Field findDeobField(String name) - { - for (ClassFile cf : inject.getDeobfuscated().getClasses()) - { - for (Field f : cf.getFields()) - { - if (f.getName().equals(name) && f.isStatic()) - { - return f; - } - } - } - return null; - } - private void injectMethods(ClassFile mixinCf, ClassFile cf, Map shadowFields) throws InjectionException { @@ -901,7 +880,7 @@ public class MixinInjector if (targetField == null) { // first try non static fields, then static - targetField = findDeobField(hookName); + targetField = InjectUtil.findDeobFieldButUseless(inject, hookName); } if (targetField == null) diff --git a/injector-plugin/src/main/java/net/runelite/injector/raw/ClearColorBuffer.java b/injector-plugin/src/main/java/net/runelite/injector/raw/ClearColorBuffer.java index ffacb7f1a8..ac40a35e14 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/raw/ClearColorBuffer.java +++ b/injector-plugin/src/main/java/net/runelite/injector/raw/ClearColorBuffer.java @@ -11,8 +11,8 @@ import net.runelite.asm.attributes.code.instructions.InvokeStatic; import net.runelite.asm.attributes.code.instructions.LDC; import net.runelite.asm.pool.Class; import net.runelite.asm.signature.Signature; -import net.runelite.deob.DeobAnnotations; import net.runelite.injector.Inject; +import net.runelite.injector.InjectUtil; import net.runelite.injector.InjectionException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +39,7 @@ public class ClearColorBuffer private void injectColorBufferHooks() throws InjectionException { - net.runelite.asm.pool.Method fillRectangle = findStaticMethod("Rasterizer2D_fillRectangle").getPoolMethod(); + net.runelite.asm.pool.Method fillRectangle = InjectUtil.findStaticMethod(inject, "Rasterizer2D_fillRectangle").getPoolMethod(); int count = 0; int replaced = 0; @@ -119,28 +119,4 @@ public class ClearColorBuffer } } } - - private Method findStaticMethod(String name) throws InjectionException - { - for (ClassFile c : inject.getDeobfuscated().getClasses()) - { - for (Method m : c.getMethods()) - { - if (!m.getName().equals(name)) - { - continue; - } - - String obfuscatedName = DeobAnnotations.getObfuscatedName(m.getAnnotations()); - Signature obfuscatedSignature = DeobAnnotations.getObfuscatedSignature(m); - - ClassFile c2 = inject.toObClass(c); - - return c2.findMethod(obfuscatedName, (obfuscatedSignature != null) ? obfuscatedSignature : m.getDescriptor()); - } - } - - throw new InjectionException("Couldn't find static method " + name); - } - } \ No newline at end of file diff --git a/injector-plugin/src/main/java/net/runelite/injector/raw/DrawAfterWidgets.java b/injector-plugin/src/main/java/net/runelite/injector/raw/DrawAfterWidgets.java index ae2a3d5478..e2250b894e 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/raw/DrawAfterWidgets.java +++ b/injector-plugin/src/main/java/net/runelite/injector/raw/DrawAfterWidgets.java @@ -38,9 +38,9 @@ import net.runelite.asm.attributes.code.instructions.GetStatic; import net.runelite.asm.attributes.code.instructions.IMul; import net.runelite.asm.attributes.code.instructions.InvokeStatic; import net.runelite.asm.signature.Signature; -import net.runelite.deob.DeobAnnotations; import net.runelite.injector.Inject; import static net.runelite.injector.InjectHookMethod.HOOKS; +import static net.runelite.injector.InjectUtil.findStaticMethod; import net.runelite.injector.InjectionException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -107,7 +107,7 @@ public class DrawAfterWidgets boolean injected = false; - Method noClip = findStaticMethod("Rasterizer2D_resetClip"); // !!!!! + Method noClip = findStaticMethod(inject, "Rasterizer2D_resetClip"); // !!!!! if (noClip == null) { @@ -261,27 +261,4 @@ public class DrawAfterWidgets throw new InjectionException("injectDrawAfterWidgets failed to inject!"); } } - - private Method findStaticMethod(String name) - { - for (ClassFile c : inject.getDeobfuscated().getClasses()) - { - for (Method m : c.getMethods()) - { - if (!m.getName().equals(name)) - { - continue; - } - - String obfuscatedName = DeobAnnotations.getObfuscatedName(m.getAnnotations()); - Signature obfuscatedSignature = DeobAnnotations.getObfuscatedSignature(m); - - ClassFile c2 = inject.toObClass(c); - - return c2.findMethod(obfuscatedName, (obfuscatedSignature != null) ? obfuscatedSignature : m.getDescriptor()); - } - } - - return null; - } } diff --git a/injector-plugin/src/main/java/net/runelite/injector/raw/DrawMenu.java b/injector-plugin/src/main/java/net/runelite/injector/raw/DrawMenu.java index 65cb9bdab4..b6634e68c5 100644 --- a/injector-plugin/src/main/java/net/runelite/injector/raw/DrawMenu.java +++ b/injector-plugin/src/main/java/net/runelite/injector/raw/DrawMenu.java @@ -1,193 +1,135 @@ -/* package net.runelite.injector.raw; -import com.google.common.base.Strings; -import java.util.HashSet; -import java.util.Set; +import java.util.ListIterator; import net.runelite.asm.ClassFile; import net.runelite.asm.Method; -import net.runelite.asm.Type; -import net.runelite.asm.attributes.Annotations; import net.runelite.asm.attributes.Code; -import net.runelite.asm.attributes.annotation.Annotation; import net.runelite.asm.attributes.code.Instruction; import net.runelite.asm.attributes.code.Instructions; import net.runelite.asm.attributes.code.Label; -import net.runelite.asm.attributes.code.instruction.types.ComparisonInstruction; import net.runelite.asm.attributes.code.instruction.types.JumpingInstruction; -import net.runelite.asm.attributes.code.instruction.types.ReturnInstruction; import net.runelite.asm.attributes.code.instructions.GetStatic; -import net.runelite.asm.attributes.code.instructions.IfACmpEq; -import net.runelite.asm.attributes.code.instructions.IfACmpNe; import net.runelite.asm.attributes.code.instructions.IfEq; import net.runelite.asm.attributes.code.instructions.IfNe; import net.runelite.asm.attributes.code.instructions.InvokeStatic; -import net.runelite.asm.execution.Execution; -import net.runelite.asm.execution.InstructionContext; import net.runelite.asm.pool.Class; import net.runelite.asm.pool.Field; import net.runelite.asm.signature.Signature; -import net.runelite.deob.DeobAnnotations; import net.runelite.injector.Inject; +import static net.runelite.injector.InjectUtil.findDeobField; +import static net.runelite.injector.InjectUtil.findStaticMethod; import net.runelite.injector.InjectionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DrawMenu { + private final Logger log = LoggerFactory.getLogger(DrawMenu.class); private final Inject inject; - private static final Field isMenuOpen = new Field( - new Class("Client"), - "isMenuOpen", - Type.BOOLEAN - ); private static final net.runelite.asm.pool.Method hook = new net.runelite.asm.pool.Method( new Class("net.runelite.client.callback.Hooks"), "drawMenu", new Signature("()Z") ); + //Label Getstatic client.isMenuOpen + //Ifne -> Label Drawmenu + //Jump -> Label Drawtext + + //Label drawtext + //Ldc xxx + //Getstatic client. something with viewport size? + //Imul + //Iconst_m1 + //Ifne -> Label after draw menu <- info we need + //Getstatic / LDC (same getstatic and LDC before) + //Getstatic / LDC + public DrawMenu(Inject inject) { - this.inject =inject; + this.inject = inject; } public void inject() throws InjectionException { - Method drawLoggedIn = findDeobThing("drawLoggedIn", "Client", false); - Instructions ins = drawLoggedIn.getCode().getInstructions(); + Field isMenuOpen = findDeobField(inject, "isMenuOpen").getPoolField(); + net.runelite.asm.pool.Method topLeftText = findStaticMethod(inject, "drawMenuActionTextAt").getPoolMethod(); - int menuOpenIdx = -1; - Field field = toObField(isMenuOpen).getPoolField(); - - for (Instruction i : ins.getInstructions()) - { - if (!(i instanceof GetStatic)) - { - continue; - } - - if (((GetStatic) i).getField().equals(field)) - { - menuOpenIdx = ins.getInstructions().indexOf(i); - } - } - - if (menuOpenIdx == -1) - { - throw new InjectionException("Couldn't find the isMenuOpen check!"); - } - - // This is where the IFEQ or IFNE will be - final Instruction jump = ins.getInstructions().get(menuOpenIdx + 1); - // We want to inject if it's false so - if (jump instanceof IfEq) - { - // Not this one, but we gotta find out where the paths will intersect - Set