From 1dbf432377f4b0355117b25ecde66915456b0ff8 Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Wed, 24 Jun 2020 14:56:35 -0700 Subject: [PATCH 01/68] slayer: Update initial amount if current amount is higher Prior to this commit it was possible to receive a change or update in task by playing on mobile or another client, log back in to RuneLite with incorrect task information saved to config and, once updated via checking a slayer gem or speaking with a slayer master, having a task amount greater than the saved initial task length. This updates the plugin to use the greater of these numbers so that case is no longer possible. --- .../runelite/client/plugins/slayer/SlayerPlugin.java | 2 +- .../client/plugins/slayer/SlayerPluginTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java index c8c02a8bf3..e343c29359 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java @@ -683,7 +683,7 @@ public class SlayerPlugin extends Plugin { taskName = name; amount = amt; - initialAmount = initAmt; + initialAmount = Math.max(amt, initAmt); taskLocation = location; save(); removeCounter(); diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java index 1c0bbb67f9..4780fa6863 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java @@ -775,6 +775,17 @@ public class SlayerPluginTest assertEquals(30, slayerPlugin.getAmount()); } + @Test + public void updateInitialAmount() + { + Widget npcDialog = mock(Widget.class); + when(npcDialog.getText()).thenReturn(TASK_EXISTING); + when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); + slayerPlugin.onGameTick(new GameTick()); + + assertEquals(222, slayerPlugin.getInitialAmount()); + } + @Test public void testTaskLookup() throws IOException { From 5ab04030b8010a31cd06972e2b7f5d2eec384c12 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Jun 2020 12:21:08 -0400 Subject: [PATCH 02/68] api: add high alch price to item composition --- .../src/main/java/net/runelite/api/ItemComposition.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/ItemComposition.java b/runelite-api/src/main/java/net/runelite/api/ItemComposition.java index 16d7876c67..72f955e5ba 100644 --- a/runelite-api/src/main/java/net/runelite/api/ItemComposition.java +++ b/runelite-api/src/main/java/net/runelite/api/ItemComposition.java @@ -91,9 +91,18 @@ public interface ItemComposition * @return the general store value of the item * * @see Constants#HIGH_ALCHEMY_MULTIPLIER + * @see ItemComposition#getHaPrice() */ int getPrice(); + /** + * Get the high alchemy price for this item. All items have a high alchemy price, + * but not all items can be alched. + * + * @return the high alch price + */ + int getHaPrice(); + /** * Checks whether the item is members only. * From 71d89af946b96921004282a76616435d481431cc Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Jun 2020 12:21:21 -0400 Subject: [PATCH 03/68] client: use item composition high alch price The correct way to compute ha price is floor(storePrice * 0.6f). This was being computed incorrectly everywhere except for the bank plugin. THis is now being computed centrally via the api. --- .../runelite/client/plugins/bank/BankPlugin.java | 12 +++++------- .../plugins/chatcommands/ChatCommandsPlugin.java | 16 ++++++---------- .../client/plugins/examine/ExaminePlugin.java | 4 +--- .../plugins/grounditems/GroundItemsPlugin.java | 3 +-- .../plugins/itemprices/ItemPricesOverlay.java | 3 +-- .../plugins/loottracker/LootTrackerPlugin.java | 3 +-- .../client/plugins/bank/BankPluginTest.java | 8 ++++---- 7 files changed, 19 insertions(+), 30 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java index fbbd834ed8..c7c1540137 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java @@ -40,8 +40,6 @@ import javax.annotation.Nullable; import javax.inject.Inject; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; -import net.runelite.api.Constants; -import static net.runelite.api.Constants.HIGH_ALCHEMY_MULTIPLIER; import net.runelite.api.InventoryID; import net.runelite.api.Item; import net.runelite.api.ItemComposition; @@ -411,8 +409,9 @@ public class BankPlugin extends Plugin } final ItemComposition itemComposition = itemManager.getItemComposition(itemId); - long gePrice = (long) itemManager.getItemPrice(itemId) * (long) itemQuantities.count(itemId); - long haPrice = (long) (itemComposition.getPrice() * HIGH_ALCHEMY_MULTIPLIER) * (long) itemQuantities.count(itemId); + final int qty = itemQuantities.count(itemId); + final long gePrice = (long) itemManager.getItemPrice(itemId) * qty; + final long haPrice = (long) itemComposition.getHaPrice() * qty; long value = Math.max(gePrice, haPrice); @@ -522,9 +521,8 @@ public class BankPlugin extends Plugin alch += qty * 1000L; break; default: - final long storePrice = itemManager.getItemComposition(id).getPrice(); - final long alchPrice = (long) (storePrice * Constants.HIGH_ALCHEMY_MULTIPLIER); - alch += alchPrice * qty; + final int alchPrice = itemManager.getItemComposition(id).getHaPrice(); + alch += (long) alchPrice * qty; ge += (long) itemManager.getItemPrice(id) * qty; break; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index bfe3e3479d..56b2435d02 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -39,7 +39,6 @@ import lombok.Value; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; -import net.runelite.api.Constants; import net.runelite.api.Experience; import net.runelite.api.IconID; import net.runelite.api.ItemComposition; @@ -1018,15 +1017,12 @@ public class ChatCommandsPlugin extends Plugin .append(QuantityFormatter.formatNumber(itemPrice)); ItemComposition itemComposition = itemManager.getItemComposition(itemId); - if (itemComposition != null) - { - int alchPrice = Math.round(itemComposition.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER); - builder - .append(ChatColorType.NORMAL) - .append(" HA value ") - .append(ChatColorType.HIGHLIGHT) - .append(QuantityFormatter.formatNumber(alchPrice)); - } + final int alchPrice = itemComposition.getHaPrice(); + builder + .append(ChatColorType.NORMAL) + .append(" HA value ") + .append(ChatColorType.HIGHLIGHT) + .append(QuantityFormatter.formatNumber(alchPrice)); String response = builder.build(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java index 5611ea656e..9bef7571d6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java @@ -34,7 +34,6 @@ import javax.inject.Inject; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; -import net.runelite.api.Constants; import net.runelite.api.ItemComposition; import net.runelite.api.ItemID; import net.runelite.api.events.ChatMessage; @@ -318,9 +317,8 @@ public class ExaminePlugin extends Plugin { // quantity is at least 1 quantity = Math.max(1, quantity); - int itemCompositionPrice = itemComposition.getPrice(); final long gePrice = itemManager.getItemPrice(id); - final long alchPrice = itemCompositionPrice <= 0 ? 0 : Math.round(itemCompositionPrice * Constants.HIGH_ALCHEMY_MULTIPLIER); + final int alchPrice = itemComposition.getHaPrice(); if (gePrice > 0 || alchPrice > 0) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index 96e461ef48..4fb07c3b50 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -51,7 +51,6 @@ import lombok.Getter; import lombok.Setter; import lombok.Value; import net.runelite.api.Client; -import net.runelite.api.Constants; import net.runelite.api.GameState; import net.runelite.api.ItemComposition; import net.runelite.api.ItemID; @@ -380,7 +379,7 @@ public class GroundItemsPlugin extends Plugin final int itemId = item.getId(); final ItemComposition itemComposition = itemManager.getItemComposition(itemId); final int realItemId = itemComposition.getNote() != -1 ? itemComposition.getLinkedNoteId() : itemId; - final int alchPrice = Math.round(itemComposition.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER); + final int alchPrice = itemComposition.getHaPrice(); final boolean dropped = tile.getWorldLocation().equals(client.getLocalPlayer().getWorldLocation()) && droppedItemQueue.remove(itemId); final GroundItem groundItem = GroundItem.builder() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java index a4102f7996..c614665401 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java @@ -29,7 +29,6 @@ import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; import net.runelite.api.Client; -import net.runelite.api.Constants; import net.runelite.api.InventoryID; import net.runelite.api.Item; import net.runelite.api.ItemComposition; @@ -213,7 +212,7 @@ class ItemPricesOverlay extends Overlay int gePrice = 0; int haPrice = 0; int haProfit = 0; - final int itemHaPrice = Math.round(itemDef.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER); + final int itemHaPrice = itemDef.getHaPrice(); if (config.showGEPrice()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index e20e250cea..d8da160419 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -61,7 +61,6 @@ import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; -import net.runelite.api.Constants; import net.runelite.api.GameState; import net.runelite.api.InventoryID; import net.runelite.api.ItemComposition; @@ -877,7 +876,7 @@ public class LootTrackerPlugin extends Plugin { final ItemComposition itemComposition = itemManager.getItemComposition(itemId); final int gePrice = itemManager.getItemPrice(itemId); - final int haPrice = Math.round(itemComposition.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER); + final int haPrice = itemComposition.getHaPrice(); final boolean ignored = ignoredItems.contains(itemComposition.getName()); return new LootTrackerItem( diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankPluginTest.java index 03424d7d01..ecc3c993c1 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankPluginTest.java @@ -84,8 +84,8 @@ public class BankPluginTest ItemComposition comp = mock(ItemComposition.class); // 60k HA price * 30 = 1.8m - when(comp.getPrice()) - .thenReturn(100_000); + when(comp.getHaPrice()) + .thenReturn(60_000); // 400k GE Price * 30 = 12m when(itemManager.getItemPrice(itemId)) @@ -121,8 +121,8 @@ public class BankPluginTest ).toArray(new Item[0]); ItemComposition whipComp = mock(ItemComposition.class); - when(whipComp.getPrice()) - .thenReturn(7); // 7 * .6 = 4, 4 * 1m overflows + when(whipComp.getHaPrice()) + .thenReturn(4); // 4 * 1m overflows when(itemManager.getItemComposition(ItemID.ABYSSAL_WHIP)) .thenReturn(whipComp); when(itemManager.getItemPrice(ItemID.ABYSSAL_WHIP)) From f9aea0d9582c59548ae3405deef1a0982d50084c Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 27 Jun 2020 13:52:14 -0400 Subject: [PATCH 04/68] examine plugin: fix overflow in computing alch price --- .../client/plugins/examine/ExaminePlugin.java | 10 +++++---- .../plugins/examine/ExaminePluginTest.java | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java index 9bef7571d6..d301bab699 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.examine; +import com.google.common.annotations.VisibleForTesting; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import java.time.Instant; @@ -313,11 +314,12 @@ public class ExaminePlugin extends Plugin return null; } - private void getItemPrice(int id, ItemComposition itemComposition, int quantity) + @VisibleForTesting + void getItemPrice(int id, ItemComposition itemComposition, int quantity) { // quantity is at least 1 quantity = Math.max(1, quantity); - final long gePrice = itemManager.getItemPrice(id); + final int gePrice = itemManager.getItemPrice(id); final int alchPrice = itemComposition.getHaPrice(); if (gePrice > 0 || alchPrice > 0) @@ -345,7 +347,7 @@ public class ExaminePlugin extends Plugin .append(ChatColorType.NORMAL) .append(" GE average ") .append(ChatColorType.HIGHLIGHT) - .append(QuantityFormatter.formatNumber(gePrice * quantity)); + .append(QuantityFormatter.formatNumber((long) gePrice * quantity)); if (quantity > 1) { @@ -365,7 +367,7 @@ public class ExaminePlugin extends Plugin .append(ChatColorType.NORMAL) .append(" HA value ") .append(ChatColorType.HIGHLIGHT) - .append(QuantityFormatter.formatNumber(alchPrice * quantity)); + .append(QuantityFormatter.formatNumber((long) alchPrice * quantity)); if (quantity > 1) { diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/examine/ExaminePluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/examine/ExaminePluginTest.java index 093beec4f9..e13f926f8b 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/examine/ExaminePluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/examine/ExaminePluginTest.java @@ -37,11 +37,14 @@ import net.runelite.api.events.ChatMessage; import net.runelite.api.events.MenuOptionClicked; import net.runelite.api.widgets.Widget; import net.runelite.client.chat.ChatMessageManager; +import net.runelite.client.chat.QueuedMessage; import net.runelite.client.game.ItemManager; import net.runelite.http.api.examine.ExamineClient; +import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import org.mockito.Mock; @@ -115,4 +118,23 @@ public class ExaminePluginTest verify(examineClient, never()).submitItem(anyInt(), anyString()); } + + @Test + public void testGetItemPrice() + { + ItemComposition itemComposition = mock(ItemComposition.class); + when(itemComposition.getName()).thenReturn("Abyssal whip"); + when(itemComposition.getHaPrice()).thenReturn(2); + when(itemManager.getItemPrice(ItemID.ABYSSAL_WHIP)).thenReturn(3); + examinePlugin.getItemPrice(ItemID.ABYSSAL_WHIP, itemComposition, 2_000_000_000); + + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(QueuedMessage.class); + verify(chatMessageManager).queue(argumentCaptor.capture()); + + QueuedMessage queuedMessage = argumentCaptor.getValue(); + assertEquals( + "Price of 2,000,000,000 x Abyssal whip: GE average 6,000,000,000 (3ea) HA value 4,000,000,000 (2ea)", + queuedMessage.getRuneLiteFormattedMessage() + ); + } } \ No newline at end of file From 47c375cb035dfe72c0c6717cdc4b89ff0accf217 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jun 2020 13:44:14 -0400 Subject: [PATCH 05/68] client: use guice provided http client everywhere --- .../runelite/cache/util/XteaKeyManager.java | 3 +- http-api/pom.xml | 5 --- .../http/api/account/AccountClient.java | 32 ++++++++--------- .../runelite/http/api/chat/ChatClient.java | 33 +++++++++-------- .../http/api/config/ConfigClient.java | 35 +++++++++---------- .../http/api/examine/ExamineClient.java | 19 +++++----- .../runelite/http/api/feed/FeedClient.java | 19 ++++------ .../http/api/ge/GrandExchangeClient.java | 7 +++- .../http/api/hiscore/HiscoreClient.java | 8 +++-- .../runelite/http/api/item/ItemClient.java | 23 +++++------- .../api/loottracker/LootTrackerClient.java | 8 +++-- .../api/osbuddy/OSBGrandExchangeClient.java | 7 +++- .../runelite/http/api/worlds/WorldClient.java | 19 ++++------ .../net/runelite/http/api/xp/XpClient.java | 18 ++++++---- .../runelite/http/api/xtea/XteaClient.java | 21 ++++++----- .../http/service/hiscore/HiscoreService.java | 3 +- .../runelite/client/ClientSessionManager.java | 8 +++-- .../java/net/runelite/client/RuneLite.java | 13 ++++++- .../net/runelite/client/RuneLiteModule.java | 17 +++++---- .../net/runelite/client/SessionClient.java | 11 ++++-- .../client/account/SessionManager.java | 16 +++++---- .../runelite/client/config/ConfigManager.java | 20 ++++++----- .../ExternalPluginManager.java | 7 ++-- .../runelite/client/game/HiscoreManager.java | 8 ++--- .../net/runelite/client/game/ItemManager.java | 11 +++--- .../runelite/client/game/WorldService.java | 5 +-- .../chatcommands/ChatCommandsPlugin.java | 12 +++++-- .../client/plugins/discord/DiscordPlugin.java | 9 +++-- .../client/plugins/examine/ExaminePlugin.java | 8 +++++ .../client/plugins/feed/FeedPanel.java | 12 +++++-- .../client/plugins/feed/FeedPlugin.java | 24 +++++++++++-- .../grandexchange/GrandExchangePlugin.java | 19 ++++++++-- .../client/plugins/hiscore/HiscorePanel.java | 23 ++++++------ .../loottracker/LootTrackerPlugin.java | 8 +++-- .../client/plugins/raids/RaidsPlugin.java | 2 +- .../client/plugins/slayer/SlayerPlugin.java | 2 +- .../wiki/WikiSearchChatboxTextInput.java | 9 +++-- .../plugins/xptracker/XpTrackerPlugin.java | 11 +++++- .../plugins/xpupdater/XpUpdaterPlugin.java | 17 +++++---- .../client/plugins/xtea/XteaPlugin.java | 13 +++++-- .../client/rs/ClientConfigLoader.java | 12 +++---- .../net/runelite/client/rs/ClientLoader.java | 19 ++++++---- .../net/runelite/client/rs/WorldSupplier.java | 7 ++-- .../runelite/client/util/ImageCapture.java | 6 +++- .../java/net/runelite/client/ws/WSClient.java | 7 ++-- .../client/plugins/PluginManagerTest.java | 28 +++++++++------ .../chatcommands/ChatCommandsPluginTest.java | 5 +++ .../GrandExchangePluginTest.java | 5 +++ .../plugins/hiscore/HiscorePanelTest.java | 4 ++- .../client/plugins/raids/RaidsPluginTest.java | 5 +++ .../xptracker/XpTrackerPluginTest.java | 5 +++ .../client/rs/ClientConfigLoaderTest.java | 3 +- 52 files changed, 407 insertions(+), 244 deletions(-) diff --git a/cache/src/main/java/net/runelite/cache/util/XteaKeyManager.java b/cache/src/main/java/net/runelite/cache/util/XteaKeyManager.java index 80f8dbf981..38ba347d4b 100644 --- a/cache/src/main/java/net/runelite/cache/util/XteaKeyManager.java +++ b/cache/src/main/java/net/runelite/cache/util/XteaKeyManager.java @@ -27,6 +27,7 @@ package net.runelite.cache.util; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.xtea.XteaClient; import net.runelite.http.api.xtea.XteaKey; import org.slf4j.Logger; @@ -40,7 +41,7 @@ public class XteaKeyManager public void loadKeys() { - XteaClient xteaClient = new XteaClient(); + XteaClient xteaClient = new XteaClient(RuneLiteAPI.CLIENT); try { diff --git a/http-api/pom.xml b/http-api/pom.xml index 8a52a759ff..dcd491b4f1 100644 --- a/http-api/pom.xml +++ b/http-api/pom.xml @@ -63,11 +63,6 @@ commons-csv 1.4 - - javax.inject - javax.inject - 1 - junit 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 0a286cd70e..625be00ad0 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 @@ -29,24 +29,22 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.UUID; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j +@RequiredArgsConstructor public class AccountClient { - private static final Logger logger = LoggerFactory.getLogger(AccountClient.class); - + private final OkHttpClient client; private UUID uuid; - public AccountClient() - { - } - - public AccountClient(UUID uuid) + public void setUuid(UUID uuid) { this.uuid = uuid; } @@ -59,13 +57,13 @@ public class AccountClient .addQueryParameter("uuid", uuid.toString()) .build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { InputStream in = response.body().byteStream(); return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), OAuthResponse.class); @@ -83,16 +81,16 @@ public class AccountClient .addPathSegment("logout") .build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString()) .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { - logger.debug("Sent logout request"); + log.debug("Sent logout request"); } } @@ -103,20 +101,20 @@ public class AccountClient .addPathSegment("session-check") .build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString()) .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { return response.isSuccessful(); } catch (IOException ex) { - logger.debug("Unable to verify session", ex); + log.debug("Unable to verify session", ex); return true; // assume it is still valid if the server is unreachable } } diff --git a/http-api/src/main/java/net/runelite/http/api/chat/ChatClient.java b/http-api/src/main/java/net/runelite/http/api/chat/ChatClient.java index 3c1565effd..f3a0b41c30 100644 --- a/http-api/src/main/java/net/runelite/http/api/chat/ChatClient.java +++ b/http-api/src/main/java/net/runelite/http/api/chat/ChatClient.java @@ -28,14 +28,19 @@ import com.google.gson.JsonParseException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import lombok.AllArgsConstructor; import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; +@AllArgsConstructor public class ChatClient { + private final OkHttpClient client; + public boolean submitKc(String username, String boss, int kc) throws IOException { HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() @@ -51,7 +56,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { return response.isSuccessful(); } @@ -70,7 +75,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) { @@ -94,7 +99,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { return response.isSuccessful(); } @@ -112,7 +117,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) { @@ -139,7 +144,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { return response.isSuccessful(); } @@ -157,7 +162,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) { @@ -188,7 +193,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { return response.isSuccessful(); } @@ -207,7 +212,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) { @@ -231,7 +236,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { return response.isSuccessful(); } @@ -249,7 +254,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) { @@ -276,7 +281,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { return response.isSuccessful(); } @@ -294,7 +299,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) { @@ -323,7 +328,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { return response.isSuccessful(); } @@ -341,7 +346,7 @@ public class ChatClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) { diff --git a/http-api/src/main/java/net/runelite/http/api/config/ConfigClient.java b/http-api/src/main/java/net/runelite/http/api/config/ConfigClient.java index c82c7d0f22..62704a8ff1 100644 --- a/http-api/src/main/java/net/runelite/http/api/config/ConfigClient.java +++ b/http-api/src/main/java/net/runelite/http/api/config/ConfigClient.java @@ -30,44 +30,41 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.RuneLiteAPI; import okhttp3.Call; import okhttp3.Callback; import okhttp3.HttpUrl; import okhttp3.MediaType; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@AllArgsConstructor +@Slf4j public class ConfigClient { - private static final Logger logger = LoggerFactory.getLogger(ConfigClient.class); - private static final MediaType TEXT_PLAIN = MediaType.parse("text/plain"); + private final OkHttpClient client; private final UUID uuid; - public ConfigClient(UUID uuid) - { - this.uuid = uuid; - } - public Configuration get() throws IOException { HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() .addPathSegment("config") .build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString()) .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { InputStream in = response.body().byteStream(); return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), Configuration.class); @@ -87,7 +84,7 @@ public class ConfigClient .addPathSegment(key) .build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .put(RequestBody.create(TEXT_PLAIN, value)) @@ -95,12 +92,12 @@ public class ConfigClient .url(url) .build(); - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { - logger.warn("Unable to synchronize configuration item", e); + log.warn("Unable to synchronize configuration item", e); future.completeExceptionally(e); } @@ -108,7 +105,7 @@ public class ConfigClient public void onResponse(Call call, Response response) { response.close(); - logger.debug("Synchronized configuration value '{}' to '{}'", key, value); + log.debug("Synchronized configuration value '{}' to '{}'", key, value); future.complete(null); } }); @@ -125,7 +122,7 @@ public class ConfigClient .addPathSegment(key) .build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .delete() @@ -133,12 +130,12 @@ public class ConfigClient .url(url) .build(); - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { - logger.warn("Unable to unset configuration item", e); + log.warn("Unable to unset configuration item", e); future.completeExceptionally(e); } @@ -146,7 +143,7 @@ public class ConfigClient public void onResponse(Call call, Response response) { response.close(); - logger.debug("Unset configuration value '{}'", key); + log.debug("Unset configuration value '{}'", key); future.complete(null); } }); diff --git a/http-api/src/main/java/net/runelite/http/api/examine/ExamineClient.java b/http-api/src/main/java/net/runelite/http/api/examine/ExamineClient.java index 5997799c2e..3271f9994e 100644 --- a/http-api/src/main/java/net/runelite/http/api/examine/ExamineClient.java +++ b/http-api/src/main/java/net/runelite/http/api/examine/ExamineClient.java @@ -25,23 +25,26 @@ package net.runelite.http.api.examine; import java.io.IOException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.RuneLiteAPI; import okhttp3.Call; import okhttp3.Callback; import okhttp3.HttpUrl; import okhttp3.MediaType; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j +@RequiredArgsConstructor public class ExamineClient { - private static final Logger logger = LoggerFactory.getLogger(ExamineClient.class); - private static final MediaType TEXT = MediaType.parse("text"); + private final OkHttpClient client; + public void submitObject(int id, String text) { submit("object", id, text); @@ -65,26 +68,26 @@ public class ExamineClient .addPathSegment(Integer.toString(id)) .build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .url(url) .post(RequestBody.create(TEXT, text)) .build(); - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { - logger.warn("Error submitting examine", e); + log.warn("Error submitting examine", e); } @Override public void onResponse(Call call, Response response) { response.close(); - logger.debug("Submitted examine info for {} {}: {}", type, id, text); + log.debug("Submitted examine info for {} {}: {}", type, id, text); } }); } diff --git a/http-api/src/main/java/net/runelite/http/api/feed/FeedClient.java b/http-api/src/main/java/net/runelite/http/api/feed/FeedClient.java index bf4698315c..62cddfa599 100644 --- a/http-api/src/main/java/net/runelite/http/api/feed/FeedClient.java +++ b/http-api/src/main/java/net/runelite/http/api/feed/FeedClient.java @@ -28,34 +28,27 @@ import com.google.gson.JsonParseException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import javax.inject.Inject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j +@RequiredArgsConstructor public class FeedClient { - private static final Logger logger = LoggerFactory.getLogger(FeedClient.class); - private final OkHttpClient client; - @Inject - public FeedClient(OkHttpClient client) - { - this.client = client; - } - public FeedResult lookupFeed() throws IOException { HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() .addPathSegment("feed.js") .build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .url(url) @@ -65,7 +58,7 @@ public class FeedClient { if (!response.isSuccessful()) { - logger.debug("Error looking up feed: {}", response); + log.debug("Error looking up feed: {}", response); return null; } diff --git a/http-api/src/main/java/net/runelite/http/api/ge/GrandExchangeClient.java b/http-api/src/main/java/net/runelite/http/api/ge/GrandExchangeClient.java index fd02f37ffc..1d898ccf27 100644 --- a/http-api/src/main/java/net/runelite/http/api/ge/GrandExchangeClient.java +++ b/http-api/src/main/java/net/runelite/http/api/ge/GrandExchangeClient.java @@ -27,6 +27,7 @@ package net.runelite.http.api.ge; import com.google.gson.Gson; import java.io.IOException; import java.util.UUID; +import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.RuneLiteAPI; @@ -34,15 +35,19 @@ import static net.runelite.http.api.RuneLiteAPI.JSON; import okhttp3.Call; import okhttp3.Callback; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; @Slf4j +@RequiredArgsConstructor public class GrandExchangeClient { private static final Gson GSON = RuneLiteAPI.GSON; + private final OkHttpClient client; + @Setter private UUID uuid; @Setter @@ -69,7 +74,7 @@ public class GrandExchangeClient .url(url) .build(); - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) diff --git a/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java b/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java index a725089de4..2807f8f411 100644 --- a/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java +++ b/http-api/src/main/java/net/runelite/http/api/hiscore/HiscoreClient.java @@ -25,9 +25,10 @@ package net.runelite.http.api.hiscore; import java.io.IOException; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import org.apache.commons.csv.CSVFormat; @@ -35,8 +36,11 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; @Slf4j +@RequiredArgsConstructor public class HiscoreClient { + private final OkHttpClient client; + public HiscoreResult lookup(String username, HiscoreEndpoint endpoint) throws IOException { return lookup(username, endpoint.getHiscoreURL()); @@ -97,7 +101,7 @@ public class HiscoreClient String responseStr; - try (Response okresponse = RuneLiteAPI.CLIENT.newCall(okrequest).execute()) + try (Response okresponse = client.newCall(okrequest).execute()) { if (!okresponse.isSuccessful()) { diff --git a/http-api/src/main/java/net/runelite/http/api/item/ItemClient.java b/http-api/src/main/java/net/runelite/http/api/item/ItemClient.java index 0dea2d1eed..1b4df52de4 100644 --- a/http-api/src/main/java/net/runelite/http/api/item/ItemClient.java +++ b/http-api/src/main/java/net/runelite/http/api/item/ItemClient.java @@ -31,27 +31,20 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.Map; -import javax.inject.Inject; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j +@AllArgsConstructor public class ItemClient { - private static final Logger logger = LoggerFactory.getLogger(ItemClient.class); - private final OkHttpClient client; - @Inject - public ItemClient(OkHttpClient client) - { - this.client = client; - } - public ItemPrice[] getPrices() throws IOException { HttpUrl.Builder urlBuilder = RuneLiteAPI.getApiBase().newBuilder() @@ -60,7 +53,7 @@ public class ItemClient HttpUrl url = urlBuilder.build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .url(url) @@ -70,7 +63,7 @@ public class ItemClient { if (!response.isSuccessful()) { - logger.warn("Error looking up prices: {}", response); + log.warn("Error looking up prices: {}", response); return null; } @@ -92,7 +85,7 @@ public class ItemClient HttpUrl url = urlBuilder.build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .url(url) @@ -102,7 +95,7 @@ public class ItemClient { if (!response.isSuccessful()) { - logger.warn("Error looking up item stats: {}", response); + log.warn("Error looking up item stats: {}", response); return null; } diff --git a/http-api/src/main/java/net/runelite/http/api/loottracker/LootTrackerClient.java b/http-api/src/main/java/net/runelite/http/api/loottracker/LootTrackerClient.java index bc1b6de369..79351cfc90 100644 --- a/http-api/src/main/java/net/runelite/http/api/loottracker/LootTrackerClient.java +++ b/http-api/src/main/java/net/runelite/http/api/loottracker/LootTrackerClient.java @@ -41,6 +41,7 @@ import static net.runelite.http.api.RuneLiteAPI.JSON; import okhttp3.Call; import okhttp3.Callback; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; @@ -51,6 +52,7 @@ public class LootTrackerClient { private static final Gson GSON = RuneLiteAPI.GSON; + private final OkHttpClient client; private final UUID uuid; public CompletableFuture submit(Collection lootRecords) @@ -67,7 +69,7 @@ public class LootTrackerClient .url(url) .build(); - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) @@ -99,7 +101,7 @@ public class LootTrackerClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) { @@ -134,7 +136,7 @@ public class LootTrackerClient .url(builder.build()) .build(); - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) diff --git a/http-api/src/main/java/net/runelite/http/api/osbuddy/OSBGrandExchangeClient.java b/http-api/src/main/java/net/runelite/http/api/osbuddy/OSBGrandExchangeClient.java index c01337fdc0..3a832c7ccb 100644 --- a/http-api/src/main/java/net/runelite/http/api/osbuddy/OSBGrandExchangeClient.java +++ b/http-api/src/main/java/net/runelite/http/api/osbuddy/OSBGrandExchangeClient.java @@ -28,15 +28,20 @@ import com.google.gson.JsonParseException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; @Slf4j +@AllArgsConstructor public class OSBGrandExchangeClient { + private final OkHttpClient client; + public OSBGrandExchangeResult lookupItem(int itemId) throws IOException { final HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() @@ -51,7 +56,7 @@ public class OSBGrandExchangeClient .url(url) .build(); - try (final Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (final Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) { diff --git a/http-api/src/main/java/net/runelite/http/api/worlds/WorldClient.java b/http-api/src/main/java/net/runelite/http/api/worlds/WorldClient.java index b9d84eefd9..97063b8c0d 100644 --- a/http-api/src/main/java/net/runelite/http/api/worlds/WorldClient.java +++ b/http-api/src/main/java/net/runelite/http/api/worlds/WorldClient.java @@ -29,34 +29,27 @@ import com.google.gson.JsonParseException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import javax.inject.Inject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j +@RequiredArgsConstructor public class WorldClient { - private static final Logger logger = LoggerFactory.getLogger(WorldClient.class); - private final OkHttpClient client; - @Inject - public WorldClient(OkHttpClient client) - { - this.client = client; - } - public WorldResult lookupWorlds() throws IOException { HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() .addPathSegment("worlds.js") .build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .url(url) @@ -66,7 +59,7 @@ public class WorldClient { if (!response.isSuccessful()) { - logger.debug("Error looking up worlds: {}", response); + log.debug("Error looking up worlds: {}", response); throw new IOException("unsuccessful response looking up worlds"); } diff --git a/http-api/src/main/java/net/runelite/http/api/xp/XpClient.java b/http-api/src/main/java/net/runelite/http/api/xp/XpClient.java index c45fe2e209..76acf6ad63 100644 --- a/http-api/src/main/java/net/runelite/http/api/xp/XpClient.java +++ b/http-api/src/main/java/net/runelite/http/api/xp/XpClient.java @@ -25,18 +25,24 @@ package net.runelite.http.api.xp; import java.io.IOException; +import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.RuneLiteAPI; import okhttp3.Call; import okhttp3.Callback; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j public class XpClient { - private static final Logger logger = LoggerFactory.getLogger(XpClient.class); + private final OkHttpClient client; + + public XpClient(OkHttpClient client) + { + this.client = client; + } public void update(String username) { @@ -50,19 +56,19 @@ public class XpClient .url(url) .build(); - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { - logger.warn("Error submitting xp track", e); + log.warn("Error submitting xp track", e); } @Override public void onResponse(Call call, Response response) { response.close(); - logger.debug("Submitted xp track for {}", username); + log.debug("Submitted xp track for {}", username); } }); } diff --git a/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java b/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java index 42b10e3239..67a2e866ca 100644 --- a/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java +++ b/http-api/src/main/java/net/runelite/http/api/xtea/XteaClient.java @@ -30,20 +30,23 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import net.runelite.http.api.RuneLiteAPI; import static net.runelite.http.api.RuneLiteAPI.JSON; import okhttp3.Call; import okhttp3.Callback; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +@Slf4j +@AllArgsConstructor public class XteaClient { - private static final Logger logger = LoggerFactory.getLogger(XteaClient.class); + private final OkHttpClient client; public void submit(XteaRequest xteaRequest) { @@ -53,19 +56,19 @@ public class XteaClient .addPathSegment("xtea") .build(); - logger.debug("Built URI: {}", url); + log.debug("Built URI: {}", url); Request request = new Request.Builder() .post(RequestBody.create(JSON, json)) .url(url) .build(); - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { - logger.warn("unable to submit xtea keys", e); + log.warn("unable to submit xtea keys", e); } @Override @@ -75,7 +78,7 @@ public class XteaClient { if (!response.isSuccessful()) { - logger.debug("unsuccessful xtea response"); + log.debug("unsuccessful xtea response"); } } finally @@ -96,7 +99,7 @@ public class XteaClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { InputStream in = response.body().byteStream(); // CHECKSTYLE:OFF @@ -120,7 +123,7 @@ public class XteaClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = client.newCall(request).execute()) { InputStream in = response.body().byteStream(); return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), XteaKey.class); diff --git a/http-service/src/main/java/net/runelite/http/service/hiscore/HiscoreService.java b/http-service/src/main/java/net/runelite/http/service/hiscore/HiscoreService.java index cc565b4444..fd73e17359 100644 --- a/http-service/src/main/java/net/runelite/http/service/hiscore/HiscoreService.java +++ b/http-service/src/main/java/net/runelite/http/service/hiscore/HiscoreService.java @@ -31,6 +31,7 @@ import com.google.common.cache.LoadingCache; import java.io.IOException; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.hiscore.HiscoreClient; import net.runelite.http.api.hiscore.HiscoreEndpoint; import net.runelite.http.api.hiscore.HiscoreResult; @@ -40,7 +41,7 @@ import org.springframework.stereotype.Service; @Service public class HiscoreService { - private final HiscoreClient hiscoreClient = new HiscoreClient(); + private final HiscoreClient hiscoreClient = new HiscoreClient(RuneLiteAPI.CLIENT); private final LoadingCache hiscoreCache = CacheBuilder.newBuilder() .maximumSize(128) .expireAfterWrite(1, TimeUnit.MINUTES) diff --git a/runelite-client/src/main/java/net/runelite/client/ClientSessionManager.java b/runelite-client/src/main/java/net/runelite/client/ClientSessionManager.java index 5009bd509d..588a1ad006 100644 --- a/runelite-client/src/main/java/net/runelite/client/ClientSessionManager.java +++ b/runelite-client/src/main/java/net/runelite/client/ClientSessionManager.java @@ -38,23 +38,27 @@ import net.runelite.api.GameState; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ClientShutdown; import net.runelite.client.util.RunnableExceptionLogger; +import okhttp3.OkHttpClient; @Singleton @Slf4j public class ClientSessionManager { - private final SessionClient sessionClient = new SessionClient(); private final ScheduledExecutorService executorService; private final Client client; + private final SessionClient sessionClient; private ScheduledFuture scheduledFuture; private UUID sessionId; @Inject - ClientSessionManager(ScheduledExecutorService executorService, @Nullable Client client) + ClientSessionManager(ScheduledExecutorService executorService, + @Nullable Client client, + OkHttpClient okHttpClient) { this.executorService = executorService; this.client = client; + this.sessionClient = new SessionClient(okHttpClient); } public void start() 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 c8cd6f352f..e9d79d1b5f 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLite.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLite.java @@ -76,6 +76,9 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxOverlay; import net.runelite.client.ui.overlay.tooltip.TooltipOverlay; import net.runelite.client.ui.overlay.worldmap.WorldMapOverlay; import net.runelite.client.ws.PartyService; +import net.runelite.http.api.RuneLiteAPI; +import okhttp3.Cache; +import okhttp3.OkHttpClient; import org.slf4j.LoggerFactory; @Singleton @@ -91,6 +94,8 @@ public class RuneLite public static final File DEFAULT_SESSION_FILE = new File(RUNELITE_DIR, "session"); public static final File DEFAULT_CONFIG_FILE = new File(RUNELITE_DIR, "settings.properties"); + private static final int MAX_OKHTTP_CACHE_SIZE = 20 * 1024 * 1024; // 20mb + @Getter private static Injector injector; @@ -178,6 +183,7 @@ public class RuneLite parser.accepts("developer-mode", "Enable developer tools"); parser.accepts("debug", "Show extra debugging output"); parser.accepts("safe-mode", "Disables external plugins and the GPU plugin"); + parser.accepts("insecure-skip-tls-verification", "Disables TLS verification"); final ArgumentAcceptingOptionSpec sessionfile = parser.accepts("sessionfile", "Use a specified session file") .withRequiredArg() @@ -227,12 +233,16 @@ public class RuneLite } }); + final OkHttpClient okHttpClient = RuneLiteAPI.CLIENT.newBuilder() + .cache(new Cache(new File(CACHE_DIR, "okhttp"), MAX_OKHTTP_CACHE_SIZE)) + .build(); + SplashScreen.init(); SplashScreen.stage(0, "Retrieving client", ""); try { - final ClientLoader clientLoader = new ClientLoader(options.valueOf(updateMode)); + final ClientLoader clientLoader = new ClientLoader(okHttpClient, options.valueOf(updateMode)); new Thread(() -> { @@ -265,6 +275,7 @@ public class RuneLite final long start = System.currentTimeMillis(); injector = Guice.createInjector(new RuneLiteModule( + okHttpClient, clientLoader, developerMode, options.has("safe-mode"), diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLiteModule.java b/runelite-client/src/main/java/net/runelite/client/RuneLiteModule.java index c1489de882..517a7f83e0 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLiteModule.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLiteModule.java @@ -50,15 +50,13 @@ import net.runelite.client.plugins.PluginManager; import net.runelite.client.task.Scheduler; import net.runelite.client.util.DeferredEventBus; import net.runelite.client.util.ExecutorServiceExceptionLogger; -import net.runelite.http.api.RuneLiteAPI; -import okhttp3.Cache; +import net.runelite.http.api.chat.ChatClient; import okhttp3.OkHttpClient; @AllArgsConstructor public class RuneLiteModule extends AbstractModule { - private static final int MAX_OKHTTP_CACHE_SIZE = 20 * 1024 * 1024; // 20mb - + private final OkHttpClient okHttpClient; private final Supplier clientLoader; private final boolean developerMode; private final boolean safeMode; @@ -73,9 +71,7 @@ public class RuneLiteModule extends AbstractModule bind(File.class).annotatedWith(Names.named("sessionfile")).toInstance(sessionfile); bind(File.class).annotatedWith(Names.named("config")).toInstance(config); bind(ScheduledExecutorService.class).toInstance(new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor())); - bind(OkHttpClient.class).toInstance(RuneLiteAPI.CLIENT.newBuilder() - .cache(new Cache(new File(RuneLite.CACHE_DIR, "okhttp"), MAX_OKHTTP_CACHE_SIZE)) - .build()); + bind(OkHttpClient.class).toInstance(okHttpClient); bind(MenuManager.class); bind(ChatMessageManager.class); bind(ItemManager.class); @@ -120,4 +116,11 @@ public class RuneLiteModule extends AbstractModule { return configManager.getConfig(ChatColorConfig.class); } + + @Provides + @Singleton + ChatClient provideChatClient(OkHttpClient okHttpClient) + { + return new ChatClient(okHttpClient); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/SessionClient.java b/runelite-client/src/main/java/net/runelite/client/SessionClient.java index ecfa96bafe..2aa8c7c3e3 100644 --- a/runelite-client/src/main/java/net/runelite/client/SessionClient.java +++ b/runelite-client/src/main/java/net/runelite/client/SessionClient.java @@ -29,15 +29,20 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.UUID; +import lombok.AllArgsConstructor; import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.ResponseBody; +@AllArgsConstructor class SessionClient { + private final OkHttpClient okHttpClient; + UUID open() throws IOException { HttpUrl url = RuneLiteAPI.getSessionBase().newBuilder() @@ -48,7 +53,7 @@ class SessionClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = okHttpClient.newCall(request).execute()) { ResponseBody body = response.body(); @@ -74,7 +79,7 @@ class SessionClient .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = okHttpClient.newCall(request).execute()) { if (!response.isSuccessful()) { @@ -94,6 +99,6 @@ class SessionClient .url(url) .build(); - RuneLiteAPI.CLIENT.newCall(request).execute().close(); + okHttpClient.newCall(request).execute().close(); } } 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 a5c45f2591..3f754b5e40 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 @@ -47,6 +47,7 @@ import net.runelite.client.ws.WSClient; import net.runelite.http.api.account.AccountClient; import net.runelite.http.api.account.OAuthResponse; import net.runelite.http.api.ws.messages.LoginResponse; +import okhttp3.OkHttpClient; @Singleton @Slf4j @@ -59,18 +60,21 @@ public class SessionManager private final ConfigManager configManager; private final WSClient wsClient; private final File sessionFile; + private final AccountClient accountClient; @Inject private SessionManager( @Named("sessionfile") File sessionfile, ConfigManager configManager, EventBus eventBus, - WSClient wsClient) + WSClient wsClient, + OkHttpClient okHttpClient) { this.configManager = configManager; this.eventBus = eventBus; this.wsClient = wsClient; this.sessionFile = sessionfile; + this.accountClient = new AccountClient(okHttpClient); eventBus.register(this); } @@ -98,7 +102,7 @@ public class SessionManager } // Check if session is still valid - AccountClient accountClient = new AccountClient(session.getUuid()); + accountClient.setUuid(session.getUuid()); if (!accountClient.sessionCheck()) { log.debug("Loaded session {} is invalid", session.getUuid()); @@ -169,10 +173,10 @@ public class SessionManager log.debug("Logging out of account {}", accountSession.getUsername()); - AccountClient client = new AccountClient(accountSession.getUuid()); + accountClient.setUuid(accountSession.getUuid()); try { - client.logout(); + accountClient.logout(); } catch (IOException ex) { @@ -191,13 +195,13 @@ public class SessionManager { // If a session is already open, use that id. Otherwise generate a new id. UUID uuid = wsClient.getSessionId() != null ? wsClient.getSessionId() : UUID.randomUUID(); - AccountClient loginClient = new AccountClient(uuid); + accountClient.setUuid(uuid); final OAuthResponse login; try { - login = loginClient.login(); + login = accountClient.login(); } catch (IOException ex) { diff --git a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java index e4cbdcc5b1..3842fd96a5 100644 --- a/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java +++ b/runelite-client/src/main/java/net/runelite/client/config/ConfigManager.java @@ -78,6 +78,7 @@ import net.runelite.client.util.ColorUtil; import net.runelite.http.api.config.ConfigClient; import net.runelite.http.api.config.ConfigEntry; import net.runelite.http.api.config.Configuration; +import okhttp3.OkHttpClient; @Singleton @Slf4j @@ -85,10 +86,9 @@ public class ConfigManager { private static final DateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); - @Inject - EventBus eventBus; - - private final ScheduledExecutorService executor; + private final File settingsFileInput; + private final EventBus eventBus; + private final OkHttpClient okHttpClient; private AccountSession session; private ConfigClient client; @@ -97,18 +97,20 @@ public class ConfigManager private final ConfigInvocationHandler handler = new ConfigInvocationHandler(this); private final Properties properties = new Properties(); private final Map pendingChanges = new HashMap<>(); - private final File settingsFileInput; @Inject public ConfigManager( @Named("config") File config, - ScheduledExecutorService scheduledExecutorService) + ScheduledExecutorService scheduledExecutorService, + EventBus eventBus, + OkHttpClient okHttpClient) { - this.executor = scheduledExecutorService; this.settingsFileInput = config; + this.eventBus = eventBus; + this.okHttpClient = okHttpClient; this.propertiesFile = getPropertiesFile(); - executor.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS); + scheduledExecutorService.scheduleWithFixedDelay(this::sendConfig, 30, 30, TimeUnit.SECONDS); } public final void switchSession(AccountSession session) @@ -124,7 +126,7 @@ public class ConfigManager else { this.session = session; - this.client = new ConfigClient(session.getUuid()); + this.client = new ConfigClient(okHttpClient, session.getUuid()); } this.propertiesFile = getPropertiesFile(); diff --git a/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginManager.java b/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginManager.java index b2175f3973..bd6baf39ac 100644 --- a/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/externalplugins/ExternalPluginManager.java @@ -64,8 +64,8 @@ import net.runelite.client.ui.SplashScreen; import net.runelite.client.util.CountingInputStream; import net.runelite.client.util.Text; import net.runelite.client.util.VerificationException; -import net.runelite.http.api.RuneLiteAPI; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; @@ -95,6 +95,9 @@ public class ExternalPluginManager @Inject private EventBus eventBus; + @Inject + private OkHttpClient okHttpClient; + public void loadExternalPlugins() throws PluginInstantiationException { refreshPlugins(); @@ -208,7 +211,7 @@ public class ExternalPluginManager .addPathSegment(manifest.getCommit() + ".jar") .build(); - try (Response res = RuneLiteAPI.CLIENT.newCall(new Request.Builder().url(url).build()).execute()) + try (Response res = okHttpClient.newCall(new Request.Builder().url(url).build()).execute()) { int fdownloaded = downloaded; downloaded += manifest.getSize(); diff --git a/runelite-client/src/main/java/net/runelite/client/game/HiscoreManager.java b/runelite-client/src/main/java/net/runelite/client/game/HiscoreManager.java index 060df7d785..9e05b20373 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/HiscoreManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/HiscoreManager.java @@ -33,11 +33,10 @@ import javax.inject.Inject; import javax.inject.Singleton; import lombok.AllArgsConstructor; import lombok.Data; -import net.runelite.api.Client; -import net.runelite.client.callback.ClientThread; import net.runelite.http.api.hiscore.HiscoreClient; import net.runelite.http.api.hiscore.HiscoreEndpoint; import net.runelite.http.api.hiscore.HiscoreResult; +import okhttp3.OkHttpClient; @Singleton public class HiscoreManager @@ -53,12 +52,13 @@ public class HiscoreManager static final HiscoreResult EMPTY = new HiscoreResult(); static final HiscoreResult NONE = new HiscoreResult(); - private final HiscoreClient hiscoreClient = new HiscoreClient(); private final LoadingCache hiscoreCache; + private final HiscoreClient hiscoreClient; @Inject - public HiscoreManager(Client client, ScheduledExecutorService executor, ClientThread clientThread) + public HiscoreManager(ScheduledExecutorService executor, OkHttpClient okHttpClient) { + hiscoreClient = new HiscoreClient(okHttpClient); hiscoreCache = CacheBuilder.newBuilder() .maximumSize(128L) .expireAfterWrite(1, TimeUnit.HOURS) diff --git a/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java b/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java index 015311a78b..9fcd1b4c98 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java @@ -60,6 +60,7 @@ import net.runelite.client.util.AsyncBufferedImage; import net.runelite.http.api.item.ItemClient; import net.runelite.http.api.item.ItemPrice; import net.runelite.http.api.item.ItemStats; +import okhttp3.OkHttpClient; @Singleton @Slf4j @@ -82,10 +83,9 @@ public class ItemManager } private final Client client; - private final ScheduledExecutorService scheduledExecutorService; private final ClientThread clientThread; - private final ItemClient itemClient; + private Map itemPrices = Collections.emptyMap(); private Map itemStats = Collections.emptyMap(); private final LoadingCache itemImages; @@ -162,13 +162,12 @@ public class ItemManager build(); @Inject - public ItemManager(Client client, ScheduledExecutorService executor, ClientThread clientThread, - ItemClient itemClient) + public ItemManager(Client client, ScheduledExecutorService scheduledExecutorService, ClientThread clientThread, + OkHttpClient okHttpClient) { this.client = client; - this.scheduledExecutorService = executor; this.clientThread = clientThread; - this.itemClient = itemClient; + this.itemClient = new ItemClient(okHttpClient); scheduledExecutorService.scheduleWithFixedDelay(this::loadPrices, 0, 30, TimeUnit.MINUTES); scheduledExecutorService.submit(this::loadStats); diff --git a/runelite-client/src/main/java/net/runelite/client/game/WorldService.java b/runelite-client/src/main/java/net/runelite/client/game/WorldService.java index 263f712a25..4cc102016d 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/WorldService.java +++ b/runelite-client/src/main/java/net/runelite/client/game/WorldService.java @@ -43,6 +43,7 @@ import net.runelite.client.util.RunnableExceptionLogger; import net.runelite.http.api.worlds.World; import net.runelite.http.api.worlds.WorldClient; import net.runelite.http.api.worlds.WorldResult; +import okhttp3.OkHttpClient; @Singleton @Slf4j @@ -59,12 +60,12 @@ public class WorldService private WorldResult worlds; @Inject - private WorldService(Client client, ScheduledExecutorService scheduledExecutorService, WorldClient worldClient, + private WorldService(Client client, ScheduledExecutorService scheduledExecutorService, OkHttpClient okHttpClient, EventBus eventBus) { this.client = client; this.scheduledExecutorService = scheduledExecutorService; - this.worldClient = worldClient; + this.worldClient = new WorldClient(okHttpClient); this.eventBus = eventBus; scheduledExecutorService.scheduleWithFixedDelay(RunnableExceptionLogger.wrap(this::tick), 0, WORLD_FETCH_TIMER, TimeUnit.MINUTES); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index 56b2435d02..4a8bbe2b13 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -80,6 +80,7 @@ import net.runelite.http.api.hiscore.HiscoreSkill; import net.runelite.http.api.hiscore.SingleHiscoreSkillResult; import net.runelite.http.api.hiscore.Skill; import net.runelite.http.api.item.ItemPrice; +import okhttp3.OkHttpClient; import org.apache.commons.text.WordUtils; @PluginDescriptor( @@ -128,8 +129,6 @@ public class ChatCommandsPlugin extends Plugin @VisibleForTesting static final int ADV_LOG_EXPLOITS_TEXT_INDEX = 1; - private final ChatClient chatClient = new ChatClient(); - private boolean bossLogLoaded; private boolean advLogLoaded; private boolean scrollInterfaceLoaded; @@ -168,6 +167,9 @@ public class ChatCommandsPlugin extends Plugin @Inject private HiscoreClient hiscoreClient; + @Inject + private ChatClient chatClient; + @Override public void startUp() { @@ -213,6 +215,12 @@ public class ChatCommandsPlugin extends Plugin return configManager.getConfig(ChatCommandsConfig.class); } + @Provides + HiscoreClient provideHiscoreClient(OkHttpClient okHttpClient) + { + return new HiscoreClient(okHttpClient); + } + private void setKc(String boss, int killcount) { configManager.setConfiguration("killcount." + client.getUsername().toLowerCase(), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java index 017f229dae..3593832fbb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java @@ -43,7 +43,6 @@ import net.runelite.api.GameState; import net.runelite.api.Skill; import net.runelite.api.WorldType; import net.runelite.api.coords.WorldPoint; -import net.runelite.client.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.StatChanged; import net.runelite.api.events.VarbitChanged; @@ -54,6 +53,7 @@ import net.runelite.client.discord.events.DiscordJoinGame; import net.runelite.client.discord.events.DiscordJoinRequest; import net.runelite.client.discord.events.DiscordReady; import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; import net.runelite.client.events.PartyChanged; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; @@ -65,12 +65,12 @@ import net.runelite.client.util.LinkBrowser; import net.runelite.client.ws.PartyMember; import net.runelite.client.ws.PartyService; import net.runelite.client.ws.WSClient; -import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.ws.messages.party.UserJoin; import net.runelite.http.api.ws.messages.party.UserPart; import net.runelite.http.api.ws.messages.party.UserSync; import okhttp3.Call; import okhttp3.Callback; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; @@ -103,6 +103,9 @@ public class DiscordPlugin extends Plugin @Inject private WSClient wsClient; + @Inject + private OkHttpClient okHttpClient; + private Map skillExp = new HashMap<>(); private NavigationButton discordButton; private boolean loginFlag; @@ -273,7 +276,7 @@ public class DiscordPlugin extends Plugin .url(url) .build(); - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + okHttpClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java index d301bab699..9292359d99 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.examine; import com.google.common.annotations.VisibleForTesting; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; +import com.google.inject.Provides; import java.time.Instant; import java.util.ArrayDeque; import java.util.Deque; @@ -58,6 +59,7 @@ import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.util.QuantityFormatter; import net.runelite.client.util.Text; import net.runelite.http.api.examine.ExamineClient; +import okhttp3.OkHttpClient; /** * Submits examine info to the api @@ -91,6 +93,12 @@ public class ExaminePlugin extends Plugin @Inject private ChatMessageManager chatMessageManager; + @Provides + ExamineClient provideExamineClient(OkHttpClient okHttpClient) + { + return new ExamineClient(okHttpClient); + } + @Subscribe public void onGameStateChanged(GameStateChanged event) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java index acace3fe33..7b1d987c4e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java @@ -41,6 +41,8 @@ import java.time.Instant; import java.util.Comparator; import java.util.function.Supplier; import javax.imageio.ImageIO; +import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ImageIcon; @@ -55,17 +57,18 @@ import net.runelite.client.ui.FontManager; import net.runelite.client.ui.PluginPanel; import net.runelite.client.util.ImageUtil; import net.runelite.client.util.LinkBrowser; -import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.feed.FeedItem; import net.runelite.http.api.feed.FeedItemType; import net.runelite.http.api.feed.FeedResult; import okhttp3.Call; import okhttp3.Callback; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.ResponseBody; @Slf4j +@Singleton class FeedPanel extends PluginPanel { private static final ImageIcon RUNELITE_ICON; @@ -104,12 +107,15 @@ class FeedPanel extends PluginPanel private final FeedConfig config; private final Supplier feedSupplier; + private final OkHttpClient okHttpClient; - FeedPanel(FeedConfig config, Supplier feedSupplier) + @Inject + FeedPanel(FeedConfig config, Supplier feedSupplier, OkHttpClient okHttpClient) { super(true); this.config = config; this.feedSupplier = feedSupplier; + this.okHttpClient = okHttpClient; setBorder(new EmptyBorder(10, 10, 10, 10)); setBackground(ColorScheme.DARK_GRAY_COLOR); @@ -158,7 +164,7 @@ class FeedPanel extends PluginPanel .url(item.getAvatar()) .build(); - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + okHttpClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPlugin.java index df48cf3a56..5da8e4b4c5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPlugin.java @@ -25,7 +25,9 @@ package net.runelite.client.plugins.feed; import com.google.common.base.Suppliers; +import com.google.inject.Binder; import com.google.inject.Provides; +import com.google.inject.TypeLiteral; import java.awt.image.BufferedImage; import java.io.IOException; import java.time.temporal.ChronoUnit; @@ -34,9 +36,9 @@ import java.util.concurrent.TimeUnit; import java.util.function.Supplier; import javax.inject.Inject; import lombok.extern.slf4j.Slf4j; -import net.runelite.client.events.ConfigChanged; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.task.Schedule; @@ -45,6 +47,7 @@ import net.runelite.client.ui.NavigationButton; import net.runelite.client.util.ImageUtil; import net.runelite.http.api.feed.FeedClient; import net.runelite.http.api.feed.FeedResult; +import okhttp3.OkHttpClient; @PluginDescriptor( name = "News Feed", @@ -70,7 +73,7 @@ public class FeedPlugin extends Plugin private FeedPanel feedPanel; private NavigationButton navButton; - private Supplier feedSupplier = Suppliers.memoizeWithExpiration(() -> + private final Supplier feedSupplier = Suppliers.memoizeWithExpiration(() -> { try { @@ -83,10 +86,19 @@ public class FeedPlugin extends Plugin return null; }, 10, TimeUnit.MINUTES); + @Override + public void configure(Binder binder) + { + // CHECKSTYLE:OFF + binder.bind(new TypeLiteral>(){}) + .toInstance(feedSupplier); + // CHECKSTYLE:ON + } + @Override protected void startUp() throws Exception { - feedPanel = new FeedPanel(config, feedSupplier); + feedPanel = injector.getInstance(FeedPanel.class); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "icon.png"); @@ -136,4 +148,10 @@ public class FeedPlugin extends Plugin { return configManager.getConfig(FeedConfig.class); } + + @Provides + FeedClient provideFeedClient(OkHttpClient okHttpClient) + { + return new FeedClient(okHttpClient); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java index 47c3ef6480..8c3c04aea2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java @@ -105,6 +105,7 @@ import net.runelite.http.api.item.ItemStats; import net.runelite.http.api.osbuddy.OSBGrandExchangeClient; import net.runelite.http.api.osbuddy.OSBGrandExchangeResult; import net.runelite.http.api.worlds.WorldType; +import okhttp3.OkHttpClient; import org.apache.commons.lang3.time.DurationFormatUtils; import org.apache.commons.text.similarity.FuzzyScore; @@ -119,7 +120,6 @@ public class GrandExchangePlugin extends Plugin private static final int GE_SLOTS = 8; private static final int OFFER_CONTAINER_ITEM = 21; private static final int OFFER_DEFAULT_ITEM_ID = 6512; - private static final OSBGrandExchangeClient CLIENT = new OSBGrandExchangeClient(); private static final String OSB_GE_TEXT = "
OSBuddy Actively traded price: "; private static final String BUY_LIMIT_GE_TEXT = "
Buy limit: "; @@ -190,6 +190,9 @@ public class GrandExchangePlugin extends Plugin private boolean loginBurstGeUpdates; private static String machineUuid; + @Inject + private OSBGrandExchangeClient osbGrandExchangeClient; + private boolean wasFuzzySearch; static @@ -291,6 +294,18 @@ public class GrandExchangePlugin extends Plugin return configManager.getConfig(GrandExchangeConfig.class); } + @Provides + OSBGrandExchangeClient provideOsbGrandExchangeClient(OkHttpClient okHttpClient) + { + return new OSBGrandExchangeClient(okHttpClient); + } + + @Provides + GrandExchangeClient provideGrandExchangeClient(OkHttpClient okHttpClient) + { + return new GrandExchangeClient(okHttpClient); + } + @Override protected void startUp() { @@ -902,7 +917,7 @@ public class GrandExchangePlugin extends Plugin { try { - final OSBGrandExchangeResult result = CLIENT.lookupItem(itemId); + final OSBGrandExchangeResult result = osbGrandExchangeClient.lookupItem(itemId); if (result != null && result.getOverall_average() > 0) { osbGrandExchangeResult = result; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java index 1a7333ecb1..1843e50c7b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java @@ -70,6 +70,7 @@ import net.runelite.http.api.hiscore.HiscoreSkill; import static net.runelite.http.api.hiscore.HiscoreSkill.*; import net.runelite.http.api.hiscore.HiscoreSkillType; import net.runelite.http.api.hiscore.Skill; +import okhttp3.OkHttpClient; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; @@ -118,15 +119,11 @@ public class HiscorePanel extends PluginPanel HiscoreEndpoint.NORMAL, HiscoreEndpoint.IRONMAN, HiscoreEndpoint.HARDCORE_IRONMAN, HiscoreEndpoint.ULTIMATE_IRONMAN, HiscoreEndpoint.DEADMAN, HiscoreEndpoint.TOURNAMENT }; - @Inject - ScheduledExecutorService executor; - - @Inject - @Nullable - private Client client; - + private final ScheduledExecutorService executor; + private final Client client; private final HiscoreConfig config; private final NameAutocompleter nameAutocompleter; + private final HiscoreClient hiscoreClient; private final IconTextField searchBar; @@ -136,10 +133,6 @@ public class HiscorePanel extends PluginPanel /* Container of all the selectable endpoints (ironman, deadman, etc) */ private final MaterialTabGroup tabGroup; - private final HiscoreClient hiscoreClient = new HiscoreClient(); - - private HiscoreResult result; - /* The currently selected endpoint */ private HiscoreEndpoint selectedEndPoint; @@ -147,11 +140,14 @@ public class HiscorePanel extends PluginPanel private boolean loading = false; @Inject - public HiscorePanel(HiscoreConfig config, NameAutocompleter nameAutocompleter) + public HiscorePanel(ScheduledExecutorService scheduledExecutorService, @Nullable Client client, + HiscoreConfig config, NameAutocompleter nameAutocompleter, OkHttpClient okHttpClient) { - super(); + this.executor = scheduledExecutorService; + this.client = client; this.config = config; this.nameAutocompleter = nameAutocompleter; + this.hiscoreClient = new HiscoreClient(okHttpClient); // The layout seems to be ignoring the top margin and only gives it // a 2-3 pixel margin, so I set the value to 18 to compensate @@ -405,6 +401,7 @@ public class HiscorePanel extends PluginPanel selectedEndPoint = HiscoreEndpoint.NORMAL; } + HiscoreResult result; try { log.debug("Hiscore endpoint " + selectedEndPoint.name() + " selected"); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index d8da160419..6707251dd7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -111,6 +111,7 @@ import net.runelite.http.api.loottracker.LootAggregate; import net.runelite.http.api.loottracker.LootRecord; import net.runelite.http.api.loottracker.LootRecordType; import net.runelite.http.api.loottracker.LootTrackerClient; +import okhttp3.OkHttpClient; import org.apache.commons.text.WordUtils; @PluginDescriptor( @@ -234,6 +235,9 @@ public class LootTrackerPlugin extends Plugin @Inject private LootManager lootManager; + @Inject + private OkHttpClient okHttpClient; + private LootTrackerPanel panel; private NavigationButton navButton; @VisibleForTesting @@ -293,7 +297,7 @@ public class LootTrackerPlugin extends Plugin AccountSession accountSession = sessionManager.getAccountSession(); if (accountSession.getUuid() != null) { - lootTrackerClient = new LootTrackerClient(accountSession.getUuid()); + lootTrackerClient = new LootTrackerClient(okHttpClient, accountSession.getUuid()); } else { @@ -341,7 +345,7 @@ public class LootTrackerPlugin extends Plugin AccountSession accountSession = sessionManager.getAccountSession(); if (accountSession != null) { - lootTrackerClient = new LootTrackerClient(accountSession.getUuid()); + lootTrackerClient = new LootTrackerClient(okHttpClient, accountSession.getUuid()); clientThread.invokeLater(() -> { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index fb6b67450c..7fbae8fc3b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -90,9 +90,9 @@ import net.runelite.client.plugins.raids.solver.Layout; import net.runelite.client.plugins.raids.solver.LayoutSolver; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager; -import net.runelite.client.util.QuantityFormatter; import net.runelite.client.util.HotkeyListener; import net.runelite.client.util.ImageCapture; +import net.runelite.client.util.QuantityFormatter; import net.runelite.client.util.Text; import static net.runelite.client.util.Text.sanitize; import net.runelite.client.ws.PartyMember; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java index c8c02a8bf3..6b8ade7b65 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java @@ -243,7 +243,7 @@ public class SlayerPlugin extends Plugin } @Provides - SlayerConfig getConfig(ConfigManager configManager) + SlayerConfig provideSlayerConfig(ConfigManager configManager) { return configManager.getConfig(SlayerConfig.class); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java index ef3b91f9a0..c4eee8374f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java @@ -49,10 +49,10 @@ import net.runelite.client.callback.ClientThread; import net.runelite.client.game.chatbox.ChatboxPanelManager; import net.runelite.client.game.chatbox.ChatboxTextInput; import net.runelite.client.util.LinkBrowser; -import net.runelite.http.api.RuneLiteAPI; import okhttp3.Call; import okhttp3.Callback; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; @@ -66,6 +66,7 @@ public class WikiSearchChatboxTextInput extends ChatboxTextInput private static final int PREDICTION_DEBOUNCE_DELAY_MS = 200; private final ChatboxPanelManager chatboxPanelManager; + private final OkHttpClient okHttpClient; private final Gson gson = new Gson(); private Future runningRequest = null; @@ -76,10 +77,12 @@ public class WikiSearchChatboxTextInput extends ChatboxTextInput @Inject public WikiSearchChatboxTextInput(ChatboxPanelManager chatboxPanelManager, ClientThread clientThread, - ScheduledExecutorService scheduledExecutorService, @Named("developerMode") final boolean developerMode) + ScheduledExecutorService scheduledExecutorService, @Named("developerMode") final boolean developerMode, + OkHttpClient okHttpClient) { super(chatboxPanelManager, clientThread); this.chatboxPanelManager = chatboxPanelManager; + this.okHttpClient = okHttpClient; lines(1); prompt("OSRS Wiki Search"); @@ -122,7 +125,7 @@ public class WikiSearchChatboxTextInput extends ChatboxTextInput .url(url) .build(); - RuneLiteAPI.CLIENT.newCall(req).enqueue(new Callback() + okHttpClient.newCall(req).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerPlugin.java index 9431eaf5a1..a13fba8575 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerPlugin.java @@ -73,6 +73,7 @@ import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ImageUtil; import net.runelite.client.util.Text; import net.runelite.http.api.xp.XpClient; +import okhttp3.OkHttpClient; @PluginDescriptor( name = "XP Tracker", @@ -116,6 +117,9 @@ public class XpTrackerPlugin extends Plugin @Inject private OverlayManager overlayManager; + @Inject + private XpClient xpClient; + private NavigationButton navButton; @Setter(AccessLevel.PACKAGE) @VisibleForTesting @@ -127,7 +131,6 @@ public class XpTrackerPlugin extends Plugin private long lastXp = 0; private boolean initializeTracker; - private final XpClient xpClient = new XpClient(); private final XpState xpState = new XpState(); private final XpPauseState xpPauseState = new XpPauseState(); @@ -137,6 +140,12 @@ public class XpTrackerPlugin extends Plugin return configManager.getConfig(XpTrackerConfig.class); } + @Provides + XpClient provideXpClient(OkHttpClient okHttpClient) + { + return new XpClient(okHttpClient); + } + @Override public void configure(Binder binder) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java index 30b2c12dc1..6f86e0006e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpupdater/XpUpdaterPlugin.java @@ -26,10 +26,10 @@ */ package net.runelite.client.plugins.xpupdater; +import com.google.inject.Provides; import java.io.IOException; import java.util.Objects; import javax.inject.Inject; -import com.google.inject.Provides; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; @@ -40,11 +40,11 @@ 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.http.api.RuneLiteAPI; import okhttp3.Call; import okhttp3.Callback; import okhttp3.FormBody; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; @@ -66,13 +66,16 @@ public class XpUpdaterPlugin extends Plugin @Inject private Client client; + @Inject + private XpUpdaterConfig config; + + @Inject + private OkHttpClient okHttpClient; + private String lastUsername; private boolean fetchXp; private long lastXp; - @Inject - private XpUpdaterConfig config; - @Provides XpUpdaterConfig getConfig(ConfigManager configManager) { @@ -191,9 +194,9 @@ public class XpUpdaterPlugin extends Plugin } } - private static void sendRequest(String platform, Request request) + private void sendRequest(String platform, Request request) { - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + okHttpClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xtea/XteaPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/xtea/XteaPlugin.java index 3393974613..4eae636114 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xtea/XteaPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xtea/XteaPlugin.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.xtea; +import com.google.inject.Provides; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; @@ -37,6 +38,7 @@ import net.runelite.client.plugins.PluginDescriptor; import net.runelite.http.api.xtea.XteaClient; import net.runelite.http.api.xtea.XteaKey; import net.runelite.http.api.xtea.XteaRequest; +import okhttp3.OkHttpClient; @PluginDescriptor( name = "Xtea", @@ -45,13 +47,20 @@ import net.runelite.http.api.xtea.XteaRequest; @Slf4j public class XteaPlugin extends Plugin { - private final XteaClient xteaClient = new XteaClient(); - private final Set sentRegions = new HashSet<>(); @Inject private Client client; + @Inject + private XteaClient xteaClient; + + @Provides + XteaClient provideXteaClient(OkHttpClient okHttpClient) + { + return new XteaClient(okHttpClient); + } + @Subscribe public void onGameStateChanged(GameStateChanged gameStateChanged) { diff --git a/runelite-client/src/main/java/net/runelite/client/rs/ClientConfigLoader.java b/runelite-client/src/main/java/net/runelite/client/rs/ClientConfigLoader.java index 19c612bd0e..0dbf77b87e 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/ClientConfigLoader.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/ClientConfigLoader.java @@ -28,18 +28,18 @@ package net.runelite.client.rs; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; -import net.runelite.http.api.RuneLiteAPI; +import lombok.AllArgsConstructor; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; +@AllArgsConstructor class ClientConfigLoader { - private ClientConfigLoader() - { - } + private final OkHttpClient okHttpClient; - static RSConfig fetch(HttpUrl url) throws IOException + RSConfig fetch(HttpUrl url) throws IOException { final Request request = new Request.Builder() .url(url) @@ -47,7 +47,7 @@ class ClientConfigLoader final RSConfig config = new RSConfig(); - try (final Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (final Response response = okHttpClient.newCall(request).execute()) { if (!response.isSuccessful()) { 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 d06a55a499..6128c4474b 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 @@ -68,9 +68,9 @@ import net.runelite.client.ui.FatalErrorDialog; import net.runelite.client.ui.SplashScreen; import net.runelite.client.util.CountingInputStream; import net.runelite.client.util.VerificationException; -import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.worlds.World; import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; @@ -83,14 +83,19 @@ public class ClientLoader implements Supplier private static File VANILLA_CACHE = new File(RuneLite.CACHE_DIR, "vanilla.cache"); private static File PATCHED_CACHE = new File(RuneLite.CACHE_DIR, "patched.cache"); + private final OkHttpClient okHttpClient; + private final ClientConfigLoader clientConfigLoader; private ClientUpdateCheckMode updateCheckMode; - private Object client = null; + private final WorldSupplier worldSupplier; - private WorldSupplier worldSupplier = new WorldSupplier(); + private Object client; - public ClientLoader(ClientUpdateCheckMode updateCheckMode) + public ClientLoader(OkHttpClient okHttpClient, ClientUpdateCheckMode updateCheckMode) { + this.okHttpClient = okHttpClient; + this.clientConfigLoader = new ClientConfigLoader(okHttpClient); this.updateCheckMode = updateCheckMode; + this.worldSupplier = new WorldSupplier(okHttpClient); } @Override @@ -187,7 +192,7 @@ public class ClientLoader implements Supplier { try { - RSConfig config = ClientConfigLoader.fetch(url); + RSConfig config = clientConfigLoader.fetch(url); if (Strings.isNullOrEmpty(config.getCodeBase()) || Strings.isNullOrEmpty(config.getInitialJar()) || Strings.isNullOrEmpty(config.getInitialClass())) { @@ -221,7 +226,7 @@ public class ClientLoader implements Supplier @Nonnull private RSConfig downloadFallbackConfig() throws IOException { - RSConfig backupConfig = ClientConfigLoader.fetch(HttpUrl.parse(RuneLiteProperties.getJavConfigBackup())); + RSConfig backupConfig = clientConfigLoader.fetch(HttpUrl.parse(RuneLiteProperties.getJavConfigBackup())); if (Strings.isNullOrEmpty(backupConfig.getCodeBase()) || Strings.isNullOrEmpty(backupConfig.getInitialJar()) || Strings.isNullOrEmpty(backupConfig.getInitialClass())) { @@ -298,7 +303,7 @@ public class ClientLoader implements Supplier .url(url) .build(); - try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) + try (Response response = okHttpClient.newCall(request).execute()) { // Its important to not close the response manually - this should be the only close or // try-with-resources on this stream or it's children diff --git a/runelite-client/src/main/java/net/runelite/client/rs/WorldSupplier.java b/runelite-client/src/main/java/net/runelite/client/rs/WorldSupplier.java index 6e143b1326..16cf8141ad 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/WorldSupplier.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/WorldSupplier.java @@ -33,15 +33,18 @@ import java.util.Queue; import java.util.Random; import java.util.function.Supplier; import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.worlds.World; import net.runelite.http.api.worlds.WorldClient; import net.runelite.http.api.worlds.WorldType; +import okhttp3.OkHttpClient; @Slf4j +@RequiredArgsConstructor class WorldSupplier implements Supplier { + private final OkHttpClient okHttpClient; private final Random random = new Random(System.nanoTime()); private Queue worlds = new ArrayDeque<>(); @@ -55,7 +58,7 @@ class WorldSupplier implements Supplier try { - List newWorlds = new WorldClient(RuneLiteAPI.CLIENT) + List newWorlds = new WorldClient(okHttpClient) .lookupWorlds() .getWorlds() .stream() diff --git a/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java b/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java index a07e0240bb..1823ca734c 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java +++ b/runelite-client/src/main/java/net/runelite/client/util/ImageCapture.java @@ -58,6 +58,7 @@ import okhttp3.Call; import okhttp3.Callback; import okhttp3.HttpUrl; import okhttp3.MediaType; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; @@ -76,6 +77,9 @@ public class ImageCapture @Inject private Notifier notifier; + @Inject + private OkHttpClient okHttpClient; + /** * Saves a screenshot of the client window to the screenshot folder as a PNG, * and optionally uploads it to an image-hosting service. @@ -197,7 +201,7 @@ public class ImageCapture .post(RequestBody.create(JSON, json)) .build(); - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + okHttpClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException ex) diff --git a/runelite-client/src/main/java/net/runelite/client/ws/WSClient.java b/runelite-client/src/main/java/net/runelite/client/ws/WSClient.java index 5b92f5c533..a2f5f7b9e0 100644 --- a/runelite-client/src/main/java/net/runelite/client/ws/WSClient.java +++ b/runelite-client/src/main/java/net/runelite/client/ws/WSClient.java @@ -40,6 +40,7 @@ import net.runelite.http.api.ws.WebsocketGsonFactory; import net.runelite.http.api.ws.WebsocketMessage; import net.runelite.http.api.ws.messages.Handshake; import net.runelite.http.api.ws.messages.party.PartyMessage; +import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import okhttp3.WebSocket; @@ -50,6 +51,7 @@ import okhttp3.WebSocketListener; public class WSClient extends WebSocketListener implements AutoCloseable { private final EventBus eventBus; + private final OkHttpClient okHttpClient; private final Collection> messages = new HashSet<>(); private volatile Gson gson; @@ -58,9 +60,10 @@ public class WSClient extends WebSocketListener implements AutoCloseable private WebSocket webSocket; @Inject - private WSClient(EventBus eventBus) + private WSClient(EventBus eventBus, OkHttpClient okHttpClient) { this.eventBus = eventBus; + this.okHttpClient = okHttpClient; this.gson = WebsocketGsonFactory.build(WebsocketGsonFactory.factory(messages)); } @@ -101,7 +104,7 @@ public class WSClient extends WebSocketListener implements AutoCloseable .url(RuneLiteAPI.getWsEndpoint()) .build(); - webSocket = RuneLiteAPI.CLIENT.newWebSocket(request, this); + webSocket = okHttpClient.newWebSocket(request, this); Handshake handshake = new Handshake(); handshake.setSession(sessionId); diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/PluginManagerTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/PluginManagerTest.java index 003e43361d..2ca7409b8d 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/PluginManagerTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/PluginManagerTest.java @@ -51,13 +51,18 @@ import net.runelite.client.RuneLiteModule; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigItem; import net.runelite.client.eventbus.EventBus; +import okhttp3.OkHttpClient; +import okhttp3.Request; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; +import static org.mockito.ArgumentMatchers.any; import org.mockito.Mock; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) @@ -76,14 +81,18 @@ public class PluginManagerTest @Bind public Client client; - private Set pluginClasses; - private Set configClasses; + private Set> pluginClasses; + private Set> configClasses; @Before public void before() throws IOException { + OkHttpClient okHttpClient = mock(OkHttpClient.class); + when(okHttpClient.newCall(any(Request.class))) + .thenThrow(new RuntimeException("in plugin manager test")); + Injector injector = Guice.createInjector(Modules - .override(new RuneLiteModule(() -> null, true, false, + .override(new RuneLiteModule(okHttpClient, () -> null, true, false, RuneLite.DEFAULT_SESSION_FILE, RuneLite.DEFAULT_CONFIG_FILE)) .with(BoundFieldModule.of(this))); @@ -119,7 +128,7 @@ public class PluginManagerTest pluginManager.loadCorePlugins(); Collection plugins = pluginManager.getPlugins(); long expected = pluginClasses.stream() - .map(cl -> (PluginDescriptor) cl.getAnnotation(PluginDescriptor.class)) + .map(cl -> cl.getAnnotation(PluginDescriptor.class)) .filter(Objects::nonNull) .filter(PluginDescriptor::loadWhenOutdated) .count(); @@ -134,7 +143,7 @@ public class PluginManagerTest plugins.forEach(eventBus::register); expected = pluginClasses.stream() - .map(cl -> (PluginDescriptor) cl.getAnnotation(PluginDescriptor.class)) + .map(cl -> cl.getAnnotation(PluginDescriptor.class)) .filter(Objects::nonNull) .filter(pd -> !pd.developerPlugin()) .count(); @@ -146,16 +155,13 @@ public class PluginManagerTest { List modules = new ArrayList<>(); modules.add(new GraphvizModule()); - modules.add(new RuneLiteModule(() -> null, true, false, + modules.add(new RuneLiteModule(mock(OkHttpClient.class), () -> null, true, false, RuneLite.DEFAULT_SESSION_FILE, RuneLite.DEFAULT_CONFIG_FILE)); PluginManager pluginManager = new PluginManager(true, false, null, null, null, null, null); pluginManager.loadCorePlugins(); - for (Plugin p : pluginManager.getPlugins()) - { - modules.add(p); - } + modules.addAll(pluginManager.getPlugins()); File file = folder.newFile(); try (PrintWriter out = new PrintWriter(file, "UTF-8")) @@ -171,7 +177,7 @@ public class PluginManagerTest @Test public void ensureNoDuplicateConfigKeyNames() { - for (final Class clazz : configClasses) + for (final Class clazz : configClasses) { final Set configKeyNames = new HashSet<>(); diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java index 97c40c0cc3..c2fab2bd0e 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java @@ -49,6 +49,7 @@ import net.runelite.client.chat.ChatCommandManager; import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ChatColorConfig; import net.runelite.client.config.ConfigManager; +import net.runelite.http.api.chat.ChatClient; import net.runelite.http.api.hiscore.HiscoreClient; import net.runelite.http.api.hiscore.HiscoreSkill; import net.runelite.http.api.hiscore.SingleHiscoreSkillResult; @@ -103,6 +104,10 @@ public class ChatCommandsPluginTest @Bind ChatMessageManager chatMessageManager; + @Mock + @Bind + ChatClient chatClient; + @Mock @Bind ChatCommandsConfig chatCommandsConfig; diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/grandexchange/GrandExchangePluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/grandexchange/GrandExchangePluginTest.java index 0c3dc00d04..9eb1f22342 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/grandexchange/GrandExchangePluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/grandexchange/GrandExchangePluginTest.java @@ -50,6 +50,7 @@ import static net.runelite.client.plugins.grandexchange.GrandExchangePlugin.find import static net.runelite.http.api.RuneLiteAPI.GSON; import net.runelite.http.api.ge.GrandExchangeClient; import net.runelite.http.api.ge.GrandExchangeTrade; +import net.runelite.http.api.osbuddy.OSBGrandExchangeClient; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.junit.Before; @@ -108,6 +109,10 @@ public class GrandExchangePluginTest @Bind private GrandExchangeClient grandExchangeClient; + @Mock + @Bind + private OSBGrandExchangeClient osbGrandExchangeClient; + @Mock @Bind private Client client; diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/hiscore/HiscorePanelTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/hiscore/HiscorePanelTest.java index dfee0deeba..ae2f63144b 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/hiscore/HiscorePanelTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/hiscore/HiscorePanelTest.java @@ -24,7 +24,9 @@ */ package net.runelite.client.plugins.hiscore; +import java.util.concurrent.ScheduledExecutorService; import static net.runelite.client.plugins.hiscore.HiscorePanel.formatLevel; +import okhttp3.OkHttpClient; import static org.junit.Assert.assertEquals; import org.junit.Test; import static org.mockito.Mockito.mock; @@ -34,7 +36,7 @@ public class HiscorePanelTest @Test public void testConstructor() { - new HiscorePanel(mock(HiscoreConfig.class), mock(NameAutocompleter.class)); + new HiscorePanel(mock(ScheduledExecutorService.class), null, mock(HiscoreConfig.class), mock(NameAutocompleter.class), mock(OkHttpClient.class)); } @Test diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/raids/RaidsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/raids/RaidsPluginTest.java index dc03a3e556..3bb07bf9a3 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/raids/RaidsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/raids/RaidsPluginTest.java @@ -45,6 +45,7 @@ import net.runelite.client.game.ItemManager; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ImageCapture; import net.runelite.client.ws.PartyService; +import net.runelite.http.api.chat.ChatClient; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -93,6 +94,10 @@ public class RaidsPluginTest @Bind Notifier notifier; + @Mock + @Bind + ChatClient chatClient; + @Mock @Bind RaidsConfig raidsConfig; diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/xptracker/XpTrackerPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/xptracker/XpTrackerPluginTest.java index ca3375bbf4..64a1cec8e6 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/xptracker/XpTrackerPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/xptracker/XpTrackerPluginTest.java @@ -39,6 +39,7 @@ import net.runelite.client.game.NPCManager; import net.runelite.client.game.SkillIconManager; import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.overlay.OverlayManager; +import net.runelite.http.api.xp.XpClient; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; @@ -70,6 +71,10 @@ public class XpTrackerPluginTest @Bind private XpTrackerConfig xpTrackerConfig; + @Mock + @Bind + private XpClient xpClient; + @Mock @Bind private NPCManager npcManager; diff --git a/runelite-client/src/test/java/net/runelite/client/rs/ClientConfigLoaderTest.java b/runelite-client/src/test/java/net/runelite/client/rs/ClientConfigLoaderTest.java index c2c3d3a87e..6ee1ecdf33 100644 --- a/runelite-client/src/test/java/net/runelite/client/rs/ClientConfigLoaderTest.java +++ b/runelite-client/src/test/java/net/runelite/client/rs/ClientConfigLoaderTest.java @@ -29,6 +29,7 @@ import com.google.common.io.CharStreams; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import okhttp3.OkHttpClient; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import org.junit.After; @@ -63,7 +64,7 @@ public class ClientConfigLoaderTest @Test public void testFetch() throws IOException { - final RSConfig config = ClientConfigLoader.fetch(server.url("/")); + final RSConfig config = new ClientConfigLoader(new OkHttpClient()).fetch(server.url("/")); assertEquals("http://oldschool1.runescape.com/", config.getCodeBase()); } From 14ecc93286599a788b3881cb78ed7b323c684d9b Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 26 Jun 2020 18:12:45 -0400 Subject: [PATCH 06/68] client: add --insecure-skip-tls-verification option Additionally this checks if the launcher property is set too which happens if the launcher is passed this flag. --- .../java/net/runelite/client/RuneLite.java | 53 +++++++++++++++++-- .../runelite/client/RuneLiteProperties.java | 6 +++ 2 files changed, 56 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 e9d79d1b5f..29d7fc32c0 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLite.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLite.java @@ -34,10 +34,17 @@ import java.io.File; import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.nio.file.Paths; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.cert.X509Certificate; import java.util.Locale; import javax.annotation.Nullable; import javax.inject.Provider; import javax.inject.Singleton; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; import javax.swing.SwingUtilities; import joptsimple.ArgumentAcceptingOptionSpec; import joptsimple.OptionParser; @@ -233,9 +240,16 @@ public class RuneLite } }); - final OkHttpClient okHttpClient = RuneLiteAPI.CLIENT.newBuilder() - .cache(new Cache(new File(CACHE_DIR, "okhttp"), MAX_OKHTTP_CACHE_SIZE)) - .build(); + OkHttpClient.Builder okHttpClientBuilder = RuneLiteAPI.CLIENT.newBuilder() + .cache(new Cache(new File(CACHE_DIR, "okhttp"), MAX_OKHTTP_CACHE_SIZE)); + + final boolean insecureSkipTlsVerification = options.has("insecure-skip-tls-verification"); + if (insecureSkipTlsVerification || RuneLiteProperties.isInsecureSkipTlsVerification()) + { + setupInsecureTrustManager(okHttpClientBuilder); + } + + final OkHttpClient okHttpClient = okHttpClientBuilder.build(); SplashScreen.init(); SplashScreen.stage(0, "Retrieving client", ""); @@ -433,4 +447,37 @@ public class RuneLite return null; } } + + private static void setupInsecureTrustManager(OkHttpClient.Builder okHttpClientBuilder) + { + try + { + X509TrustManager trustManager = new X509TrustManager() + { + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) + { + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) + { + } + + @Override + public X509Certificate[] getAcceptedIssuers() + { + return new X509Certificate[0]; + } + }; + + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, new TrustManager[]{trustManager}, new SecureRandom()); + okHttpClientBuilder.sslSocketFactory(sc.getSocketFactory(), trustManager); + } + catch (NoSuchAlgorithmException | KeyManagementException ex) + { + log.warn("unable to setup insecure trust manager", ex); + } + } } diff --git a/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java b/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java index 83e30cbfc7..ab0911c1f4 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLiteProperties.java @@ -41,6 +41,7 @@ public class RuneLiteProperties private static final String WIKI_LINK = "runelite.wiki.link"; private static final String PATREON_LINK = "runelite.patreon.link"; private static final String LAUNCHER_VERSION_PROPERTY = "runelite.launcher.version"; + private static final String INSECURE_SKIP_TLS_VERIFICATION_PROPERTY = "runelite.insecure-skip-tls-verification"; private static final String TROUBLESHOOTING_LINK = "runelite.wiki.troubleshooting.link"; private static final String BUILDING_LINK = "runelite.wiki.building.link"; private static final String DNS_CHANGE_LINK = "runelite.dnschange.link"; @@ -110,6 +111,11 @@ public class RuneLiteProperties return System.getProperty(LAUNCHER_VERSION_PROPERTY); } + public static boolean isInsecureSkipTlsVerification() + { + return Boolean.getBoolean(INSECURE_SKIP_TLS_VERIFICATION_PROPERTY); + } + public static String getTroubleshootingLink() { return properties.getProperty(TROUBLESHOOTING_LINK); From 62bbf35baf6061fcb1736c470208507d1d09b800 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 29 Jun 2020 10:27:06 -0400 Subject: [PATCH 07/68] api: add VarbitComposition, config index, and index fileids --- .../main/java/net/runelite/api/Client.java | 15 ++++++ .../java/net/runelite/api/IndexDataBase.java | 7 +++ .../net/runelite/api/VarbitComposition.java | 49 +++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 runelite-api/src/main/java/net/runelite/api/VarbitComposition.java diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index 94c7174325..cb5fee5e71 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -400,6 +400,11 @@ public interface Client extends GameEngine */ IndexDataBase getIndexScripts(); + /** + * Gets the config index. + */ + IndexDataBase getIndexConfig(); + /** * Returns the x-axis base coordinate. *

@@ -745,6 +750,16 @@ public interface Client extends GameEngine */ void setVarbit(Varbits varbit, int value); + /** + * Gets the varbit composition for a given varbit id + * + * @param id + * @return + */ + @VisibleForDevtools + @Nullable + VarbitComposition getVarbit(int id); + /** * Gets the value of a given variable. * diff --git a/runelite-api/src/main/java/net/runelite/api/IndexDataBase.java b/runelite-api/src/main/java/net/runelite/api/IndexDataBase.java index 67de31469e..ba8042c480 100644 --- a/runelite-api/src/main/java/net/runelite/api/IndexDataBase.java +++ b/runelite-api/src/main/java/net/runelite/api/IndexDataBase.java @@ -33,4 +33,11 @@ public interface IndexDataBase * Returns true if any cache overlay in this index is outdated due to hash mismatch */ boolean isOverlayOutdated(); + + /** + * Get the child file ids for a given archive + * @param archiveId + * @return + */ + int[] getFileIds(int archiveId); } diff --git a/runelite-api/src/main/java/net/runelite/api/VarbitComposition.java b/runelite-api/src/main/java/net/runelite/api/VarbitComposition.java new file mode 100644 index 0000000000..1e46fd4d76 --- /dev/null +++ b/runelite-api/src/main/java/net/runelite/api/VarbitComposition.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020, Adam + * 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.api; + +public interface VarbitComposition +{ + /** + * The varp index for this varbit + * + * @return + */ + int getIndex(); + + /** + * The least significant bit of the varbit + * + * @return + */ + int getLeastSignificantBit(); + + /** + * The most significant bit of the varbit (inclusive) + * + * @return + */ + int getMostSignificantBit(); +} From 53c8593929c89290530f18f52eed8117b3ef8a21 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 29 Jun 2020 10:27:51 -0400 Subject: [PATCH 08/68] var inspector: optimize var checking This fixes the inspector incorrectly only checking the first ~2k varbits due to there being some holes now in the varbit ids --- .../client/plugins/devtools/VarInspector.java | 98 +++++++++++-------- 1 file changed, 55 insertions(+), 43 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java index ef8454b712..e39a0bcba2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/VarInspector.java @@ -24,6 +24,8 @@ */ package net.runelite.client.plugins.devtools; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import com.google.inject.Inject; import java.awt.BorderLayout; import java.awt.Dimension; @@ -48,13 +50,16 @@ import javax.swing.border.CompoundBorder; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; +import net.runelite.api.IndexDataBase; import net.runelite.api.VarClientInt; import net.runelite.api.VarClientStr; import net.runelite.api.VarPlayer; +import net.runelite.api.VarbitComposition; import net.runelite.api.Varbits; import net.runelite.api.events.VarClientIntChanged; import net.runelite.api.events.VarClientStrChanged; import net.runelite.api.events.VarbitChanged; +import net.runelite.client.callback.ClientThread; import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.ui.ClientUI; @@ -84,9 +89,10 @@ class VarInspector extends JFrame } private final static int MAX_LOG_ENTRIES = 10_000; + private static final int VARBITS_ARCHIVE_ID = 14; private final Client client; - private final DevToolsPlugin plugin; + private final ClientThread clientThread; private final EventBus eventBus; private final JPanel tracker = new JPanel(); @@ -95,16 +101,16 @@ class VarInspector extends JFrame private int[] oldVarps = null; private int[] oldVarps2 = null; - private int numVarbits = 10000; + private Multimap varbits; private Map varcs = null; @Inject - VarInspector(Client client, EventBus eventBus, DevToolsPlugin plugin) + VarInspector(Client client, ClientThread clientThread, EventBus eventBus, DevToolsPlugin plugin) { - this.eventBus = eventBus; this.client = client; - this.plugin = plugin; + this.clientThread = clientThread; + this.eventBus = eventBus; setTitle("RuneLite Var Inspector"); setIconImage(ClientUI.ICON); @@ -213,63 +219,51 @@ class VarInspector extends JFrame } @Subscribe - public void onVarbitChanged(VarbitChanged ev) + public void onVarbitChanged(VarbitChanged varbitChanged) { + int index = varbitChanged.getIndex(); int[] varps = client.getVarps(); // Check varbits - for (int i = 0; i < numVarbits; i++) + for (int i : varbits.get(index)) { - try + int old = client.getVarbitValue(oldVarps, i); + int neew = client.getVarbitValue(varps, i); + if (old != neew) { - int old = client.getVarbitValue(oldVarps, i); - int neew = client.getVarbitValue(varps, i); - if (old != neew) - { - // Set the varbit so it doesn't show in the varp changes - // However, some varbits share common bits, so we only do it in oldVarps2 - // Example: 4101 collides with 4104-4129 - client.setVarbitValue(oldVarps2, i, neew); + // Set the varbit so it doesn't show in the varp changes + // However, some varbits share common bits, so we only do it in oldVarps2 + // Example: 4101 collides with 4104-4129 + client.setVarbitValue(oldVarps2, i, neew); - String name = String.format("%d", i); - for (Varbits varbit : Varbits.values()) + String name = Integer.toString(i); + for (Varbits varbit : Varbits.values()) + { + if (varbit.getId() == i) { - if (varbit.getId() == i) - { - name = String.format("%s(%d)", varbit.name(), i); - break; - } + name = String.format("%s(%d)", varbit.name(), i); + break; } - addVarLog(VarType.VARBIT, name, old, neew); } - } - catch (IndexOutOfBoundsException e) - { - // We don't know what the last varbit is, so we just hit the end, then set it for future iterations - log.debug("Hit OOB at varbit {}", i); - numVarbits = i; - break; + addVarLog(VarType.VARBIT, name, old, neew); } } // Check varps - for (int i = 0; i < varps.length; i++) + int old = oldVarps2[index]; + int neew = varps[index]; + if (old != neew) { - int old = oldVarps2[i]; - int neew = varps[i]; - if (old != neew) + String name = Integer.toString(index); + for (VarPlayer varp : VarPlayer.values()) { - String name = String.format("%d", i); - for (VarPlayer varp : VarPlayer.values()) + if (varp.getId() == index) { - if (varp.getId() == i) - { - name = String.format("%s(%d)", varp.name(), i); - break; - } + name = String.format("%s(%d)", varp.name(), index); + break; } - addVarLog(VarType.VARP, name, old, neew); } + addVarLog(VarType.VARP, name, old, neew); } System.arraycopy(client.getVarps(), 0, oldVarps, 0, oldVarps.length); @@ -349,6 +343,22 @@ class VarInspector extends JFrame System.arraycopy(client.getVarps(), 0, oldVarps, 0, oldVarps.length); System.arraycopy(client.getVarps(), 0, oldVarps2, 0, oldVarps2.length); varcs = new HashMap<>(client.getVarcMap()); + varbits = HashMultimap.create(); + + clientThread.invoke(() -> + { + // Build varp index -> varbit id map + IndexDataBase indexVarbits = client.getIndexConfig(); + final int[] varbitIds = indexVarbits.getFileIds(VARBITS_ARCHIVE_ID); + for (int id : varbitIds) + { + VarbitComposition varbit = client.getVarbit(id); + if (varbit != null) + { + varbits.put(varbit.getIndex(), id); + } + } + }); eventBus.register(this); setVisible(true); @@ -361,5 +371,7 @@ class VarInspector extends JFrame tracker.removeAll(); eventBus.unregister(this); setVisible(false); + varcs = null; + varbits = null; } } From b0d8092d7deb386e9080577a97db4906ba065fa9 Mon Sep 17 00:00:00 2001 From: Joe Zeffiro Date: Mon, 29 Jun 2020 08:12:12 -0700 Subject: [PATCH 09/68] npc indicators: add (un)tag-all option This modifies the tagged npc list allowing all npcs of a certain name to be tagged Co-authored-by: Adam --- .../npchighlight/NpcIndicatorsConfig.java | 7 ++ .../npchighlight/NpcIndicatorsPlugin.java | 88 +++++++++++++++---- 2 files changed, 80 insertions(+), 15 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java index 3511f7c2f9..739ad7b59f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java @@ -87,6 +87,13 @@ public interface NpcIndicatorsConfig extends Config return ""; } + @ConfigItem( + keyName = "npcToHighlight", + name = "", + description = "" + ) + void setNpcToHighlight(String npcsToHighlight); + @ConfigItem( position = 4, keyName = "npcColor", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java index 107bb58cbd..780375dcdf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java @@ -85,6 +85,9 @@ public class NpcIndicatorsPlugin extends Plugin private static final String TAG = "Tag"; private static final String UNTAG = "Un-tag"; + private static final String TAG_ALL = "Tag-All"; + private static final String UNTAG_ALL = "Un-tag-All"; + private static final Set NPC_MENU_ACTIONS = ImmutableSet.of(MenuAction.NPC_FIRST_OPTION, MenuAction.NPC_SECOND_OPTION, MenuAction.NPC_THIRD_OPTION, MenuAction.NPC_FOURTH_OPTION, MenuAction.NPC_FIFTH_OPTION, MenuAction.SPELL_CAST_ON_NPC, MenuAction.ITEM_USE_ON_NPC); @@ -270,16 +273,48 @@ public class NpcIndicatorsPlugin extends Plugin } else if (menuAction == MenuAction.EXAMINE_NPC && client.isKeyPressed(KeyCode.KC_SHIFT)) { - // Add tag option + // Add tag and tag-all options + final int id = event.getIdentifier(); + final NPC[] cachedNPCs = client.getCachedNPCs(); + final NPC npc = cachedNPCs[id]; + + if (npc == null || npc.getName() == null) + { + return; + } + + final String npcName = npc.getName(); + boolean matchesList = highlights.stream() + .filter(highlight -> !highlight.equalsIgnoreCase(npcName)) + .anyMatch(highlight -> WildcardMatcher.matches(highlight, npcName)); + MenuEntry[] menuEntries = client.getMenuEntries(); - menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); + + // Only add Untag-All option to npcs not highlighted by a wildcard entry, because untag-all will not remove wildcards + if (!matchesList) + { + menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 2); + final MenuEntry tagAllEntry = menuEntries[menuEntries.length - 2] = new MenuEntry(); + tagAllEntry.setOption(highlights.stream().anyMatch(npcName::equalsIgnoreCase) ? UNTAG_ALL : TAG_ALL); + tagAllEntry.setTarget(event.getTarget()); + tagAllEntry.setParam0(event.getActionParam0()); + tagAllEntry.setParam1(event.getActionParam1()); + tagAllEntry.setIdentifier(event.getIdentifier()); + tagAllEntry.setType(MenuAction.RUNELITE.getId()); + } + else + { + menuEntries = Arrays.copyOf(menuEntries, menuEntries.length + 1); + } + final MenuEntry tagEntry = menuEntries[menuEntries.length - 1] = new MenuEntry(); - tagEntry.setOption(highlightedNpcs.stream().anyMatch(npc -> npc.getIndex() == event.getIdentifier()) ? UNTAG : TAG); + tagEntry.setOption(highlightedNpcs.contains(npc) ? UNTAG : TAG); tagEntry.setTarget(event.getTarget()); tagEntry.setParam0(event.getActionParam0()); tagEntry.setParam1(event.getActionParam1()); tagEntry.setIdentifier(event.getIdentifier()); tagEntry.setType(MenuAction.RUNELITE.getId()); + client.setMenuEntries(menuEntries); } } @@ -288,13 +323,13 @@ public class NpcIndicatorsPlugin extends Plugin public void onMenuOptionClicked(MenuOptionClicked click) { if (click.getMenuAction() != MenuAction.RUNELITE || - !(click.getMenuOption().equals(TAG) || click.getMenuOption().equals(UNTAG))) + !(click.getMenuOption().equals(TAG) || click.getMenuOption().equals(UNTAG) || + click.getMenuOption().equals(TAG_ALL) || click.getMenuOption().equals(UNTAG_ALL))) { return; } final int id = click.getId(); - final boolean removed = npcTags.remove(id); final NPC[] cachedNPCs = client.getCachedNPCs(); final NPC npc = cachedNPCs[id]; @@ -303,19 +338,29 @@ public class NpcIndicatorsPlugin extends Plugin return; } - if (removed) + if (click.getMenuOption().equals(TAG) || click.getMenuOption().equals(UNTAG)) { - highlightedNpcs.remove(npc); - memorizedNpcs.remove(npc.getIndex()); + final boolean removed = npcTags.remove(id); + + if (removed) + { + highlightedNpcs.remove(npc); + memorizedNpcs.remove(npc.getIndex()); + } + else + { + if (!client.isInInstancedRegion()) + { + memorizeNpc(npc); + npcTags.add(id); + } + highlightedNpcs.add(npc); + } } else { - if (!client.isInInstancedRegion()) - { - memorizeNpc(npc); - npcTags.add(id); - } - highlightedNpcs.add(npc); + final String name = npc.getName(); + updateNpcsToHighlight(name); } click.consume(); @@ -388,6 +433,19 @@ public class NpcIndicatorsPlugin extends Plugin lastPlayerLocation = client.getLocalPlayer().getWorldLocation(); } + private void updateNpcsToHighlight(String npc) + { + final List highlightedNpcs = new ArrayList<>(highlights); + + if (!highlightedNpcs.removeIf(npc::equalsIgnoreCase)) + { + highlightedNpcs.add(npc); + } + + // this triggers the config change event and rebuilds npcs + config.setNpcToHighlight(Text.toCSV(highlightedNpcs)); + } + private static boolean isInViewRange(WorldPoint wp1, WorldPoint wp2) { int distance = wp1.distanceTo(wp2); @@ -449,7 +507,7 @@ public class NpcIndicatorsPlugin extends Plugin @VisibleForTesting List getHighlights() { - final String configNpcs = config.getNpcToHighlight().toLowerCase(); + final String configNpcs = config.getNpcToHighlight(); if (configNpcs.isEmpty()) { From ac30c8dc3f1d5d4de152bf2e61e6f953d3fb6265 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 1 Jul 2020 11:32:46 -0400 Subject: [PATCH 10/68] npc indicators: fix tag/untag option name selection logic When pressed tag/untag will first check if the npc id is tagged via npcTags, so the menu option should be based off of that, and not whether or not the npc is highlighted generally --- .../client/plugins/npchighlight/NpcIndicatorsPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java index 780375dcdf..0990ff39a7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java @@ -308,7 +308,7 @@ public class NpcIndicatorsPlugin extends Plugin } final MenuEntry tagEntry = menuEntries[menuEntries.length - 1] = new MenuEntry(); - tagEntry.setOption(highlightedNpcs.contains(npc) ? UNTAG : TAG); + tagEntry.setOption(npcTags.contains(npc.getIndex()) ? UNTAG : TAG); tagEntry.setTarget(event.getTarget()); tagEntry.setParam0(event.getActionParam0()); tagEntry.setParam1(event.getActionParam1()); From 8f320cb9edc815a5c606d1c2b4060cefe8b69d83 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 1 Jul 2020 14:26:52 -0400 Subject: [PATCH 11/68] api: add ActorDeath event, remove PlayerDeath --- .../api/events/{PlayerDeath.java => ActorDeath.java} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename runelite-api/src/main/java/net/runelite/api/events/{PlayerDeath.java => ActorDeath.java} (92%) diff --git a/runelite-api/src/main/java/net/runelite/api/events/PlayerDeath.java b/runelite-api/src/main/java/net/runelite/api/events/ActorDeath.java similarity index 92% rename from runelite-api/src/main/java/net/runelite/api/events/PlayerDeath.java rename to runelite-api/src/main/java/net/runelite/api/events/ActorDeath.java index 0b048818c8..e721be6eab 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/PlayerDeath.java +++ b/runelite-api/src/main/java/net/runelite/api/events/ActorDeath.java @@ -25,13 +25,13 @@ package net.runelite.api.events; import lombok.Value; -import net.runelite.api.Player; +import net.runelite.api.Actor; /** - * An event fired when a player dies. + * An event fired when an actor dies. */ @Value -public class PlayerDeath +public class ActorDeath { - private final Player player; + private final Actor actor; } From 6dc6e78f51473c9372306d5995541d1c39a9a6c4 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 1 Jul 2020 14:27:57 -0400 Subject: [PATCH 12/68] plugins: update to use ActorDeath --- .../plugins/screenshot/ScreenshotPlugin.java | 25 +++++++++++-------- .../client/plugins/timers/TimersPlugin.java | 6 ++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java index 8ce1ec7839..7d0c3d18a2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java @@ -43,15 +43,17 @@ import javax.swing.SwingUtilities; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Actor; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Player; import net.runelite.api.Point; import net.runelite.api.SpriteID; +import net.runelite.api.events.ActorDeath; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.GameTick; -import net.runelite.api.events.PlayerDeath; +import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.api.events.WidgetLoaded; import net.runelite.api.widgets.Widget; import static net.runelite.api.widgets.WidgetID.BARROWS_REWARD_GROUP_ID; @@ -63,7 +65,6 @@ import static net.runelite.api.widgets.WidgetID.LEVEL_UP_GROUP_ID; import static net.runelite.api.widgets.WidgetID.QUEST_COMPLETED_GROUP_ID; import static net.runelite.api.widgets.WidgetID.THEATRE_OF_BLOOD_REWARD_GROUP_ID; import net.runelite.api.widgets.WidgetInfo; -import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.client.Notifier; import static net.runelite.client.RuneLite.SCREENSHOT_DIR; import net.runelite.client.config.ConfigManager; @@ -254,16 +255,20 @@ public class ScreenshotPlugin extends Plugin } @Subscribe - public void onPlayerDeath(PlayerDeath playerDeath) + public void onActorDeath(ActorDeath actorDeath) { - Player player = playerDeath.getPlayer(); - if (player == client.getLocalPlayer() && config.screenshotPlayerDeath()) + Actor actor = actorDeath.getActor(); + if (actor instanceof Player) { - takeScreenshot("Death", "Deaths"); - } - else if (player != client.getLocalPlayer() && (player.isFriendsChatMember() || player.isFriend()) && config.screenshotFriendDeath() && player.getCanvasTilePoly() != null) - { - takeScreenshot("Death " + player.getName(), "Deaths"); + Player player = (Player) actor; + if (player == client.getLocalPlayer() && config.screenshotPlayerDeath()) + { + takeScreenshot("Death", "Deaths"); + } + else if (player != client.getLocalPlayer() && (player.isFriendsChatMember() || player.isFriend()) && config.screenshotFriendDeath() && player.getCanvasTilePoly() != null) + { + takeScreenshot("Death " + player.getName(), "Deaths"); + } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java index 24f9d5297c..fe2b8a6184 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java @@ -50,6 +50,7 @@ import net.runelite.api.VarPlayer; import net.runelite.api.Varbits; import net.runelite.api.WorldType; import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.ActorDeath; import net.runelite.api.events.AnimationChanged; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.GameStateChanged; @@ -58,7 +59,6 @@ import net.runelite.api.events.GraphicChanged; import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.MenuOptionClicked; import net.runelite.api.events.NpcDespawned; -import net.runelite.api.events.PlayerDeath; import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.WidgetHiddenChanged; import net.runelite.api.widgets.Widget; @@ -876,9 +876,9 @@ public class TimersPlugin extends Plugin } @Subscribe - public void onPlayerDeath(PlayerDeath playerDeath) + public void onActorDeath(ActorDeath actorDeath) { - if (playerDeath.getPlayer() == client.getLocalPlayer()) + if (actorDeath.getActor() == client.getLocalPlayer()) { infoBoxManager.removeIf(t -> t instanceof TimerTimer && ((TimerTimer) t).getTimer().isRemovedOnDeath()); } From 67030e38a44f355a0131cff5250ed45c7b01dc53 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 1 Jul 2020 14:30:03 -0400 Subject: [PATCH 13/68] slayer plugin: better support multikills This observes deaths of tagged npcs each tick and will use those if available instead of assuming one kill per xpdrop --- .../client/plugins/slayer/SlayerPlugin.java | 77 +++++++++++++++---- .../plugins/slayer/SlayerPluginTest.java | 71 ++++++++++++++++- 2 files changed, 132 insertions(+), 16 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java index 6b8ade7b65..4148822fc6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java @@ -30,11 +30,14 @@ import com.google.inject.Provides; import java.awt.Color; import java.awt.image.BufferedImage; import java.io.IOException; +import static java.lang.Integer.max; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.ScheduledExecutorService; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -44,18 +47,22 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; +import net.runelite.api.Actor; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.GameState; +import net.runelite.api.Hitsplat; import net.runelite.api.ItemID; import net.runelite.api.MessageNode; import net.runelite.api.NPC; import net.runelite.api.NPCComposition; import static net.runelite.api.Skill.SLAYER; import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.ActorDeath; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; +import net.runelite.api.events.HitsplatApplied; import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.StatChanged; @@ -174,6 +181,10 @@ public class SlayerPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private List highlightedTargets = new ArrayList<>(); + private final Set taggedNpcs = new HashSet<>(); + private int taggedNpcsDiedPrevTick; + private int taggedNpcsDiedThisTick; + @Getter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE) private int amount; @@ -237,6 +248,7 @@ public class SlayerPlugin extends Plugin overlayManager.remove(targetMinimapOverlay); removeCounter(); highlightedTargets.clear(); + taggedNpcs.clear(); cachedXp = -1; chatCommandManager.unregisterCommand(TASK_COMMAND_STRING); @@ -260,6 +272,7 @@ public class SlayerPlugin extends Plugin amount = 0; loginFlag = true; highlightedTargets.clear(); + taggedNpcs.clear(); break; case LOGGED_IN: if (config.amount() != -1 @@ -299,6 +312,7 @@ public class SlayerPlugin extends Plugin public void onNpcDespawned(NpcDespawned npcDespawned) { NPC npc = npcDespawned.getNpc(); + taggedNpcs.remove(npc); highlightedTargets.remove(npc); } @@ -391,6 +405,9 @@ public class SlayerPlugin extends Plugin removeCounter(); } } + + taggedNpcsDiedPrevTick = taggedNpcsDiedThisTick; + taggedNpcsDiedThisTick = 0; } @Subscribe @@ -541,20 +558,49 @@ public class SlayerPlugin extends Plugin return; } - final Task task = Task.getTask(taskName); - - // null tasks are technically valid, it only means they arent explicitly defined in the Task enum - // allow them through so that if there is a task capture failure the counter will still work - final int taskKillExp = task != null ? task.getExpectedKillExp() : 0; - - // Only count exp gain as a kill if the task either has no expected exp for a kill, or if the exp gain is equal - // to the expected exp gain for the task. - if (taskKillExp == 0 || taskKillExp == slayerExp - cachedXp) - { - killedOne(); - } - + final int delta = slayerExp - cachedXp; cachedXp = slayerExp; + + log.debug("Slayer xp change delta: {}, killed npcs: {}", delta, taggedNpcsDiedPrevTick); + + final Task task = Task.getTask(taskName); + if (task != null && task.getExpectedKillExp() > 0) + { + // Only decrement a kill if the xp drop matches the expected drop. This is just for Tzhaar tasks. + if (task.getExpectedKillExp() == delta) + { + killed(1); + } + } + else + { + // This is at least one kill, but if we observe multiple tagged NPCs dieing on the previous tick, count them + // instead. + killed(max(taggedNpcsDiedPrevTick, 1)); + } + } + + @Subscribe + public void onHitsplatApplied(HitsplatApplied hitsplatApplied) + { + Actor actor = hitsplatApplied.getActor(); + Hitsplat hitsplat = hitsplatApplied.getHitsplat(); + if (hitsplat.getHitsplatType() == Hitsplat.HitsplatType.DAMAGE_ME && highlightedTargets.contains(actor)) + { + // If the actor is in highlightedTargets it must be an NPC and also a task assignment + taggedNpcs.add((NPC) actor); + } + } + + @Subscribe + public void onActorDeath(ActorDeath actorDeath) + { + Actor actor = actorDeath.getActor(); + if (taggedNpcs.contains(actor)) + { + log.debug("Tagged NPC {} has died", actor.getName()); + ++taggedNpcsDiedThisTick; + } } @Subscribe @@ -576,16 +622,17 @@ public class SlayerPlugin extends Plugin } @VisibleForTesting - void killedOne() + void killed(int amt) { if (amount == 0) { return; } - amount--; + amount -= amt; if (doubleTroubleExtraKill()) { + assert amt == 1; amount--; } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java index 1c0bbb67f9..4cd9bec315 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java @@ -28,19 +28,25 @@ import com.google.inject.Guice; import com.google.inject.testing.fieldbinder.Bind; import com.google.inject.testing.fieldbinder.BoundFieldModule; import java.io.IOException; +import java.util.Arrays; import java.util.concurrent.ScheduledExecutorService; import javax.inject.Inject; import net.runelite.api.ChatMessageType; import static net.runelite.api.ChatMessageType.GAMEMESSAGE; import net.runelite.api.Client; import net.runelite.api.GameState; +import net.runelite.api.Hitsplat; import net.runelite.api.MessageNode; +import net.runelite.api.NPC; +import net.runelite.api.NPCComposition; import net.runelite.api.Player; import net.runelite.api.Skill; import net.runelite.api.coords.LocalPoint; +import net.runelite.api.events.ActorDeath; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; +import net.runelite.api.events.HitsplatApplied; import net.runelite.api.events.StatChanged; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; @@ -771,7 +777,7 @@ public class SlayerPluginTest slayerPlugin.onChatMessage(chatMessage); assertEquals("Suqahs", slayerPlugin.getTaskName()); - slayerPlugin.killedOne(); + slayerPlugin.killed(1); assertEquals(30, slayerPlugin.getAmount()); } @@ -863,4 +869,67 @@ public class SlayerPluginTest verify(infoBoxManager, never()).addInfoBox(any()); } + + @Test + public void testMultikill() + { + final Player player = mock(Player.class); + when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0)); + when(client.getLocalPlayer()).thenReturn(player); + + // Setup xp cache + StatChanged statChanged = new StatChanged( + Skill.SLAYER, + 0, + 1, + 1 + ); + slayerPlugin.onStatChanged(statChanged); + + NPCComposition npcComposition = mock(NPCComposition.class); + when(npcComposition.getActions()).thenReturn(new String[]{"Attack"}); + + NPC npc1 = mock(NPC.class); + when(npc1.getName()).thenReturn("Suqah"); + when(npc1.getTransformedComposition()).thenReturn(npcComposition); + + NPC npc2 = mock(NPC.class); + when(npc2.getName()).thenReturn("Suqah"); + when(npc2.getTransformedComposition()).thenReturn(npcComposition); + + when(client.getNpcs()).thenReturn(Arrays.asList(npc1, npc2)); + + // Set task + Widget npcDialog = mock(Widget.class); + when(npcDialog.getText()).thenReturn(TASK_NEW); + when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); + slayerPlugin.onGameTick(new GameTick()); + + // Damage both npcs + Hitsplat hitsplat = new Hitsplat(Hitsplat.HitsplatType.DAMAGE_ME, 1, 1); + HitsplatApplied hitsplatApplied = new HitsplatApplied(); + hitsplatApplied.setHitsplat(hitsplat); + hitsplatApplied.setActor(npc1); + slayerPlugin.onHitsplatApplied(hitsplatApplied); + + hitsplatApplied.setActor(npc2); + slayerPlugin.onHitsplatApplied(hitsplatApplied); + + // Kill both npcs + slayerPlugin.onActorDeath(new ActorDeath(npc1)); + slayerPlugin.onActorDeath(new ActorDeath(npc2)); + + slayerPlugin.onGameTick(new GameTick()); + + statChanged = new StatChanged( + Skill.SLAYER, + 105, + 2, + 2 + ); + slayerPlugin.onStatChanged(statChanged); + + assertEquals("Suqahs", slayerPlugin.getTaskName()); + assertEquals(229, slayerPlugin.getAmount()); // 2 kills + } } From 83607f1335ef2d3d658606a5073561fc4e49a4e4 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 1 Jul 2020 19:18:30 -0400 Subject: [PATCH 14/68] infobox manager: keep infoboxes in order of insertion Collections.binarySearch() does not guarantee which element is found if there are multiple that compare equal, leaving the order of infoboxes not necessarily in insertion order. This was an unintended side effect of ba9ffb1d600d314100a128db503d10b97a6cbef5 and 406c2bc7dbb8b9db70e8e525fb51aad5f3f56e0d. --- .../ui/overlay/infobox/InfoBoxManager.java | 39 ++++++++++++++++++- .../overlay/infobox/InfoBoxManagerTest.java | 3 ++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java index 766b34c57c..efda12a992 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/infobox/InfoBoxManager.java @@ -29,6 +29,7 @@ import com.google.common.collect.ComparisonChain; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.Predicate; @@ -71,12 +72,12 @@ public class InfoBoxManager synchronized (this) { - int idx = Collections.binarySearch(infoBoxes, infoBox, (b1, b2) -> ComparisonChain + int idx = findInsertionIndex(infoBoxes, infoBox, (b1, b2) -> ComparisonChain .start() .compare(b1.getPriority(), b2.getPriority()) .compare(b1.getPlugin().getName(), b2.getPlugin().getName()) .result()); - infoBoxes.add(idx < 0 ? -idx - 1 : idx, infoBox); + infoBoxes.add(idx, infoBox); } BufferedImage image = infoBox.getImage(); @@ -150,4 +151,38 @@ public class InfoBoxManager infoBox.setScaledImage(resultImage); } + + /** + * Find insertion point for the given key into the given sorted list. If key already exists in the list, + * return the index after the last occurrence. + * @param list + * @param key + * @param c + * @param + * @return + */ + private static int findInsertionIndex(List list, T key, Comparator c) + { + int idx = Collections.binarySearch(list, key, c); + + if (idx < 0) + { + // key isn't found in the list + return -idx - 1; + } + + // list(idx) is equal to key, so it is not necessary to recheck it + for (int i = idx + 1; i < list.size(); ++i) + { + T cur = list.get(i); + int cmp = c.compare(cur, key); + if (cmp > 0) + { + // this is the first element which is greater + return i; + } + } + + return list.size(); + } } diff --git a/runelite-client/src/test/java/net/runelite/client/ui/overlay/infobox/InfoBoxManagerTest.java b/runelite-client/src/test/java/net/runelite/client/ui/overlay/infobox/InfoBoxManagerTest.java index e0ce1e6a6e..49c9c2c484 100644 --- a/runelite-client/src/test/java/net/runelite/client/ui/overlay/infobox/InfoBoxManagerTest.java +++ b/runelite-client/src/test/java/net/runelite/client/ui/overlay/infobox/InfoBoxManagerTest.java @@ -114,5 +114,8 @@ public class InfoBoxManagerTest infoBoxManager.addInfoBox(new TestInfobox(InfoBoxPriority.MED, "three")); assertEquals(3, infoBoxManager.getInfoBoxes().size()); + assertEquals("one", infoBoxManager.getInfoBoxes().get(0).getText()); + assertEquals("two", infoBoxManager.getInfoBoxes().get(1).getText()); + assertEquals("three", infoBoxManager.getInfoBoxes().get(2).getText()); } } \ No newline at end of file From c5f8b88146ac5ef4c191a87c2d57f5e65a41d9d9 Mon Sep 17 00:00:00 2001 From: Trevor Date: Wed, 1 Jul 2020 18:24:35 -0400 Subject: [PATCH 15/68] cache: add default values to HealthBarDefinition --- .../cache/definitions/HealthBarDefinition.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cache/src/main/java/net/runelite/cache/definitions/HealthBarDefinition.java b/cache/src/main/java/net/runelite/cache/definitions/HealthBarDefinition.java index 970d9e8745..3d37861ecf 100644 --- a/cache/src/main/java/net/runelite/cache/definitions/HealthBarDefinition.java +++ b/cache/src/main/java/net/runelite/cache/definitions/HealthBarDefinition.java @@ -31,13 +31,13 @@ public class HealthBarDefinition { public int id; public int field3276; - public int field3277; - public int field3278; - public int field3283; - public int field3272; - public int field3275; - public int healthBarFrontSpriteId; - public int healthBarBackSpriteId; - public int healthScale; - public int healthBarPadding; + public int field3277 = 255; + public int field3278 = 255; + public int field3283 = -1; + public int field3272 = 1; + public int field3275 = 70; + public int healthBarFrontSpriteId = -1; + public int healthBarBackSpriteId = -1; + public int healthScale = 30; + public int healthBarPadding = 0; } From 0fce0f75e297ab5e268a08798a675a60986d82f0 Mon Sep 17 00:00:00 2001 From: Shawn Shadrix Date: Wed, 10 Jun 2020 22:20:16 -0400 Subject: [PATCH 16/68] randomevents: Cleanup and alphabetize code --- .../randomevents/RandomEventConfig.java | 36 +++++++------------ .../randomevents/RandomEventPlugin.java | 22 ++++++------ 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventConfig.java index 5d7fff13e8..14f6673f75 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventConfig.java @@ -44,18 +44,29 @@ public interface RandomEventConfig extends Config keyName = "removeMenuOptions", name = "Remove others' menu options", description = "Remove menu options from random events for other players.", - position = 0 + position = -3 ) default boolean removeMenuOptions() { return true; } + @ConfigItem( + keyName = "notifyAll", + name = "Notify for all events", + description = "", + position = -2, + section = notificationSection + ) + default boolean notifyAllEvents() + { + return false; + } + @ConfigItem( keyName = "notifyDunce", name = "Notify on Surprise Exam", description = "", - position = 1, section = notificationSection ) default boolean notifyDunce() @@ -67,7 +78,6 @@ public interface RandomEventConfig extends Config keyName = "notifyGenie", name = "Notify on Genie", description = "", - position = 2, section = notificationSection ) default boolean notifyGenie() @@ -79,7 +89,6 @@ public interface RandomEventConfig extends Config keyName = "notifyDemon", name = "Notify on Drill Demon", description = "", - position = 3, section = notificationSection ) default boolean notifyDemon() @@ -91,7 +100,6 @@ public interface RandomEventConfig extends Config keyName = "notifyForester", name = "Notify on Freaky Forester", description = "", - position = 4, section = notificationSection ) default boolean notifyForester() @@ -103,7 +111,6 @@ public interface RandomEventConfig extends Config keyName = "notifyFrog", name = "Notify on Kiss the Frog", description = "", - position = 5, section = notificationSection ) default boolean notifyFrog() @@ -115,7 +122,6 @@ public interface RandomEventConfig extends Config keyName = "notifyGravedigger", name = "Notify on Gravedigger", description = "", - position = 6, section = notificationSection ) default boolean notifyGravedigger() @@ -127,7 +133,6 @@ public interface RandomEventConfig extends Config keyName = "notifyMoM", name = "Notify on Mysterious Old Man", description = "", - position = 7, section = notificationSection ) default boolean notifyMoM() @@ -139,7 +144,6 @@ public interface RandomEventConfig extends Config keyName = "notifyBob", name = "Notify on Evil Bob", description = "", - position = 8, section = notificationSection ) default boolean notifyBob() @@ -151,24 +155,10 @@ public interface RandomEventConfig extends Config keyName = "notifyQuiz", name = "Notify on Quiz Master", description = "", - position = 9, section = notificationSection ) default boolean notifyQuiz() { return false; } - - @ConfigItem( - keyName = "notifyAll", - name = "Notify for all events", - description = "", - position = 10, - section = notificationSection - ) - default boolean notifyAllEvents() - { - return false; - } } - diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventPlugin.java index 85aace2e7c..20c9f8fdac 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventPlugin.java @@ -55,28 +55,28 @@ import net.runelite.client.plugins.PluginDescriptor; public class RandomEventPlugin extends Plugin { private static final Set EVENT_NPCS = ImmutableSet.of( - NpcID.DR_JEKYLL, NpcID.DR_JEKYLL_314, NpcID.BEE_KEEPER_6747, NpcID.CAPT_ARNAV, - NpcID.SERGEANT_DAMIEN_6743, + NpcID.DR_JEKYLL, NpcID.DR_JEKYLL_314, NpcID.DRUNKEN_DWARF, - NpcID.FREAKY_FORESTER_6748, - NpcID.GENIE, NpcID.GENIE_327, + NpcID.DUNCE_6749, NpcID.EVIL_BOB, NpcID.EVIL_BOB_6754, - NpcID.POSTIE_PETE_6738, + NpcID.FLIPPA_6744, + NpcID.FREAKY_FORESTER_6748, + NpcID.FROG_5429, + NpcID.GENIE, NpcID.GENIE_327, + NpcID.GILES, NpcID.GILES_5441, NpcID.LEO_6746, + NpcID.MILES, NpcID.MILES_5440, NpcID.MYSTERIOUS_OLD_MAN_6750, NpcID.MYSTERIOUS_OLD_MAN_6751, NpcID.MYSTERIOUS_OLD_MAN_6752, NpcID.MYSTERIOUS_OLD_MAN_6753, + NpcID.NILES, NpcID.NILES_5439, NpcID.PILLORY_GUARD, - NpcID.FLIPPA_6744, + NpcID.POSTIE_PETE_6738, NpcID.QUIZ_MASTER_6755, NpcID.RICK_TURPENTINE, NpcID.RICK_TURPENTINE_376, NpcID.SANDWICH_LADY, - NpcID.DUNCE_6749, - NpcID.NILES, NpcID.NILES_5439, - NpcID.MILES, NpcID.MILES_5440, - NpcID.GILES, NpcID.GILES_5441, - NpcID.FROG_5429 + NpcID.SERGEANT_DAMIEN_6743 ); private static final Set EVENT_OPTIONS = ImmutableSet.of( "Talk-to", From f9ef48584b0373d65702a45189dac2a4643b5b1d Mon Sep 17 00:00:00 2001 From: Shawn Shadrix Date: Wed, 10 Jun 2020 22:23:56 -0400 Subject: [PATCH 17/68] randomevents: Add missing events This commit adds options and handling for the Beekeeper, Sandwich Lady, and Jekyll & Hyde random events. --- .../randomevents/RandomEventConfig.java | 33 +++++++++++++++++++ .../randomevents/RandomEventPlugin.java | 7 ++++ 2 files changed, 40 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventConfig.java index 14f6673f75..537387138f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventConfig.java @@ -161,4 +161,37 @@ public interface RandomEventConfig extends Config { return false; } + + @ConfigItem( + keyName = "notifyJekyll", + name = "Notify on Jekyll & Hyde", + description = "", + section = notificationSection + ) + default boolean notifyJekyll() + { + return false; + } + + @ConfigItem( + keyName = "notifyBeekeeper", + name = "Notify on Beekeeper", + description = "", + section = notificationSection + ) + default boolean notifyBeekeeper() + { + return false; + } + + @ConfigItem( + keyName = "notifySandwich", + name = "Notify on Sandwich Lady", + description = "", + section = notificationSection + ) + default boolean notifySandwich() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventPlugin.java index 20c9f8fdac..2dad55c9bf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/randomevents/RandomEventPlugin.java @@ -177,6 +177,8 @@ public class RandomEventPlugin extends Plugin switch (id) { + case NpcID.BEE_KEEPER_6747: + return config.notifyBeekeeper(); case NpcID.SERGEANT_DAMIEN_6743: return config.notifyDemon(); case NpcID.FREAKY_FORESTER_6748: @@ -186,6 +188,9 @@ public class RandomEventPlugin extends Plugin case NpcID.GENIE: case NpcID.GENIE_327: return config.notifyGenie(); + case NpcID.DR_JEKYLL: + case NpcID.DR_JEKYLL_314: + return config.notifyJekyll(); case NpcID.EVIL_BOB: case NpcID.EVIL_BOB_6754: return config.notifyBob(); @@ -200,6 +205,8 @@ public class RandomEventPlugin extends Plugin return config.notifyQuiz(); case NpcID.DUNCE_6749: return config.notifyDunce(); + case NpcID.SANDWICH_LADY: + return config.notifySandwich(); default: return false; } From 6111a4b790bc77e2a343029dd42eec0adbc8be75 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Thu, 2 Jul 2020 00:36:38 -0400 Subject: [PATCH 18/68] chatnotifications: Only notify on name in player messages (#11874) This commit changes the behavior of notifyOnOwnName so that it only notifies the user when their name is mentioned in a chat message sent by another player to prevent notification spam during PVM and other activities. --- .../chatnotifications/ChatNotificationsConfig.java | 2 +- .../chatnotifications/ChatNotificationsPlugin.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsConfig.java index 8ef956df8d..80044fc340 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsConfig.java @@ -58,7 +58,7 @@ public interface ChatNotificationsConfig extends Config position = 2, keyName = "notifyOnOwnName", name = "Notify on own name", - description = "Notifies you whenever your name is mentioned" + description = "Notifies you whenever someone mentions you by name" ) default boolean notifyOnOwnName() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java index dc663ca462..a412756fa1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java @@ -34,6 +34,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.inject.Inject; +import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.MessageNode; import net.runelite.api.events.ChatMessage; @@ -186,8 +187,11 @@ public class ChatNotificationsPlugin extends Plugin { messageNode.setValue(matcher.replaceAll(usernameReplacer)); update = true; - - if (config.notifyOnOwnName()) + if (config.notifyOnOwnName() && (chatMessage.getType() == ChatMessageType.PUBLICCHAT + || chatMessage.getType() == ChatMessageType.PRIVATECHAT + || chatMessage.getType() == ChatMessageType.FRIENDSCHAT + || chatMessage.getType() == ChatMessageType.MODCHAT + || chatMessage.getType() == ChatMessageType.MODPRIVATECHAT)) { sendNotification(chatMessage); } From d999b5f84653d8e7e3491954af320d108c253f26 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Thu, 2 Jul 2020 01:44:57 -0400 Subject: [PATCH 19/68] SkillChallengeClue: Add Varrock armour 4 to prospector outfit (#12024) --- .../client/plugins/cluescrolls/clues/SkillChallengeClue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/SkillChallengeClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/SkillChallengeClue.java index de66057d6a..a8d0987357 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/SkillChallengeClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/SkillChallengeClue.java @@ -169,7 +169,7 @@ public class SkillChallengeClue extends ClueScroll implements NpcClueScroll, Nam any("", item(ItemID.GRACEFUL_GLOVES), item(ItemID.GRACEFUL_GLOVES_11859), item(ItemID.GRACEFUL_GLOVES_13587), item(ItemID.GRACEFUL_GLOVES_13588), item(ItemID.GRACEFUL_GLOVES_13599), item(ItemID.GRACEFUL_GLOVES_13600), item(ItemID.GRACEFUL_GLOVES_13611), item(ItemID.GRACEFUL_GLOVES_13612), item(ItemID.GRACEFUL_GLOVES_13623), item(ItemID.GRACEFUL_GLOVES_13624), item(ItemID.GRACEFUL_GLOVES_13635), item(ItemID.GRACEFUL_GLOVES_13636), item(ItemID.GRACEFUL_GLOVES_13675), item(ItemID.GRACEFUL_GLOVES_13676), item(ItemID.GRACEFUL_GLOVES_21073), item(ItemID.GRACEFUL_GLOVES_21075), item(ItemID.GRACEFUL_GLOVES_24755), item(ItemID.GRACEFUL_GLOVES_24757)), any("", item(ItemID.GRACEFUL_BOOTS), item(ItemID.GRACEFUL_BOOTS_11861), item(ItemID.GRACEFUL_BOOTS_13589), item(ItemID.GRACEFUL_BOOTS_13590), item(ItemID.GRACEFUL_BOOTS_13601), item(ItemID.GRACEFUL_BOOTS_13602), item(ItemID.GRACEFUL_BOOTS_13613), item(ItemID.GRACEFUL_BOOTS_13614), item(ItemID.GRACEFUL_BOOTS_13625), item(ItemID.GRACEFUL_BOOTS_13626), item(ItemID.GRACEFUL_BOOTS_13637), item(ItemID.GRACEFUL_BOOTS_13638), item(ItemID.GRACEFUL_BOOTS_13677), item(ItemID.GRACEFUL_BOOTS_13678), item(ItemID.GRACEFUL_BOOTS_21076), item(ItemID.GRACEFUL_BOOTS_21078), item(ItemID.GRACEFUL_BOOTS_24758), item(ItemID.GRACEFUL_BOOTS_24760)))), new SkillChallengeClue("Mix an anti-venom potion.", item(ItemID.ANTIDOTE4_5952), xOfItem(ItemID.ZULRAHS_SCALES, 20)), - new SkillChallengeClue("Mine a piece of Runite ore", "mine a piece of runite ore whilst sporting the finest mining gear.", true, ANY_PICKAXE, all("Prospector kit", item(ItemID.PROSPECTOR_HELMET), item(ItemID.PROSPECTOR_JACKET), item(ItemID.PROSPECTOR_LEGS), item(ItemID.PROSPECTOR_BOOTS))), + new SkillChallengeClue("Mine a piece of Runite ore", "mine a piece of runite ore whilst sporting the finest mining gear.", true, ANY_PICKAXE, all("Prospector kit", item(ItemID.PROSPECTOR_HELMET), any("", item(ItemID.PROSPECTOR_JACKET), item(ItemID.VARROCK_ARMOUR_4)), item(ItemID.PROSPECTOR_LEGS), item(ItemID.PROSPECTOR_BOOTS))), new SkillChallengeClue("Steal a gem from the Ardougne market."), new SkillChallengeClue("Pickpocket an elf."), new SkillChallengeClue("Bind a blood rune at the blood altar.", item(ItemID.DARK_ESSENCE_FRAGMENTS)), From 2240d555819eabd11052590509c0167dd14b4a14 Mon Sep 17 00:00:00 2001 From: RuneLite Cache-Code Autoupdater Date: Thu, 2 Jul 2020 10:32:37 +0000 Subject: [PATCH 20/68] Update Item IDs to 2020-07-02-rev190 --- runelite-api/src/main/java/net/runelite/api/ItemID.java | 5 +++++ runelite-api/src/main/java/net/runelite/api/NullItemID.java | 2 ++ 2 files changed, 7 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/ItemID.java b/runelite-api/src/main/java/net/runelite/api/ItemID.java index 3ed8668b67..83d3d27994 100644 --- a/runelite-api/src/main/java/net/runelite/api/ItemID.java +++ b/runelite-api/src/main/java/net/runelite/api/ItemID.java @@ -11576,5 +11576,10 @@ public final class ItemID public static final int ZIGGY = 24849; public static final int SOFT_CLAY_PACK_24851 = 24851; public static final int BAG_FULL_OF_GEMS_24853 = 24853; + public static final int MYTHICAL_MAX_CAPE = 24855; + public static final int MYTHICAL_MAX_HOOD = 24857; + public static final int WARRIOR_PATH_STARTER_KIT = 24859; + public static final int WIZARD_PATH_STARTER_KIT = 24860; + public static final int RANGER_PATH_STARTER_KIT = 24861; /* This file is automatically generated. Do not edit. */ } diff --git a/runelite-api/src/main/java/net/runelite/api/NullItemID.java b/runelite-api/src/main/java/net/runelite/api/NullItemID.java index 66cfc9b1df..ec4e73815d 100644 --- a/runelite-api/src/main/java/net/runelite/api/NullItemID.java +++ b/runelite-api/src/main/java/net/runelite/api/NullItemID.java @@ -13068,5 +13068,7 @@ public final class NullItemID public static final int NULL_24850 = 24850; public static final int NULL_24852 = 24852; public static final int NULL_24854 = 24854; + public static final int NULL_24856 = 24856; + public static final int NULL_24858 = 24858; /* This file is automatically generated. Do not edit. */ } From 07cee7070916d23ef78a8ae99fedabcfed829e72 Mon Sep 17 00:00:00 2001 From: RuneLite Cache-Code Autoupdater Date: Thu, 2 Jul 2020 10:32:38 +0000 Subject: [PATCH 21/68] Update Object IDs to 2020-07-02-rev190 --- runelite-api/src/main/java/net/runelite/api/ObjectID.java | 1 + 1 file changed, 1 insertion(+) diff --git a/runelite-api/src/main/java/net/runelite/api/ObjectID.java b/runelite-api/src/main/java/net/runelite/api/ObjectID.java index d050738b5f..6200b65794 100644 --- a/runelite-api/src/main/java/net/runelite/api/ObjectID.java +++ b/runelite-api/src/main/java/net/runelite/api/ObjectID.java @@ -20090,5 +20090,6 @@ public final class ObjectID public static final int STAIRS_39609 = 39609; public static final int CRYPT = 39617; public static final int COFFIN_39620 = 39620; + public static final int MOUNTED_MAX_CAPE_39621 = 39621; /* This file is automatically generated. Do not edit. */ } From 33992efac709654b91d3850e1e9499316ec40790 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Thu, 2 Jul 2020 04:44:21 -0600 Subject: [PATCH 22/68] runelite-client: remove removed scripts --- .../main/java/net/runelite/api/ScriptID.java | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/ScriptID.java b/runelite-api/src/main/java/net/runelite/api/ScriptID.java index 58d7b9f0d0..039d2c0f48 100644 --- a/runelite-api/src/main/java/net/runelite/api/ScriptID.java +++ b/runelite-api/src/main/java/net/runelite/api/ScriptID.java @@ -109,17 +109,6 @@ public final class ScriptID @ScriptArguments() public static final int CHAT_PROMPT_INIT = 223; - /** - * Displays the game messages when clicking on an item inside the Items Kept on Death interface - *

    - *
  • int (boolean) Item kept on death
  • - *
  • int Item Quantity
  • - *
  • String Item Name
  • - *
- */ - @ScriptArguments(integer = 2, string = 1) - public static final int DEATH_KEEP_ITEM_EXAMINE = 1603; - /** * Checks the state of the given stash unit. *
    @@ -204,12 +193,6 @@ public final class ScriptID @ScriptArguments(string = 1) public static final int FRIENDS_CHAT_SEND_KICK = 215; - /** - * Builds the items kept on death widget - */ - @ScriptArguments(integer = 4, string = 2) - public static final int DEATH_KEEP_BUILD = 1601; - /** * Builds the widget that holds all of the players inside a friends chat */ From 9e9f428fe7b3cc580d94d25c472c0b166fa04a03 Mon Sep 17 00:00:00 2001 From: Trevor Date: Wed, 24 Jun 2020 18:29:14 -0400 Subject: [PATCH 23/68] raid plugin: add raid scouted/reset events --- .../runelite/client/plugins/raids/Raid.java | 2 +- .../client/plugins/raids/RaidRoom.java | 2 +- .../client/plugins/raids/RaidsPlugin.java | 9 ++++ .../client/plugins/raids/RoomType.java | 2 +- .../plugins/raids/events/RaidReset.java | 34 +++++++++++++++ .../plugins/raids/events/RaidScouted.java | 42 +++++++++++++++++++ 6 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/raids/events/RaidReset.java create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/raids/events/RaidScouted.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/Raid.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/Raid.java index d881351cbd..662aac5981 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/Raid.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/Raid.java @@ -31,7 +31,7 @@ import net.runelite.api.coords.WorldPoint; import net.runelite.client.plugins.raids.solver.Layout; import net.runelite.client.plugins.raids.solver.Room; -class Raid +public class Raid { @Getter private final RaidRoom[] rooms = new RaidRoom[16]; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidRoom.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidRoom.java index 06101d6e08..df71695898 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidRoom.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidRoom.java @@ -29,7 +29,7 @@ import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @Getter -enum RaidRoom +public enum RaidRoom { START("Start", RoomType.START), END("End", RoomType.END), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index 7fbae8fc3b..57b74bd469 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -77,10 +77,13 @@ import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.chat.QueuedMessage; import net.runelite.client.config.ConfigManager; import net.runelite.client.config.RuneLiteConfig; +import net.runelite.client.eventbus.EventBus; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ChatInput; import net.runelite.client.events.ConfigChanged; import net.runelite.client.events.OverlayMenuClicked; +import net.runelite.client.plugins.raids.events.RaidReset; +import net.runelite.client.plugins.raids.events.RaidScouted; import net.runelite.client.game.ItemManager; import net.runelite.client.game.SpriteManager; import net.runelite.client.input.KeyManager; @@ -179,6 +182,9 @@ public class RaidsPlugin extends Plugin @Inject private ImageCapture imageCapture; + @Inject + private EventBus eventBus; + @Getter private final Set roomWhitelist = new HashSet(); @@ -506,6 +512,8 @@ public class RaidsPlugin extends Plugin { sendRaidLayoutMessage(); } + + eventBus.post(new RaidScouted(raid, firstSolve)); } private void sendRaidLayoutMessage() @@ -1008,5 +1016,6 @@ public class RaidsPlugin extends Plugin raid = null; chestOpened = false; updateInfoBoxState(); + eventBus.post(new RaidReset()); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RoomType.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RoomType.java index 686391e563..0ddb2085fe 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RoomType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RoomType.java @@ -30,7 +30,7 @@ import lombok.Getter; @AllArgsConstructor @Getter -enum RoomType +public enum RoomType { START("Start", '#'), END("End", '¤'), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/events/RaidReset.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/events/RaidReset.java new file mode 100644 index 0000000000..e1d6f9aa83 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/events/RaidReset.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020, Trevor + * 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.raids.events; + +/** + * An event that fires when the raid plugin resets + * + * This happens when the player leaves a raid and when the raid plugin turns off + */ +public class RaidReset +{ +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/events/RaidScouted.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/events/RaidScouted.java new file mode 100644 index 0000000000..b57152d975 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/events/RaidScouted.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020, Trevor + * 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.raids.events; + +import lombok.Value; +import net.runelite.client.plugins.raids.Raid; + +/** + * An event that fires when the player scouts a raid + * + * This will fire every time the raid plugin successfully scouts a raid but mostly fires at LOGGED_IN gamestate changes + * This event only fires in scoutable raids (not challenge mode) + * The raid object is not guaranteed to change in between events + */ +@Value +public class RaidScouted +{ + private Raid raid; + private boolean firstScout; +} From c2a33e2b9797b1d752ac1f0aef3626f5232f5644 Mon Sep 17 00:00:00 2001 From: CopyPastaOSRS <66518222+CopyPastaOSRS@users.noreply.github.com> Date: Sat, 4 Jul 2020 00:50:35 +0200 Subject: [PATCH 24/68] WidgetOverlay: Make encounter health bar moveable (#11938) --- .../src/main/java/net/runelite/api/widgets/WidgetID.java | 6 ++++++ .../src/main/java/net/runelite/api/widgets/WidgetInfo.java | 4 +++- .../java/net/runelite/client/ui/overlay/WidgetOverlay.java | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java index 1e6a4229d1..be4e856996 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java @@ -154,6 +154,7 @@ public class WidgetID public static final int GENERIC_SCROLL_GROUP_ID = 625; public static final int GAUNTLET_TIMER_GROUP_ID = 637; public static final int BANK_PIN_GROUP_ID = 213; + public static final int HEALTH_OVERLAY_BAR_GROUP_ID = 303; static class WorldMap { @@ -916,4 +917,9 @@ public class WidgetID { static final int CONTAINER = 0; } + + static class EncounterHealthBar + { + static final int CONTAINER = 6; + } } diff --git a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java index 46f7f96b1f..a8ba4b369e 100644 --- a/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java +++ b/runelite-api/src/main/java/net/runelite/api/widgets/WidgetInfo.java @@ -537,7 +537,9 @@ public enum WidgetInfo SKILLS_CONTAINER(WidgetID.SKILLS_GROUP_ID, WidgetID.Skills.CONTAINER), - GAUNTLET_TIMER_CONTAINER(WidgetID.GAUNTLET_TIMER_GROUP_ID, WidgetID.GauntletTimer.CONTAINER); + GAUNTLET_TIMER_CONTAINER(WidgetID.GAUNTLET_TIMER_GROUP_ID, WidgetID.GauntletTimer.CONTAINER), + + HEALTH_OVERLAY_BAR(WidgetID.HEALTH_OVERLAY_BAR_GROUP_ID, WidgetID.EncounterHealthBar.CONTAINER); private final int groupId; private final int childId; diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java index 4ab0ebe31c..1f2da4539b 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/WidgetOverlay.java @@ -59,6 +59,7 @@ public class WidgetOverlay extends Overlay .put(WidgetInfo.LMS_INFO, OverlayPosition.TOP_RIGHT) .put(WidgetInfo.LMS_KDA, OverlayPosition.TOP_RIGHT) .put(WidgetInfo.GAUNTLET_TIMER_CONTAINER, OverlayPosition.TOP_LEFT) + .put(WidgetInfo.HEALTH_OVERLAY_BAR, OverlayPosition.TOP_CENTER) .build(); public static Collection createOverlays(final Client client) From e3163c80ae7f34ca95b34973bc7c79a60b95600d Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 3 Jul 2020 17:51:08 -0400 Subject: [PATCH 25/68] plugin manager: remove extra injectMembers() call This has been here a long time, but as far as we can tell is no longer necessary. It is causing double instantiation of classes which are only injected a single place. --- .../src/main/java/net/runelite/client/plugins/PluginManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java index d3f430259b..4aeb37b213 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java @@ -525,7 +525,6 @@ public class PluginManager binder.install(plugin); }; Injector pluginInjector = parent.createChildInjector(pluginModule); - pluginInjector.injectMembers(plugin); plugin.injector = pluginInjector; } catch (CreationException ex) From 6d39bc8e2c6ef193861c35aa117e5e59b5903152 Mon Sep 17 00:00:00 2001 From: melkypie <5113962+melkypie@users.noreply.github.com> Date: Sat, 4 Jul 2020 14:07:03 +0300 Subject: [PATCH 26/68] tooltips: make overlay color background option affect tooltips --- .../runelite/client/ui/overlay/tooltip/TooltipOverlay.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/tooltip/TooltipOverlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/tooltip/TooltipOverlay.java index f808fa49f2..1f68a348f4 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/tooltip/TooltipOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/tooltip/TooltipOverlay.java @@ -39,6 +39,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.components.LayoutableRenderableEntity; +import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TooltipComponent; @Singleton @@ -103,12 +104,17 @@ public class TooltipOverlay extends Overlay if (tooltip.getComponent() != null) { entity = tooltip.getComponent(); + if (entity instanceof PanelComponent) + { + ((PanelComponent) entity).setBackgroundColor(runeLiteConfig.overlayBackgroundColor()); + } } else { final TooltipComponent tooltipComponent = new TooltipComponent(); tooltipComponent.setModIcons(client.getModIcons()); tooltipComponent.setText(tooltip.getText()); + tooltipComponent.setBackgroundColor(runeLiteConfig.overlayBackgroundColor()); entity = tooltipComponent; } From 1087c193bd78a1e9f9367e9f34caf02c50bb61a1 Mon Sep 17 00:00:00 2001 From: MMagicala <36617521+MMagicala@users.noreply.github.com> Date: Sat, 4 Jul 2020 13:15:03 -0700 Subject: [PATCH 27/68] skillcalculator: Fix Maple longbow (u) xp (#12064) --- .../client/plugins/skillcalculator/skill_fletching.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/skillcalculator/skill_fletching.json b/runelite-client/src/main/resources/net/runelite/client/plugins/skillcalculator/skill_fletching.json index 13c04e5a1c..60214cc263 100644 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/skillcalculator/skill_fletching.json +++ b/runelite-client/src/main/resources/net/runelite/client/plugins/skillcalculator/skill_fletching.json @@ -328,7 +328,7 @@ "level": 55, "icon": 62, "name": "Maple Longbow (U)", - "xp": 58.5 + "xp": 58.3 }, { "level": 55, From 7b1414d0c064e2b436cad196b00c5e8fcfa55489 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Sun, 5 Jul 2020 01:43:32 -0400 Subject: [PATCH 28/68] discord: Fix Hosidius/Tithe Farm regionIDs --- .../runelite/client/plugins/discord/DiscordGameEventType.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 21a474776b..cc18573c4d 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 @@ -113,7 +113,7 @@ enum DiscordGameEventType CITY_GOBLIN_VILLAGE("Goblin Village" , DiscordAreaType.CITIES, 11830), CITY_GUTANOTH("Gu'Tanoth" , DiscordAreaType.CITIES, 10031), CITY_GWENITH("Gwenith", DiscordAreaType.CITIES, 8501, 8757, 9013), - CITY_HOSIDIUS_HOUSE("Hosidius" , DiscordAreaType.CITIES, 6713, 6712, 6455, 6711, 6710, 6965, 6966, 7222, 7223, 6967), + CITY_HOSIDIUS_HOUSE("Hosidius" , DiscordAreaType.CITIES, 6710, 6711, 6712, 6713, 6455, 6456, 6965, 6966, 6967, 6968, 7221, 7223, 7224, 7478, 7479), CITY_JATISZO("Jatizso" , DiscordAreaType.CITIES, 9531), CITY_JIGGIG("Jiggig" , DiscordAreaType.CITIES, 9775), CITY_KARAMJA("Karamja" , DiscordAreaType.CITIES, 11569, 11568, 11567, 11566, 11313, 11312, 11311), @@ -253,7 +253,7 @@ enum DiscordGameEventType MG_ROGUES_DEN("Rogues' Den", DiscordAreaType.MINIGAMES, 11855, 11854, 12111, 12110), MG_SORCERESS_GARDEN("Sorceress's Garden", DiscordAreaType.MINIGAMES, 11605), MG_TEMPLE_TREKKING("Temple Trekking", DiscordAreaType.MINIGAMES, 8014, 8270, 8256, 8782, 9038, 9294, 9550, 9806), - MG_TITHE_FARM("Tithe Farm", DiscordAreaType.MINIGAMES, 6968), + MG_TITHE_FARM("Tithe Farm", DiscordAreaType.MINIGAMES, 7222), MG_TROUBLE_BREWING("Trouble Brewing", DiscordAreaType.MINIGAMES, 15150), MG_TZHAAR_FIGHT_CAVES("Tzhaar Fight Caves", DiscordAreaType.MINIGAMES, 9551), MG_TZHAAR_FIGHT_PITS("Tzhaar Fight Pits", DiscordAreaType.MINIGAMES, 9552), From 11cd19c2ce3fcae20aaa8b75f3b3c32f2ed48a64 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 5 Jul 2020 17:34:04 -0400 Subject: [PATCH 29/68] player composition: add isFemale --- .../src/main/java/net/runelite/api/PlayerComposition.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/PlayerComposition.java b/runelite-api/src/main/java/net/runelite/api/PlayerComposition.java index 20ac41b6cb..7920c36eed 100644 --- a/runelite-api/src/main/java/net/runelite/api/PlayerComposition.java +++ b/runelite-api/src/main/java/net/runelite/api/PlayerComposition.java @@ -32,6 +32,13 @@ import net.runelite.api.kit.KitType; */ public interface PlayerComposition { + /** + * Checks if the player is female. + * + * @return true if the player is female + */ + boolean isFemale(); + /** * Gets an array of IDs related to equipment slots. *

    From 277eee79dab5a6befe5dd8efeab420ddd144a27a Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Sat, 4 Jul 2020 02:50:33 -0400 Subject: [PATCH 30/68] agility: add missing Meiyerditch obstacle highlights --- .../java/net/runelite/client/plugins/agility/Obstacles.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/Obstacles.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/Obstacles.java index bda6037a6c..b1b58b5f17 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/Obstacles.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/Obstacles.java @@ -88,7 +88,8 @@ class Obstacles SHELF_18096, FLOORBOARDS_18097, FLOORBOARDS_18098, WASHING_LINE_18099, WASHING_LINE_18100, NULL_18135, NULL_18136, SHELF_18105, SHELF_18106, SHELF_18107, SHELF_18108, FLOORBOARDS_18109, FLOORBOARDS_18110, FLOORBOARDS_18112, FLOORBOARDS_18111, FLOORBOARDS_18114, FLOORBOARDS_18113, - NULL_18116, FLOORBOARDS_18117, FLOORBOARDS_18118, STAIRS_DOWN, WALL_17980, + NULL_18116, FLOORBOARDS_18117, FLOORBOARDS_18118, STAIRS_DOWN, WALL_17980, BARRICADE_18054, LADDER_17999, + LADDER_18000, LADDER_18001, LADDER_18002, ROCKY_SURFACE, WALL_39172, WALL_39173, // Werewolf STEPPING_STONE_11643, HURDLE, HURDLE_11639, HURDLE_11640, PIPE_11657, SKULL_SLOPE, ZIP_LINE, ZIP_LINE_11645, ZIP_LINE_11646, From 3988ef0a4ea0cc0aac9f995eb07d3422f6f118ec Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Mon, 6 Jul 2020 23:08:30 -0400 Subject: [PATCH 31/68] discord: Fix Prifddinas area region IDs (#12059) --- .../client/plugins/discord/DiscordGameEventType.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 cc18573c4d..2df8d6bd60 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 @@ -86,7 +86,7 @@ enum DiscordGameEventType BOSS_SMOKE_DEVIL("Thermonuclear smoke devil", DiscordAreaType.BOSSES, 9363, 9619), BOSS_VORKATH("Vorkath", DiscordAreaType.BOSSES, 9023), BOSS_WINTERTODT("Wintertodt", DiscordAreaType.BOSSES, 6462), - BOSS_ZALCANO("Zalcano", DiscordAreaType.BOSSES, 13250), + BOSS_ZALCANO("Zalcano", DiscordAreaType.BOSSES, 12126), BOSS_ZULRAH("Zulrah", DiscordAreaType.BOSSES, 9007), BOSS_NIGHTMARE("Nightmare of Ashihama", DiscordAreaType.BOSSES, 15515), @@ -112,7 +112,7 @@ enum DiscordGameEventType CITY_FALADOR("Falador" , DiscordAreaType.CITIES, 11828, 11572, 11571, 11827, 12084), CITY_GOBLIN_VILLAGE("Goblin Village" , DiscordAreaType.CITIES, 11830), CITY_GUTANOTH("Gu'Tanoth" , DiscordAreaType.CITIES, 10031), - CITY_GWENITH("Gwenith", DiscordAreaType.CITIES, 8501, 8757, 9013), + CITY_GWENITH("Gwenith", DiscordAreaType.CITIES, 8757), CITY_HOSIDIUS_HOUSE("Hosidius" , DiscordAreaType.CITIES, 6710, 6711, 6712, 6713, 6455, 6456, 6965, 6966, 6967, 6968, 7221, 7223, 7224, 7478, 7479), CITY_JATISZO("Jatizso" , DiscordAreaType.CITIES, 9531), CITY_JIGGIG("Jiggig" , DiscordAreaType.CITIES, 9775), @@ -128,6 +128,7 @@ enum DiscordGameEventType CITY_MORTTON("Mort'ton" , DiscordAreaType.CITIES, 13875), CITY_MOR_UI_REK("Mor UI Rek" , DiscordAreaType.CITIES, 9808, 9807, 10064, 10063), CITY_MOUNT_KARUULM("Mount Karuulm", DiscordAreaType.CITIES, 5179, 4923, 5180), + CITY_MYNYDD("Mynydd", DiscordAreaType.CITIES, 8501), CITY_NARDAH("Nardah" , DiscordAreaType.CITIES, 13613), CITY_NEITIZNOT("Neitiznot" , DiscordAreaType.CITIES, 9275), CITY_PISCATORIS("Piscatoris" , DiscordAreaType.CITIES, 9273), @@ -136,7 +137,7 @@ enum DiscordGameEventType CITY_PORT_PHASMATYS("Port Phasmatys" , DiscordAreaType.CITIES, 14646), CITY_PORT_SARIM("Port Sarim" , DiscordAreaType.CITIES, 12082), CITY_PISCARILIUS_HOUSE("Port Piscarilius" , DiscordAreaType.CITIES, 6971, 7227, 6970, 7226), - CITY_PRIFDDINAS("Prifddinas", DiscordAreaType.CITIES, 12894, 12895, 13150, 13151), + CITY_PRIFDDINAS("Prifddinas", DiscordAreaType.CITIES, 8499, 8500, 8755, 8756, 9011, 9012, 9013, 12894, 12895, 13150, 13151), CITY_RELLEKKA("Rellekka" , DiscordAreaType.CITIES, 10553), CITY_RIMMINGTON("Rimmington" , DiscordAreaType.CITIES, 11826, 11570), CITY_SEERS_VILLAGE("Seers' Village" , DiscordAreaType.CITIES, 10806), @@ -219,7 +220,7 @@ enum DiscordGameEventType DUNGEON_THE_WARRENS("The Warrens", DiscordAreaType.DUNGEONS, 7070, 7326), DUNGEON_TOLNA("Dungeon of Tolna", DiscordAreaType.DUNGEONS, 13209), DUNGEON_TOWER_OF_LIFE("Tower of Life Basement", DiscordAreaType.DUNGEONS, 12100), - DUNGEON_TRAHAEARN_MINE("Trahaearn Mine", DiscordAreaType.DUNGEONS, 13249), + DUNGEON_TRAHAEARN_MINE("Trahaearn Mine", DiscordAreaType.DUNGEONS, 13250), DUNGEON_TUNNEL_OF_CHAOS("Tunnel of Chaos", DiscordAreaType.DUNGEONS, 12625), DUNGEON_UNDERGROUND_PASS("Underground Pass", DiscordAreaType.DUNGEONS, 9369, 9370), DUNGEON_VARROCKSEWERS("Varrock Sewers", DiscordAreaType.DUNGEONS, 12954, 13210), @@ -242,7 +243,7 @@ enum DiscordGameEventType MG_CLAN_WARS("Clan Wars", DiscordAreaType.MINIGAMES, 13135, 13134, 13133, 13131, 13130, 13387, 13386), MG_DUEL_ARENA("Duel Arena", DiscordAreaType.MINIGAMES, 13362), MG_FISHING_TRAWLER("Fishing Trawler", DiscordAreaType.MINIGAMES, 7499), - MG_GAUNTLET("Gauntlet", DiscordAreaType.MINIGAMES, 12995), + MG_GAUNTLET("The Gauntlet", DiscordAreaType.MINIGAMES, 12127, 7512, 7768), MG_INFERNO("The Inferno", DiscordAreaType.MINIGAMES, 9043), MG_LAST_MAN_STANDING("Last Man Standing", DiscordAreaType.MINIGAMES, 13660, 13659, 13658, 13916, 13915, 13914), MG_HALLOWED_SEPULCHRE("Hallowed Sepulchre", DiscordAreaType.MINIGAMES, 8797, 9051, 9052, 9053, 9054, 9309, 9563, 9565, 9821, 10074, 10075, 10077), From a3bd5e50fa94cedf824b853c437636e9784b80fe Mon Sep 17 00:00:00 2001 From: Joe Zeffiro Date: Wed, 1 Jul 2020 06:14:56 -0700 Subject: [PATCH 32/68] KeyManager: Block remaps on authenticator game state Similar to 01bdbe5aabf4a14aa52b32acd2abc3f1270a2d34, we do not want to block input when the user is inputting their authenticator code at the login screen. --- .../src/main/java/net/runelite/client/input/KeyManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/input/KeyManager.java b/runelite-client/src/main/java/net/runelite/client/input/KeyManager.java index 066f8089c8..762e8efb86 100644 --- a/runelite-client/src/main/java/net/runelite/client/input/KeyManager.java +++ b/runelite-client/src/main/java/net/runelite/client/input/KeyManager.java @@ -145,6 +145,6 @@ public class KeyManager return true; } - return client.getGameState() != GameState.LOGIN_SCREEN; + return client.getGameState() != GameState.LOGIN_SCREEN && client.getGameState() != GameState.LOGIN_SCREEN_AUTHENTICATOR; } } From 349efebd58f0725988a9d290e1d0399189c286d8 Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Mon, 6 Jul 2020 21:56:09 -0700 Subject: [PATCH 33/68] keyremapping: Remove vestigial LOGIN_SCREEN guard clause Key remaps have been blocked at the KeyManager level as of commit 01bdbe5aabf4a14aa52b32acd2abc3f1270a2d34, so a LOGIN_SCREEN game state check is no longer needed within individual KeyListeners. --- .../client/plugins/keyremapping/KeyRemappingListener.java | 3 +-- .../client/plugins/keyremapping/KeyRemappingListenerTest.java | 3 --- 2 files changed, 1 insertion(+), 5 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 f07ccbf553..25c0da9576 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 @@ -33,7 +33,6 @@ import java.util.Map; import java.util.Set; import javax.inject.Inject; import net.runelite.api.Client; -import net.runelite.api.GameState; import net.runelite.api.VarClientStr; import net.runelite.client.callback.ClientThread; import net.runelite.client.input.KeyListener; @@ -68,7 +67,7 @@ class KeyRemappingListener implements KeyListener @Override public void keyPressed(KeyEvent e) { - if (client.getGameState() == GameState.LOGIN_SCREEN || !plugin.chatboxFocused()) + if (!plugin.chatboxFocused()) { return; } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/keyremapping/KeyRemappingListenerTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/keyremapping/KeyRemappingListenerTest.java index cbaefc875f..4d3b3b3005 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/keyremapping/KeyRemappingListenerTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/keyremapping/KeyRemappingListenerTest.java @@ -30,7 +30,6 @@ import com.google.inject.testing.fieldbinder.BoundFieldModule; import java.awt.event.KeyEvent; import javax.inject.Inject; import net.runelite.api.Client; -import net.runelite.api.GameState; import net.runelite.client.config.ModifierlessKeybind; import org.junit.Before; import org.junit.Test; @@ -64,8 +63,6 @@ public class KeyRemappingListenerTest public void setUp() { Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); - - when(client.getGameState()).thenReturn(GameState.LOGGED_IN); } @Test From 395fd1f5193e35b70fba0c08c0ebbac69e9655b9 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 8 Jul 2020 17:44:51 -0400 Subject: [PATCH 34/68] config: minor plugin panel cleanup --- .../client/plugins/config/PluginListItem.java | 2 -- .../client/plugins/config/PluginListPanel.java | 18 +++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java index 2c5cfe5bbd..0569944009 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListItem.java @@ -100,8 +100,6 @@ class PluginListItem extends JPanel keywords.add(mf.getInternalName()); } - final List popupMenuItems = new ArrayList<>(); - setLayout(new BorderLayout(3, 0)); setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH, 20)); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java index 72d5d4cf36..c27cc2c800 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/PluginListPanel.java @@ -87,7 +87,6 @@ class PluginListPanel extends PluginPanel private final ConfigManager configManager; private final PluginManager pluginManager; - private final ScheduledExecutorService executorService; private final Provider configPanelProvider; private final List fakePlugins = new ArrayList<>(); @@ -117,7 +116,6 @@ class PluginListPanel extends PluginPanel this.configManager = configManager; this.pluginManager = pluginManager; this.externalPluginManager = externalPluginManager; - this.executorService = executorService; this.configPanelProvider = configPanelProvider; muxer = new MultiplexingPluginPanel(this) @@ -214,14 +212,16 @@ class PluginListPanel extends PluginPanel config, configDescriptor); }) - ).map(desc -> - { - PluginListItem listItem = new PluginListItem(this, desc); - listItem.setPinned(pinnedPlugins.contains(desc.getName())); - return listItem; - }).collect(Collectors.toList()); + ) + .map(desc -> + { + PluginListItem listItem = new PluginListItem(this, desc); + listItem.setPinned(pinnedPlugins.contains(desc.getName())); + return listItem; + }) + .sorted(Comparator.comparing(p -> p.getPluginConfig().getName())) + .collect(Collectors.toList()); - pluginList.sort(Comparator.comparing(p -> p.getPluginConfig().getName())); mainPanel.removeAll(); refresh(); } From 9b65de74ee0ad4472f51e33e57c8a7d6fd78f9d9 Mon Sep 17 00:00:00 2001 From: Su-Shing Chen Date: Sat, 20 Jun 2020 15:41:25 +1200 Subject: [PATCH 35/68] ge plugin: add GE links to the offers panel This allows looking up GE prices for items already on offer, without the need to manually search for the item on the Search tab. Accessed via a new popup menu. --- .../grandexchange/GrandExchangeItemPanel.java | 17 +++-------------- .../grandexchange/GrandExchangeOfferSlot.java | 19 +++++++++++++++---- .../grandexchange/GrandExchangePlugin.java | 10 ++++++++++ 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeItemPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeItemPanel.java index 8b43715150..b833c4ab41 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeItemPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeItemPanel.java @@ -39,9 +39,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; -import net.runelite.client.util.AsyncBufferedImage; import net.runelite.client.ui.ColorScheme; -import net.runelite.client.util.LinkBrowser; +import net.runelite.client.util.AsyncBufferedImage; import net.runelite.client.util.QuantityFormatter; /** @@ -90,7 +89,7 @@ class GrandExchangeItemPanel extends JPanel @Override public void mouseReleased(MouseEvent e) { - geLink(name, itemID); + GrandExchangePlugin.openGeLink(name, itemID); } }; @@ -164,14 +163,4 @@ class GrandExchangeItemPanel extends JPanel c.setBackground(color); } } - - private static void geLink(String name, int itemID) - { - final String url = "http://services.runescape.com/m=itemdb_oldschool/" - + name.replaceAll(" ", "_") - + "/viewitem?obj=" - + itemID; - - LinkBrowser.browse(url); - } -} \ No newline at end of file +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java index f2a35d47d8..b4495ad90a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java @@ -39,7 +39,10 @@ import java.awt.image.BufferedImage; import javax.annotation.Nullable; import javax.swing.ImageIcon; import javax.swing.JLabel; +import javax.swing.JMenuItem; import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; import net.runelite.api.GrandExchangeOffer; import net.runelite.api.GrandExchangeOfferState; @@ -98,21 +101,21 @@ public class GrandExchangeOfferSlot extends JPanel @Override public void mousePressed(MouseEvent mouseEvent) { - super.mousePressed(mouseEvent); - switchPanel(); + if (SwingUtilities.isLeftMouseButton(mouseEvent)) + { + switchPanel(); + } } @Override public void mouseEntered(MouseEvent mouseEvent) { - super.mouseEntered(mouseEvent); container.setBackground(ColorScheme.DARKER_GRAY_HOVER_COLOR); } @Override public void mouseExited(MouseEvent mouseEvent) { - super.mouseExited(mouseEvent); container.setBackground(ColorScheme.DARKER_GRAY_COLOR); } }; @@ -227,6 +230,13 @@ public class GrandExchangeOfferSlot extends JPanel progressBar.setMaximumValue(newOffer.getTotalQuantity()); progressBar.setValue(newOffer.getQuantitySold()); + final JPopupMenu popupMenu = new JPopupMenu(); + popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5)); + + final JMenuItem openGeLink = new JMenuItem("Open Grand Exchange website"); + openGeLink.addActionListener(e -> GrandExchangePlugin.openGeLink(offerItem.getName(), offerItem.getId())); + popupMenu.add(openGeLink); + /* Couldn't set the tooltip for the container panel as the children override it, so I'm setting * the tooltips on the children instead. */ for (Component c : container.getComponents()) @@ -235,6 +245,7 @@ public class GrandExchangeOfferSlot extends JPanel { JPanel panel = (JPanel) c; panel.setToolTipText(htmlTooltip(((int) progressBar.getPercentage()) + "%")); + panel.setComponentPopupMenu(popupMenu); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java index 8c3c04aea2..be52533acc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java @@ -96,6 +96,7 @@ import net.runelite.client.ui.ClientToolbar; import net.runelite.client.ui.NavigationButton; import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ImageUtil; +import net.runelite.client.util.LinkBrowser; import net.runelite.client.util.OSType; import net.runelite.client.util.QuantityFormatter; import net.runelite.client.util.Text; @@ -932,4 +933,13 @@ public class GrandExchangePlugin extends Plugin } }); } + + static void openGeLink(String name, int itemId) + { + final String url = "https://services.runescape.com/m=itemdb_oldschool/" + + name.replaceAll(" ", "+") + + "/viewitem?obj=" + + itemId; + LinkBrowser.browse(url); + } } From 9fd36a600c3d2ee7075892ed68f459d4c56e8aa8 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 9 Jul 2020 13:04:48 -0400 Subject: [PATCH 36/68] xpdrop plugin: use script events instead of widget hidden This also uses the default color enum to assign default xpdrop colors instead of using our hardcoded enum. --- .../main/java/net/runelite/api/EnumID.java | 1 + .../main/java/net/runelite/api/ScriptID.java | 9 ++ .../plugins/experiencedrop/DefaultColors.java | 45 ------ .../plugins/experiencedrop/XpDropPlugin.java | 152 +++++++----------- 4 files changed, 69 insertions(+), 138 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/DefaultColors.java diff --git a/runelite-api/src/main/java/net/runelite/api/EnumID.java b/runelite-api/src/main/java/net/runelite/api/EnumID.java index 0b2d477a84..7d836dc613 100644 --- a/runelite-api/src/main/java/net/runelite/api/EnumID.java +++ b/runelite-api/src/main/java/net/runelite/api/EnumID.java @@ -33,4 +33,5 @@ public final class EnumID { public static final int MUSIC_TRACK_NAMES = 812; public static final int MUSIC_TRACK_IDS = 819; + public static final int XPDROP_COLORS = 1169; } diff --git a/runelite-api/src/main/java/net/runelite/api/ScriptID.java b/runelite-api/src/main/java/net/runelite/api/ScriptID.java index 039d2c0f48..af79f87a2f 100644 --- a/runelite-api/src/main/java/net/runelite/api/ScriptID.java +++ b/runelite-api/src/main/java/net/runelite/api/ScriptID.java @@ -275,4 +275,13 @@ public final class ScriptID */ @ScriptArguments(integer = 2) public static final int TOPLEVEL_REDRAW = 907; + + /** + * Called to set position of an xpdrop text and sprite(s) + *

      + *
    • XP drop parent component
    • + *
    + */ + @ScriptArguments(integer = 4, string = 1) + public static final int XPDROPS_SETDROPSIZE = 996; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/DefaultColors.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/DefaultColors.java deleted file mode 100644 index 227d82b3ee..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/DefaultColors.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2018, Cameron - * 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.experiencedrop; - -import java.awt.Color; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@AllArgsConstructor -enum DefaultColors -{ - WHITE(new Color(0xFF, 0xFF, 0xFF)), - LILAC(new Color(0xC8, 0xC8, 0xFF)), - CYAN(new Color(0x00, 0xFF, 0xFF)), - JADE(new Color(0xC8, 0xFF, 0xC8)), - LIME(new Color(0x64, 0xFF, 0x64)), - YELLOW(new Color(0xFF, 0xFF, 0x40)), - ORANGE(new Color(0xFF, 0x98, 0x1F)), - PINK(new Color(0xFF, 0xC8, 0xC8)); - - @Getter - private final Color color; -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java index 3a62513b8a..ffbd13a067 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java @@ -31,16 +31,19 @@ import java.util.Map; import java.util.stream.IntStream; import javax.inject.Inject; import net.runelite.api.Client; +import net.runelite.api.EnumComposition; +import net.runelite.api.EnumID; +import static net.runelite.api.ScriptID.XPDROPS_SETDROPSIZE; import static net.runelite.api.ScriptID.XPDROP_DISABLED; import net.runelite.api.Skill; import net.runelite.api.SpriteID; import net.runelite.api.Varbits; import net.runelite.api.events.GameTick; +import net.runelite.api.events.ScriptPreFired; import net.runelite.api.events.StatChanged; -import net.runelite.api.events.WidgetHiddenChanged; import net.runelite.api.widgets.Widget; -import net.runelite.api.widgets.WidgetID; -import net.runelite.api.widgets.WidgetInfo; +import static net.runelite.api.widgets.WidgetInfo.TO_CHILD; +import static net.runelite.api.widgets.WidgetInfo.TO_GROUP; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.Plugin; @@ -49,12 +52,10 @@ import net.runelite.client.plugins.PluginDescriptor; @PluginDescriptor( name = "XP Drop", description = "Enable customization of the way XP drops are displayed", - tags = {"experience", "levels", "tick", "prayer"} + tags = {"experience", "levels", "tick", "prayer", "xpdrop"} ) public class XpDropPlugin extends Plugin { - private static final int XPDROP_PADDING = 2; // space between xp drop icons - @Inject private Client client; @@ -76,116 +77,81 @@ public class XpDropPlugin extends Plugin } @Subscribe - public void onWidgetHiddenChanged(WidgetHiddenChanged event) + public void onScriptPreFired(ScriptPreFired scriptPreFired) { - Widget widget = event.getWidget(); - - int group = WidgetInfo.TO_GROUP(widget.getId()); - - if (group != WidgetID.EXPERIENCE_DROP_GROUP_ID) + if (scriptPreFired.getScriptId() == XPDROPS_SETDROPSIZE) { - return; + final int[] intStack = client.getIntStack(); + final int intStackSize = client.getIntStackSize(); + // This runs prior to the proc being invoked, so the arguments are still on the stack. + // Grab the first argument to the script. + final int widgetId = intStack[intStackSize - 4]; + processXpDrop(widgetId); } + } - if (widget.isHidden()) - { - return; - } + private void processXpDrop(int widgetId) + { + final Widget xpdrop = client.getWidget(TO_GROUP(widgetId), TO_CHILD(widgetId)); + final Widget[] children = xpdrop.getDynamicChildren(); + // child 0 is the xpdrop text, everything else are sprite ids for skills + final Widget text = children[0]; if (config.hideSkillIcons()) { - if (widget.getSpriteId() > 0) - { - widget.setHidden(true); - return; - } - else if (!widget.getText().isEmpty()) - { - // Align text accordingly to take up hidden skill icon space - int width = 0; - for (Widget w : widget.getParent().getDynamicChildren()) - { - if (w.getSpriteId() != -1) - { - if (width > 0) - { - // Add in space between sprites - width += XPDROP_PADDING; - } - width += w.getWidth(); // width of sprite - } - } - - final int xpDropPosition = client.getVar(Varbits.EXPERIENCE_TRACKER_POSITION); - switch (xpDropPosition) - { - case 2: // left - int cur = widget.getRelativeX(); - cur -= width; - widget.setRelativeX(cur); - break; - case 0: // right - break; - case 1: // center - cur = widget.getRelativeX(); - cur -= width / 2; - widget.setRelativeX(cur); - break; - } - } + // keep only text + xpdrop.setChildren(Arrays.copyOf(children, 1)); } PrayerType prayer = currentTickPrayer; if (prayer == null) { - resetTextColor(widget); + resetTextColor(text); return; } - String text = widget.getText(); final IntStream spriteIDs = - Arrays.stream(widget.getParent().getDynamicChildren()).mapToInt(Widget::getSpriteId); + Arrays.stream(children) + .skip(1) // skip text + .mapToInt(Widget::getSpriteId); - if (text != null) + int color = text.getTextColor(); + + switch (prayer) { - int color = widget.getTextColor(); - - switch (prayer) - { - case MELEE: - if (spriteIDs.anyMatch(id -> - id == SpriteID.SKILL_ATTACK || id == SpriteID.SKILL_STRENGTH || id == SpriteID.SKILL_DEFENCE - || correctPrayer)) - { - color = config.getMeleePrayerColor().getRGB(); - correctPrayer = true; - } - break; - case RANGE: - if (spriteIDs.anyMatch(id -> id == SpriteID.SKILL_RANGED || correctPrayer)) - { - color = config.getRangePrayerColor().getRGB(); - correctPrayer = true; - } - break; - case MAGIC: - if (spriteIDs.anyMatch(id -> id == SpriteID.SKILL_MAGIC || correctPrayer)) - { - color = config.getMagePrayerColor().getRGB(); - correctPrayer = true; - } - break; - } - - widget.setTextColor(color); + case MELEE: + if (correctPrayer || spriteIDs.anyMatch(id -> + id == SpriteID.SKILL_ATTACK || id == SpriteID.SKILL_STRENGTH || id == SpriteID.SKILL_DEFENCE)) + { + color = config.getMeleePrayerColor().getRGB(); + correctPrayer = true; + } + break; + case RANGE: + if (correctPrayer || spriteIDs.anyMatch(id -> id == SpriteID.SKILL_RANGED)) + { + color = config.getRangePrayerColor().getRGB(); + correctPrayer = true; + } + break; + case MAGIC: + if (correctPrayer || spriteIDs.anyMatch(id -> id == SpriteID.SKILL_MAGIC)) + { + color = config.getMagePrayerColor().getRGB(); + correctPrayer = true; + } + break; } + + text.setTextColor(color); } private void resetTextColor(Widget widget) { - int defaultColorIdx = client.getVar(Varbits.EXPERIENCE_DROP_COLOR); - int defaultColor = DefaultColors.values()[defaultColorIdx].getColor().getRGB(); - widget.setTextColor(defaultColor); + EnumComposition colorEnum = client.getEnum(EnumID.XPDROP_COLORS); + int defaultColorId = client.getVar(Varbits.EXPERIENCE_DROP_COLOR); + int color = colorEnum.getIntValue(defaultColorId); + widget.setTextColor(color); } private PrayerType getActivePrayerType() From 623de6326908ebcbab2e4a2f05bb7a1706a3fbc5 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 10 Jul 2020 00:07:46 -0400 Subject: [PATCH 37/68] xpdrops: reset xpdrop color on wrong prayer --- .../client/plugins/experiencedrop/XpDropPlugin.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java index ffbd13a067..987f5fffb2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java @@ -115,7 +115,7 @@ public class XpDropPlugin extends Plugin .skip(1) // skip text .mapToInt(Widget::getSpriteId); - int color = text.getTextColor(); + int color = -1; switch (prayer) { @@ -143,7 +143,14 @@ public class XpDropPlugin extends Plugin break; } - text.setTextColor(color); + if (color != -1) + { + text.setTextColor(color); + } + else + { + resetTextColor(text); + } } private void resetTextColor(Widget widget) From 122f74ae80200bc3ad81954366c97457d06a1bed Mon Sep 17 00:00:00 2001 From: Max Weber Date: Fri, 10 Jul 2020 03:51:47 -0600 Subject: [PATCH 38/68] npchighlight: Allow transparency on npc colors For parity with ground markers --- .../client/plugins/npchighlight/NpcIndicatorsConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java index 739ad7b59f..375d919aa5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsConfig.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.npchighlight; import java.awt.Color; +import net.runelite.client.config.Alpha; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; @@ -100,6 +101,7 @@ public interface NpcIndicatorsConfig extends Config name = "Highlight Color", description = "Color of the NPC highlight" ) + @Alpha default Color getHighlightColor() { return Color.CYAN; From a2118a57d8b65571750417d24a941e55b02ecaf5 Mon Sep 17 00:00:00 2001 From: Paulo Cabral Sanz Date: Thu, 9 Jul 2020 23:32:58 -0300 Subject: [PATCH 39/68] Add Nullable decorator to widget getter api --- runelite-api/src/main/java/net/runelite/api/Client.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index cb5fee5e71..881cb4696e 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -486,6 +486,7 @@ public interface Client extends GameEngine * @param widget the widget info * @return the widget */ + @Nullable Widget getWidget(WidgetInfo widget); /** @@ -498,6 +499,7 @@ public interface Client extends GameEngine * @param childId the child widget ID * @return the widget corresponding to the group and child pair */ + @Nullable Widget getWidget(int groupId, int childId); /** From cb4b7d42ea9a85b0efacbbfb7c0b37909edc9a2a Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Thu, 9 Jul 2020 14:56:46 -0700 Subject: [PATCH 40/68] KeyListener: Add isEnabledOnLoginScreen() method This commit moves login screen handling out of the KeyManager into the KeyListener interface so it does not need any knowledge of HotkeyListener's implementation. --- .../net/runelite/client/input/KeyListener.java | 4 ++++ .../net/runelite/client/input/KeyManager.java | 16 +++++----------- .../plugins/loginscreen/LoginScreenPlugin.java | 6 ++++++ .../java/net/runelite/client/ui/ClientUI.java | 4 ++-- .../net/runelite/client/util/HotkeyListener.java | 10 +++++++--- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/input/KeyListener.java b/runelite-client/src/main/java/net/runelite/client/input/KeyListener.java index d8b72f4a04..06526149d3 100644 --- a/runelite-client/src/main/java/net/runelite/client/input/KeyListener.java +++ b/runelite-client/src/main/java/net/runelite/client/input/KeyListener.java @@ -26,4 +26,8 @@ package net.runelite.client.input; public interface KeyListener extends java.awt.event.KeyListener { + default boolean isEnabledOnLoginScreen() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/input/KeyManager.java b/runelite-client/src/main/java/net/runelite/client/input/KeyManager.java index 762e8efb86..b464e2fc84 100644 --- a/runelite-client/src/main/java/net/runelite/client/input/KeyManager.java +++ b/runelite-client/src/main/java/net/runelite/client/input/KeyManager.java @@ -32,7 +32,6 @@ import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameState; -import net.runelite.client.util.HotkeyListener; @Singleton public class KeyManager @@ -133,18 +132,13 @@ public class KeyManager return true; } - if (!(keyListener instanceof HotkeyListener)) + final GameState gameState = client.getGameState(); + + if (gameState == GameState.LOGIN_SCREEN || gameState == GameState.LOGIN_SCREEN_AUTHENTICATOR) { - return true; + return keyListener.isEnabledOnLoginScreen(); } - final HotkeyListener hotkeyListener = (HotkeyListener) keyListener; - - if (hotkeyListener.isEnabledOnLogin()) - { - return true; - } - - return client.getGameState() != GameState.LOGIN_SCREEN && client.getGameState() != GameState.LOGIN_SCREEN_AUTHENTICATOR; + return true; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loginscreen/LoginScreenPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loginscreen/LoginScreenPlugin.java index b1b4303434..e338af7fe6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loginscreen/LoginScreenPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loginscreen/LoginScreenPlugin.java @@ -183,6 +183,12 @@ public class LoginScreenPlugin extends Plugin implements KeyListener } } + @Override + public boolean isEnabledOnLoginScreen() + { + return true; + } + @Override public void keyTyped(KeyEvent e) { diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java index a5d85c577b..13c13c7c68 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ClientUI.java @@ -382,7 +382,7 @@ public class ClientUI toggleSidebar(); } }; - sidebarListener.setEnabledOnLogin(true); + sidebarListener.setEnabledOnLoginScreen(true); keyManager.registerKeyListener(sidebarListener); final HotkeyListener pluginPanelListener = new HotkeyListener(config::panelToggleKey) @@ -393,7 +393,7 @@ public class ClientUI togglePluginPanel(); } }; - pluginPanelListener.setEnabledOnLogin(true); + pluginPanelListener.setEnabledOnLoginScreen(true); keyManager.registerKeyListener(pluginPanelListener); // Add mouse listener diff --git a/runelite-client/src/main/java/net/runelite/client/util/HotkeyListener.java b/runelite-client/src/main/java/net/runelite/client/util/HotkeyListener.java index 6dd2d88aba..2099564846 100644 --- a/runelite-client/src/main/java/net/runelite/client/util/HotkeyListener.java +++ b/runelite-client/src/main/java/net/runelite/client/util/HotkeyListener.java @@ -26,7 +26,6 @@ package net.runelite.client.util; import java.awt.event.KeyEvent; import java.util.function.Supplier; -import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Setter; import net.runelite.client.config.Keybind; @@ -42,8 +41,13 @@ public abstract class HotkeyListener implements KeyListener private boolean isConsumingTyped = false; @Setter - @Getter - private boolean isEnabledOnLogin = false; + private boolean enabledOnLoginScreen; + + @Override + public boolean isEnabledOnLoginScreen() + { + return enabledOnLoginScreen; + } @Override public void keyTyped(KeyEvent e) From e086a1155b426f0fa38ca784314e739c9ee3e6c6 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 Jul 2020 11:46:22 -0400 Subject: [PATCH 41/68] xpdrops: fix recoloring xpdrops when prayer is flicked on the previous tick Previously the widget hidden event would not run until the next client tick, due to it being on a timer, and the game tick event being deferred until the next frame. Now that we are hooking to the script being executed it fires prior to the game tick event being fired. --- .../runelite/client/plugins/experiencedrop/XpDropPlugin.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java index 987f5fffb2..4d2bac8f29 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java @@ -68,7 +68,6 @@ public class XpDropPlugin extends Plugin private boolean correctPrayer; private Skill lastSkill = null; private Map previousSkillExpTable = new EnumMap<>(Skill.class); - private PrayerType currentTickPrayer; @Provides XpDropConfig provideConfig(ConfigManager configManager) @@ -103,7 +102,7 @@ public class XpDropPlugin extends Plugin xpdrop.setChildren(Arrays.copyOf(children, 1)); } - PrayerType prayer = currentTickPrayer; + PrayerType prayer = getActivePrayerType(); if (prayer == null) { resetTextColor(text); @@ -176,7 +175,6 @@ public class XpDropPlugin extends Plugin @Subscribe public void onGameTick(GameTick tick) { - currentTickPrayer = getActivePrayerType(); correctPrayer = false; final int fakeTickDelay = config.fakeXpDropDelay(); From 35381c41834924c0b15041a2868cfe884a72f891 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 11 Jul 2020 12:12:13 -0400 Subject: [PATCH 42/68] xpdrops: fix hide skill icons We need to have the underlaying child array to make and assign back a copy to remove skill icons --- .../runelite/client/plugins/experiencedrop/XpDropPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java index 4d2bac8f29..6dc402012d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java @@ -92,7 +92,7 @@ public class XpDropPlugin extends Plugin private void processXpDrop(int widgetId) { final Widget xpdrop = client.getWidget(TO_GROUP(widgetId), TO_CHILD(widgetId)); - final Widget[] children = xpdrop.getDynamicChildren(); + final Widget[] children = xpdrop.getChildren(); // child 0 is the xpdrop text, everything else are sprite ids for skills final Widget text = children[0]; From 16c78630fb431a8b0f9d0cffd02bfc1b5df9c39c Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Sat, 11 Jul 2020 15:26:49 -0700 Subject: [PATCH 43/68] xpdrops: Fix white xp drop text recolors Selecting #FFFFFF as a prayer color yields an RGB value of -1. Since all values will be negative numbers, 0 should be used as an "unset" value instead. --- .../runelite/client/plugins/experiencedrop/XpDropPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java index 6dc402012d..b2198a6dfd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java @@ -114,7 +114,7 @@ public class XpDropPlugin extends Plugin .skip(1) // skip text .mapToInt(Widget::getSpriteId); - int color = -1; + int color = 0; switch (prayer) { @@ -142,7 +142,7 @@ public class XpDropPlugin extends Plugin break; } - if (color != -1) + if (color != 0) { text.setTextColor(color); } From 703ab49c3651c6f9661a9b33b41127c1c930f73b Mon Sep 17 00:00:00 2001 From: Henry Darnell Date: Sun, 12 Jul 2020 21:44:43 -0500 Subject: [PATCH 44/68] ThinProgressBar: Further darken background color (#11916) Most colors will not be of a sufficient (3:1) contrast ratio when being darkened only once. This commit darkens the background color to reach that threshold to be more clearly differentiated from the foreground color. --- .../java/net/runelite/client/ui/components/ThinProgressBar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/components/ThinProgressBar.java b/runelite-client/src/main/java/net/runelite/client/ui/components/ThinProgressBar.java index f80ff5b740..4b9b798c81 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/components/ThinProgressBar.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/components/ThinProgressBar.java @@ -61,7 +61,7 @@ public class ThinProgressBar extends JPanel public void setForeground(Color color) { super.setForeground(color); - setBackground(color.darker()); + setBackground(color.darker().darker()); } public void setMaximumValue(int maximumValue) From ef0124813617aa41a5b50b49bf0f9f6f1689fb80 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Sun, 12 Jul 2020 22:55:01 -0400 Subject: [PATCH 45/68] ItemChargeConfig: Improve grammar and wording (#11881) --- .../plugins/itemcharges/ItemChargeConfig.java | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java index 81e527ca66..5bc0e9e167 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java @@ -51,7 +51,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "veryLowWarningColor", name = "Very Low Warning Color", - description = "Configure the color of the overlay when charges are very low", + description = "The color of the overlay when charges are very low", position = 1 ) default Color veryLowWarningColor() @@ -62,7 +62,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "lowWarningColor", name = "Low Warning Color", - description = "Configure the color of the overlay when charges are low", + description = "The color of the overlay when charges are low", position = 2 ) default Color lowWarningolor() @@ -73,7 +73,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "veryLowWarning", name = "Very Low Warning", - description = "Configure the charge count for the very low warning color", + description = "The charge count for the very low warning color", position = 3 ) default int veryLowWarning() @@ -84,7 +84,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "lowWarning", name = "Low Warning", - description = "Configure the charge count for the low warning color", + description = "The charge count for the low warning color", position = 4 ) default int lowWarning() @@ -95,7 +95,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showTeleportCharges", name = "Show Teleport Charges", - description = "Configures if teleport item count is shown", + description = "Show teleport item charge counts", position = 5, section = chargesSection ) @@ -107,7 +107,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showDodgyCount", name = "Dodgy Necklace Count", - description = "Configures if Dodgy Necklace charge count is shown", + description = "Show Dodgy necklace charges", position = 6, section = chargesSection ) @@ -119,7 +119,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "dodgyNotification", name = "Dodgy Necklace Notification", - description = "Configures if the dodgy necklace breaking notification is shown", + description = "Send a notification when a Dodgy necklace breaks", position = 7, section = notificationSection ) @@ -149,7 +149,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showImpCharges", name = "Show Imp-in-a-box charges", - description = "Configures if imp-in-a-box item charges is shown", + description = "Show Imp-in-a-box item charges", position = 8, section = chargesSection ) @@ -161,7 +161,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showFungicideCharges", name = "Show Fungicide Charges", - description = "Configures if fungicide item charges is shown", + description = "Show Fungicide item charges", position = 9, section = chargesSection ) @@ -173,7 +173,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showWateringCanCharges", name = "Show Watering Can Charges", - description = "Configures if watering can item charge is shown", + description = "Show Watering can item charges", position = 10, section = chargesSection ) @@ -185,7 +185,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showWaterskinCharges", name = "Show Waterskin Charges", - description = "Configures if waterskin item charge is shown", + description = "Show Waterskin dose counts", position = 11, section = chargesSection ) @@ -196,8 +196,8 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showBellowCharges", - name = "Show Bellow Charges", - description = "Configures if ogre bellow item charge is shown", + name = "Show Bellows Charges", + description = "Show Ogre bellows item charges", position = 12, section = chargesSection ) @@ -209,7 +209,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showBasketCharges", name = "Show Basket Charges", - description = "Configures if fruit basket item charge is shown", + description = "Show Fruit basket item counts", position = 13, section = chargesSection ) @@ -221,7 +221,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showSackCharges", name = "Show Sack Charges", - description = "Configures if sack item charge is shown", + description = "Show Sack item counts", position = 14, section = chargesSection ) @@ -233,7 +233,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showAbyssalBraceletCharges", name = "Show Abyssal Bracelet Charges", - description = "Configures if abyssal bracelet item charge is shown", + description = "Show Abyssal bracelet item charges", position = 15, section = chargesSection ) @@ -245,7 +245,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showAmuletOfChemistryCharges", name = "Show Amulet of Chemistry Charges", - description = "Configures if amulet of chemistry item charge is shown", + description = "Show Amulet of chemistry item charges", position = 16, section = chargesSection ) @@ -275,7 +275,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showAmuletOfBountyCharges", name = "Show Amulet of Bounty Charges", - description = "Configures if amulet of bounty item charge is shown", + description = "Show Amulet of bounty item charges", position = 17, section = chargesSection ) @@ -305,7 +305,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "recoilNotification", name = "Ring of Recoil Notification", - description = "Configures if the ring of recoil breaking notification is shown", + description = "Send a notification when a Ring of recoil breaks", position = 18, section = notificationSection ) @@ -317,7 +317,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showBindingNecklaceCharges", name = "Show Binding Necklace Charges", - description = "Configures if binding necklace item charge is shown", + description = "Show Binding necklace item charges", position = 19, section = chargesSection ) @@ -347,7 +347,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "bindingNotification", name = "Binding Necklace Notification", - description = "Configures if the binding necklace breaking notification is shown", + description = "Send a notification when a Binding necklace breaks", position = 20, section = notificationSection ) @@ -359,7 +359,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showExplorerRingCharges", name = "Show Explorer's Ring Alch Charges", - description = "Configures if explorer's ring alchemy charges are shown", + description = "Show Explorer's ring alchemy charges", position = 21, section = chargesSection ) @@ -389,7 +389,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showRingOfForgingCount", name = "Show Ring of Forging Charges", - description = "Configures if the Ring of Forging charge count is shown", + description = "Show Ring of forging item charges", position = 22, section = chargesSection ) @@ -419,7 +419,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "ringOfForgingNotification", name = "Ring of Forging Notification", - description = "Configures if the Ring of Forging breaking notification is enabled", + description = "Send a notification when a Ring of forging breaks", position = 23, section = notificationSection ) @@ -431,7 +431,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showInfoboxes", name = "Show Infoboxes", - description = "Configures whether to show an infobox equipped charge items", + description = "Show an infobox with remaining charges for equipped items", position = 24 ) default boolean showInfoboxes() @@ -442,7 +442,7 @@ public interface ItemChargeConfig extends Config @ConfigItem( keyName = "showPotionDoseCount", name = "Show Potion Doses", - description = "Configures if potion doses are shown", + description = "Show remaining potion doses", position = 25, section = chargesSection ) From d6302702a9355032b7ea770ea5e5dc36a9e24617 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 13 Jul 2020 13:40:54 -0400 Subject: [PATCH 46/68] clues: correct spelling of Burthorpe --- .../client/plugins/cluescrolls/clues/CrypticClue.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java index 47f02029b4..f9ff8a6ec1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java @@ -231,7 +231,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc new CrypticClue("Talk to Cassie in Falador.", "Cassie", new WorldPoint(2975, 3383, 0), "Cassie is found just south-east of the northern Falador gate."), new CrypticClue("Faint sounds of 'Arr', fire giants found deep, the eastern tip of a lake, are the rewards you could reap.", new WorldPoint(3055, 10338, 0), "Dig south of the pillar in the Deep Wilderness Dungeon in the room with the fire giants."), new CrypticClue("If you're feeling brave, dig beneath the dragon's eye.", new WorldPoint(2410, 4714, 0), "Dig below the mossy rock under the Viyeldi caves (Legend's Quest). Items needed: Pickaxe, unpowered orb, lockpick, spade, any charge orb spell, and either 79 agility or an axe and machete."), - new CrypticClue("Search the tents in the Imperial Guard camp in Burthorpe for some boxes.", BOXES_3686, new WorldPoint(2885, 3540, 0), "Search in the tents in the northwest corner of the soldiers' camp in Burthrope."), + new CrypticClue("Search the tents in the Imperial Guard camp in Burthorpe for some boxes.", BOXES_3686, new WorldPoint(2885, 3540, 0), "Search in the tents in the northwest corner of the soldiers' camp in Burthorpe."), new CrypticClue("A dwarf, approaching death, but very much in the light.", "Thorgel", new WorldPoint(1863, 4639, 0), "Speak to Thorgel at the entrance to the Death altar."), new CrypticClue("You must be 100 to play with me.", "Squire (Veteran)", new WorldPoint(2638, 2656, 0), "Speak to the Veteran boat squire at Pest Control."), new CrypticClue("Three rule below and three sit at top. Come dig at my entrance.", new WorldPoint(2523, 3739, 0), "Dig in front of the entrance to the Waterbirth Island Dungeon."), @@ -319,7 +319,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc new CrypticClue("Search the crates in Falador General store.", CRATES_24088, new WorldPoint(2955, 3390, 0), "The Falador General Store can be found by the northern entrance to the city."), new CrypticClue("Talk to Wayne at Wayne's Chains in Falador.", "Wayne", new WorldPoint(2972, 3312, 0), "Wayne's shop is found directly south of the White Knights' Castle."), new CrypticClue("Search the boxes next to a chest that needs a crystal key.", BOXES_360, new WorldPoint(2915, 3452, 0), "The Crystal chest can be found in the house directly south of the Witch's house in Taverley."), - new CrypticClue("Talk to Turael in Burthorpe.", "Turael", new WorldPoint(2930, 3536, 0), "Turael is located in the small house east of the Toad and Chicken inn in Burthrope."), + new CrypticClue("Talk to Turael in Burthorpe.", "Turael", new WorldPoint(2930, 3536, 0), "Turael is located in the small house east of the Toad and Chicken inn in Burthorpe."), new CrypticClue("More resources than I can handle, but in a very dangerous area. Can't wait to strike gold!", new WorldPoint(3183, 3941, 0), "Dig between the three gold ores in the Wilderness Resource Area."), new CrypticClue("Observing someone in a swamp, under the telescope lies treasure.", new WorldPoint(2221, 3091, 0), "Dig next to the telescope on Broken Handz's island in the poison wastes. (Accessible only through fairy ring DLR)"), new CrypticClue("A general who sets a 'shining' example.", "General Hining", new WorldPoint(2186, 3148, 0), "Talk to General Hining in Tyras Camp."), From ed5868b5269616254e469d6e4b50cf0d535299ec Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Thu, 9 Jul 2020 13:15:49 -0400 Subject: [PATCH 47/68] chat commands: add ape atoll agility to longBossName --- .../client/plugins/chatcommands/ChatCommandsPlugin.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index 4a8bbe2b13..0c67b12c94 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -1696,6 +1696,11 @@ public class ChatCommandsPlugin extends Plugin case "hs 5": return "Hallowed Sepulchre Floor 5"; + // Ape Atoll Agility + case "aa": + case "ape atoll": + return "Ape Atoll Agility"; + default: return WordUtils.capitalize(boss); } From 6c6238d60f41c98aee2bb8b08ded040351e7ef27 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Sat, 11 Jul 2020 01:39:58 -0600 Subject: [PATCH 48/68] runelite-client: avoid Widget::getDynamicChildren where trivial --- .../runelite/client/plugins/bank/BankPlugin.java | 5 ++--- .../plugins/banktags/tabs/TabInterface.java | 2 +- .../client/plugins/examine/ExaminePlugin.java | 15 ++++++--------- .../plugins/experiencedrop/XpDropPlugin.java | 2 +- .../grandexchange/GrandExchangePlugin.java | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java index c7c1540137..5b0524888e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java @@ -363,8 +363,8 @@ public class BankPlugin extends Plugin return; } - final Widget[] children = titleContainer.getDynamicChildren(); - if (children == null || children.length < 2) + final Widget title = titleContainer.getChild(1); + if (title == null) { return; } @@ -377,7 +377,6 @@ public class BankPlugin extends Plugin final String titleText = createValueText(prices); - final Widget title = children[1]; title.setText(SEED_VAULT_TITLE + titleText); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java index a9c930258f..561f71a81f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java @@ -1113,7 +1113,7 @@ public class TabInterface incinerator.setOriginalWidth(INCINERATOR_WIDTH); incinerator.setOriginalY(INCINERATOR_HEIGHT); - Widget child = incinerator.getDynamicChildren()[0]; + Widget child = incinerator.getChild(0); child.setOriginalHeight(INCINERATOR_HEIGHT); child.setOriginalWidth(INCINERATOR_WIDTH); child.setWidthMode(WidgetSizeMode.ABSOLUTE); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java index 9292359d99..b2a6db3028 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java @@ -293,28 +293,25 @@ public class ExaminePlugin extends Plugin || WidgetID.PLAYER_TRADE_SCREEN_GROUP_ID == widgetGroup || WidgetID.PLAYER_TRADE_INVENTORY_GROUP_ID == widgetGroup) { - Widget[] children = widget.getDynamicChildren(); - if (actionParam < children.length) + Widget widgetItem = widget.getChild(actionParam); + if (widgetItem != null) { - Widget widgetItem = children[actionParam]; return new int[]{widgetItem.getItemQuantity(), widgetItem.getItemId()}; } } else if (WidgetInfo.SHOP_ITEMS_CONTAINER.getGroupId() == widgetGroup) { - Widget[] children = widget.getDynamicChildren(); - if (actionParam < children.length) + Widget widgetItem = widget.getChild(actionParam); + if (widgetItem != null) { - Widget widgetItem = children[actionParam]; return new int[]{1, widgetItem.getItemId()}; } } else if (WidgetID.SEED_VAULT_GROUP_ID == widgetGroup) { - Widget[] children = client.getWidget(SEED_VAULT_ITEM_CONTAINER).getDynamicChildren(); - if (actionParam < children.length) + Widget widgetItem = client.getWidget(SEED_VAULT_ITEM_CONTAINER).getChild(actionParam); + if (widgetItem != null) { - Widget widgetItem = children[actionParam]; return new int[]{widgetItem.getItemQuantity(), widgetItem.getItemId()}; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java index b2198a6dfd..b5ddf8bb22 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropPlugin.java @@ -99,7 +99,7 @@ public class XpDropPlugin extends Plugin if (config.hideSkillIcons()) { // keep only text - xpdrop.setChildren(Arrays.copyOf(children, 1)); + Arrays.fill(children, 1, children.length, null); } PrayerType prayer = getActivePrayerType(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java index be52533acc..ef944b4516 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java @@ -618,7 +618,7 @@ public class GrandExchangePlugin extends Plugin case WidgetID.GRAND_EXCHANGE_GROUP_ID: Widget grandExchangeOffer = client.getWidget(WidgetInfo.GRAND_EXCHANGE_OFFER_CONTAINER); grandExchangeText = client.getWidget(WidgetInfo.GRAND_EXCHANGE_OFFER_TEXT); - grandExchangeItem = grandExchangeOffer.getDynamicChildren()[OFFER_CONTAINER_ITEM]; + grandExchangeItem = grandExchangeOffer.getChild(OFFER_CONTAINER_ITEM); break; // Grand exchange was closed (if it was open before). case WidgetID.INVENTORY_GROUP_ID: From f0b7be68ba2a6d47f5102dffbc92bd5953d209c5 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Fri, 10 Jul 2020 17:20:43 -0600 Subject: [PATCH 49/68] npchighlight: factor out npc name tag checking --- .../npchighlight/NpcIndicatorsPlugin.java | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java index 0990ff39a7..5a6c0a746c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java @@ -385,17 +385,13 @@ public class NpcIndicatorsPlugin extends Plugin return; } - for (String highlight : highlights) + if (highlightMatchesNPCName(npcName)) { - if (WildcardMatcher.matches(highlight, npcName)) + highlightedNpcs.add(npc); + if (!client.isInInstancedRegion()) { - highlightedNpcs.add(npc); - if (!client.isInInstancedRegion()) - { - memorizeNpc(npc); - spawnedNpcsThisTick.add(npc); - } - break; + memorizeNpc(npc); + spawnedNpcsThisTick.add(npc); } } } @@ -529,7 +525,6 @@ public class NpcIndicatorsPlugin extends Plugin return; } - outer: for (NPC npc : client.getNpcs()) { final String npcName = npc.getName(); @@ -545,17 +540,14 @@ public class NpcIndicatorsPlugin extends Plugin continue; } - for (String highlight : highlights) + if (highlightMatchesNPCName(npcName)) { - if (WildcardMatcher.matches(highlight, npcName)) + if (!client.isInInstancedRegion()) { - if (!client.isInInstancedRegion()) - { - memorizeNpc(npc); - } - highlightedNpcs.add(npc); - continue outer; + memorizeNpc(npc); } + highlightedNpcs.add(npc); + continue; } // NPC is not highlighted @@ -563,6 +555,19 @@ public class NpcIndicatorsPlugin extends Plugin } } + private boolean highlightMatchesNPCName(String npcName) + { + for (String highlight : highlights) + { + if (WildcardMatcher.matches(highlight, npcName)) + { + return true; + } + } + + return false; + } + private void validateSpawnedNpcs() { if (skipNextSpawnCheck) From f0a8b678204c7edc1b9854fca1a14fe2ad20bd2a Mon Sep 17 00:00:00 2001 From: Max Weber Date: Fri, 10 Jul 2020 17:21:33 -0600 Subject: [PATCH 50/68] npchighlight: don't unhighlight name tagged npcs if unindex-tagging them --- .../client/plugins/npchighlight/NpcIndicatorsPlugin.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java index 5a6c0a746c..4b9ad27bcf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java @@ -344,8 +344,11 @@ public class NpcIndicatorsPlugin extends Plugin if (removed) { - highlightedNpcs.remove(npc); - memorizedNpcs.remove(npc.getIndex()); + if (!highlightMatchesNPCName(npc.getName())) + { + highlightedNpcs.remove(npc); + memorizedNpcs.remove(npc.getIndex()); + } } else { From 4308d433a27f5eaf8adde36ef8e55fd85cf51456 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Fri, 10 Jul 2020 19:29:59 -0600 Subject: [PATCH 51/68] npchighlight: Don't iterate npcs off the client thread --- .../npchighlight/NpcIndicatorsPlugin.java | 25 +++++++++++-------- .../npchighlight/NpcIndicatorsPluginTest.java | 9 ++----- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java index 4b9ad27bcf..24e5bbf9a5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java @@ -187,7 +187,6 @@ public class NpcIndicatorsPlugin extends Plugin { overlayManager.add(npcSceneOverlay); overlayManager.add(npcMinimapOverlay); - highlights = getHighlights(); clientThread.invoke(() -> { skipNextSpawnCheck = true; @@ -200,13 +199,16 @@ public class NpcIndicatorsPlugin extends Plugin { overlayManager.remove(npcSceneOverlay); overlayManager.remove(npcMinimapOverlay); - deadNpcsToDisplay.clear(); - memorizedNpcs.clear(); - spawnedNpcsThisTick.clear(); - despawnedNpcsThisTick.clear(); - teleportGraphicsObjectSpawnedThisTick.clear(); - npcTags.clear(); - highlightedNpcs.clear(); + clientThread.invoke(() -> + { + deadNpcsToDisplay.clear(); + memorizedNpcs.clear(); + spawnedNpcsThisTick.clear(); + despawnedNpcsThisTick.clear(); + teleportGraphicsObjectSpawnedThisTick.clear(); + npcTags.clear(); + highlightedNpcs.clear(); + }); } @Subscribe @@ -231,8 +233,7 @@ public class NpcIndicatorsPlugin extends Plugin return; } - highlights = getHighlights(); - rebuildAllNpcs(); + clientThread.invoke(this::rebuildAllNpcs); } @Subscribe @@ -516,8 +517,10 @@ public class NpcIndicatorsPlugin extends Plugin return Text.fromCSV(configNpcs); } - private void rebuildAllNpcs() + @VisibleForTesting + void rebuildAllNpcs() { + highlights = getHighlights(); highlightedNpcs.clear(); if (client.getGameState() != GameState.LOGGED_IN && diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java index 7884a7c81b..1260c5df0d 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java @@ -38,7 +38,6 @@ import net.runelite.api.MenuEntry; import net.runelite.api.NPC; import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.NpcSpawned; -import net.runelite.client.events.ConfigChanged; import net.runelite.client.ui.overlay.OverlayManager; import static org.junit.Assert.assertEquals; import org.junit.Before; @@ -97,9 +96,7 @@ public class NpcIndicatorsPluginTest when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin"); when(npcIndicatorsConfig.deadNpcMenuColor()).thenReturn(Color.RED); - ConfigChanged configChanged = new ConfigChanged(); - configChanged.setGroup("npcindicators"); - npcIndicatorsPlugin.onConfigChanged(configChanged); + npcIndicatorsPlugin.rebuildAllNpcs(); NPC npc = mock(NPC.class); when(npc.getName()).thenReturn("Goblin"); @@ -124,9 +121,7 @@ public class NpcIndicatorsPluginTest when(npcIndicatorsConfig.highlightMenuNames()).thenReturn(true); when(npcIndicatorsConfig.getHighlightColor()).thenReturn(Color.BLUE); - ConfigChanged configChanged = new ConfigChanged(); - configChanged.setGroup("npcindicators"); - npcIndicatorsPlugin.onConfigChanged(configChanged); + npcIndicatorsPlugin.rebuildAllNpcs(); NPC npc = mock(NPC.class); when(npc.getName()).thenReturn("Goblin"); From eb251a7e852e4a99f033dc3cd4c8cca6795b0396 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Fri, 26 Jun 2020 22:52:19 -0600 Subject: [PATCH 52/68] rl-client: Prevent chat inputs from taking keys from the worldmap search KeyRemapping has this check too, and [proc,keypress_permit] has similar, though not identical one. --- .../client/game/chatbox/ChatboxItemSearch.java | 5 +++++ .../client/game/chatbox/ChatboxPanelManager.java | 8 ++++++++ .../runelite/client/game/chatbox/ChatboxTextInput.java | 10 ++++++++++ .../client/game/chatbox/ChatboxTextMenuInput.java | 10 ++++++++++ .../plugins/wiki/WikiSearchChatboxTextInput.java | 5 +++++ 5 files changed, 38 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxItemSearch.java b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxItemSearch.java index 3796b8f2c3..2599e55dc7 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxItemSearch.java +++ b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxItemSearch.java @@ -184,6 +184,11 @@ public class ChatboxItemSearch extends ChatboxTextInput @Override public void keyPressed(KeyEvent ev) { + if (!chatboxPanelManager.shouldTakeInput()) + { + return; + } + switch (ev.getKeyCode()) { case KeyEvent.VK_ENTER: diff --git a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxPanelManager.java b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxPanelManager.java index e9d7c5641c..38bb623b95 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxPanelManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxPanelManager.java @@ -199,4 +199,12 @@ public class ChatboxPanelManager { return client.getWidget(WidgetInfo.CHATBOX_CONTAINER); } + + public boolean shouldTakeInput() + { + // the search box on the world map can be focused, and chat input goes there, even + // though the chatbox still has its key listener. + Widget worldMapSearch = client.getWidget(WidgetInfo.WORLD_MAP_SEARCH); + return worldMapSearch == null || client.getVar(VarClientInt.WORLD_MAP_SEARCH_FOCUSED) != 1; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextInput.java b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextInput.java index 4d2bfe8170..a11aad1e1c 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextInput.java +++ b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextInput.java @@ -609,6 +609,11 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse @Override public void keyTyped(KeyEvent e) { + if (!chatboxPanelManager.shouldTakeInput()) + { + return; + } + char c = e.getKeyChar(); if (charValidator.test(c)) { @@ -628,6 +633,11 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse @Override public void keyPressed(KeyEvent ev) { + if (!chatboxPanelManager.shouldTakeInput()) + { + return; + } + int code = ev.getKeyCode(); if (ev.isControlDown()) { diff --git a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextMenuInput.java b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextMenuInput.java index 94f3c10dcc..bc637a6528 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextMenuInput.java +++ b/runelite-client/src/main/java/net/runelite/client/game/chatbox/ChatboxTextMenuInput.java @@ -178,6 +178,11 @@ public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener @Override public void keyTyped(KeyEvent e) { + if (!chatboxPanelManager.shouldTakeInput()) + { + return; + } + char c = e.getKeyChar(); if (c == '\033') @@ -198,6 +203,11 @@ public class ChatboxTextMenuInput extends ChatboxInput implements KeyListener @Override public void keyPressed(KeyEvent e) { + if (!chatboxPanelManager.shouldTakeInput()) + { + return; + } + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { e.consume(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java index c4eee8374f..17607d6149 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java @@ -256,6 +256,11 @@ public class WikiSearchChatboxTextInput extends ChatboxTextInput @Override public void keyPressed(KeyEvent ev) { + if (!chatboxPanelManager.shouldTakeInput()) + { + return; + } + switch (ev.getKeyCode()) { case KeyEvent.VK_UP: From 1ee41dba5abf57c79ce582ca55c27bc323ee7f25 Mon Sep 17 00:00:00 2001 From: melkypie <5113962+melkypie@users.noreply.github.com> Date: Sun, 28 Jun 2020 17:24:06 +0300 Subject: [PATCH 53/68] loot tracker: move cox loot value message from raids to loot tracker Reverts commit bf0ff69e07eaebd12ada127ae55113456c19209d. Fixes the bug of double loot messages and adds the ability to use HA for loot value messages. --- .../loottracker/LootTrackerConfig.java | 10 ++++ .../loottracker/LootTrackerPlugin.java | 24 +++++++++ .../client/plugins/raids/RaidsConfig.java | 13 +---- .../client/plugins/raids/RaidsPlugin.java | 51 ------------------- .../loottracker/LootTrackerPluginTest.java | 41 +++++++++++++++ .../client/plugins/raids/RaidsPluginTest.java | 46 ----------------- 6 files changed, 76 insertions(+), 109 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java index a33534d975..368d06fa4c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerConfig.java @@ -138,4 +138,14 @@ public interface LootTrackerConfig extends Config { return false; } + + @ConfigItem( + keyName = "showRaidsLootValue", + name = "Show chat message for raids loot", + description = "Adds a chat message that displays the value of your loot at the end of the raid." + ) + default boolean showRaidsLootValue() + { + return true; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index 6707251dd7..6d31251008 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -547,6 +547,30 @@ public class LootTrackerPlugin extends Plugin .map(item -> new ItemStack(item.getId(), item.getQuantity(), client.getLocalPlayer().getLocalLocation())) .collect(Collectors.toList()); + if (config.showRaidsLootValue() && event.equals("Chambers of Xeric")) + { + long totalValue = items.stream() + .filter(item -> item.getId() > -1) + .mapToLong(item -> (long) (config.priceType() == LootTrackerPriceType.GRAND_EXCHANGE ? + itemManager.getItemPrice(item.getId()) * item.getQuantity() : + itemManager.getItemComposition(item.getId()).getHaPrice() * item.getQuantity())) + .sum(); + + String chatMessage = new ChatMessageBuilder() + .append(ChatColorType.NORMAL) + .append("Your loot is worth around ") + .append(ChatColorType.HIGHLIGHT) + .append(QuantityFormatter.formatNumber(totalValue)) + .append(ChatColorType.NORMAL) + .append(" coins.") + .build(); + + chatMessageManager.queue(QueuedMessage.builder() + .type(ChatMessageType.FRIENDSCHATNOTIFICATION) + .runeLiteFormattedMessage(chatMessage) + .build()); + } + if (items.isEmpty()) { log.debug("No items to find for Event: {} | Container: {}", event, container); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java index 25f8062fd8..5a1a81bf7e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsConfig.java @@ -178,17 +178,6 @@ public interface RaidsConfig extends Config @ConfigItem( position = 13, - keyName = "showLootValue", - name = "Show Loot Value", - description = "Shows the value of your loot at the end of a raid" - ) - default boolean showLootValue() - { - return true; - } - - @ConfigItem( - position = 14, keyName = "screenshotHotkey", name = "Scouter screenshot hotkey", description = "Hotkey used to screenshot the scouting overlay" @@ -199,7 +188,7 @@ public interface RaidsConfig extends Config } @ConfigItem( - position = 15, + position = 14, keyName = "uploadScreenshot", name = "Upload scouting screenshot", description = "Uploads the scouting screenshot to Imgur or the clipboard" diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index 57b74bd469..e251d701f6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -51,8 +51,6 @@ import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.InstanceTemplates; -import net.runelite.api.InventoryID; -import net.runelite.api.ItemContainer; import net.runelite.api.MenuAction; import net.runelite.api.MessageNode; import net.runelite.api.NullObjectID; @@ -67,8 +65,6 @@ import net.runelite.api.events.ChatMessage; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.VarbitChanged; -import net.runelite.api.events.WidgetLoaded; -import net.runelite.api.widgets.WidgetID; import net.runelite.client.callback.ClientThread; import net.runelite.client.chat.ChatColorType; import net.runelite.client.chat.ChatCommandManager; @@ -84,7 +80,6 @@ import net.runelite.client.events.ConfigChanged; import net.runelite.client.events.OverlayMenuClicked; import net.runelite.client.plugins.raids.events.RaidReset; import net.runelite.client.plugins.raids.events.RaidScouted; -import net.runelite.client.game.ItemManager; import net.runelite.client.game.SpriteManager; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; @@ -95,7 +90,6 @@ import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager; import net.runelite.client.util.HotkeyListener; import net.runelite.client.util.ImageCapture; -import net.runelite.client.util.QuantityFormatter; import net.runelite.client.util.Text; import static net.runelite.client.util.Text.sanitize; import net.runelite.client.ws.PartyMember; @@ -173,9 +167,6 @@ public class RaidsPlugin extends Plugin @Inject private ScheduledExecutorService scheduledExecutorService; - @Inject - private ItemManager itemManager; - @Inject private KeyManager keyManager; @@ -213,8 +204,6 @@ public class RaidsPlugin extends Plugin */ @Getter private int raidPartyID; - - private boolean chestOpened; private RaidsTimer timer; boolean checkInRaid; private boolean loggedIn; @@ -269,44 +258,6 @@ public class RaidsPlugin extends Plugin updateLists(); } - @Subscribe - public void onWidgetLoaded(WidgetLoaded event) - { - if (event.getGroupId() != WidgetID.CHAMBERS_OF_XERIC_REWARD_GROUP_ID || - !config.showLootValue() || - chestOpened) - { - return; - } - - chestOpened = true; - - ItemContainer rewardItemContainer = client.getItemContainer(InventoryID.CHAMBERS_OF_XERIC_CHEST); - if (rewardItemContainer == null) - { - return; - } - - long totalValue = Arrays.stream(rewardItemContainer.getItems()) - .filter(item -> item.getId() > -1) - .mapToLong(item -> (long) itemManager.getItemPrice(item.getId()) * item.getQuantity()) - .sum(); - - String chatMessage = new ChatMessageBuilder() - .append(ChatColorType.NORMAL) - .append("Your loot is worth around ") - .append(ChatColorType.HIGHLIGHT) - .append(QuantityFormatter.formatNumber(totalValue)) - .append(ChatColorType.NORMAL) - .append(" coins.") - .build(); - - chatMessageManager.queue(QueuedMessage.builder() - .type(ChatMessageType.FRIENDSCHATNOTIFICATION) - .runeLiteFormattedMessage(chatMessage) - .build()); - } - @Subscribe public void onVarbitChanged(VarbitChanged event) { @@ -482,7 +433,6 @@ public class RaidsPlugin extends Plugin updateInfoBoxState(); boolean firstSolve = (raid == null); raid = buildRaid(raid); - chestOpened = false; if (raid == null) { @@ -1014,7 +964,6 @@ public class RaidsPlugin extends Plugin private void reset() { raid = null; - chestOpened = false; updateInfoBoxState(); eventBus.post(new RaidReset()); } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java index c6f54cb2b6..43d554ea3e 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java @@ -37,15 +37,21 @@ import java.util.concurrent.ScheduledExecutorService; import javax.inject.Inject; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; +import net.runelite.api.InventoryID; +import net.runelite.api.Item; import net.runelite.api.ItemComposition; +import net.runelite.api.ItemContainer; import net.runelite.api.ItemID; import net.runelite.api.IterableHashTable; import net.runelite.api.MessageNode; import net.runelite.api.Player; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.WidgetLoaded; +import net.runelite.api.widgets.WidgetID; import net.runelite.client.account.SessionManager; import net.runelite.client.chat.ChatMessageManager; +import net.runelite.client.chat.QueuedMessage; import net.runelite.client.game.ItemManager; import net.runelite.client.game.ItemStack; import net.runelite.client.game.SpriteManager; @@ -57,9 +63,13 @@ import static org.junit.Assert.assertNull; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyCollection; import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; import org.mockito.Mock; +import org.mockito.Mockito; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -202,4 +212,35 @@ public class LootTrackerPluginTest assertNull(lootTrackerPlugin.eventType); } } + + @Test + public void testCoXRaidsLootValue() + { + when(lootTrackerConfig.showRaidsLootValue()).thenReturn(true); + when(lootTrackerConfig.priceType()).thenReturn(LootTrackerPriceType.GRAND_EXCHANGE); + + LootTrackerPlugin spyPlugin = Mockito.spy(lootTrackerPlugin); + // Make sure we don't execute addLoot, so we don't have to mock LootTrackerPanel and everything else also + doNothing().when(spyPlugin).addLoot(anyString(), anyInt(), any(LootRecordType.class), anyCollection()); + + ItemContainer itemContainer = mock(ItemContainer.class); + when(itemContainer.getItems()).thenReturn(new Item[]{ + new Item(ItemID.TWISTED_BOW, 1), + new Item(ItemID.PURE_ESSENCE, 42) + }); + when(client.getItemContainer(InventoryID.CHAMBERS_OF_XERIC_CHEST)).thenReturn(itemContainer); + + when(itemManager.getItemPrice(ItemID.TWISTED_BOW)).thenReturn(1_100_000_000); + when(itemManager.getItemPrice(ItemID.PURE_ESSENCE)).thenReturn(6); + + WidgetLoaded widgetLoaded = new WidgetLoaded(); + widgetLoaded.setGroupId(WidgetID.CHAMBERS_OF_XERIC_REWARD_GROUP_ID); + spyPlugin.onWidgetLoaded(widgetLoaded); + + ArgumentCaptor captor = ArgumentCaptor.forClass(QueuedMessage.class); + verify(chatMessageManager).queue(captor.capture()); + + QueuedMessage queuedMessage = captor.getValue(); + assertEquals("Your loot is worth around 1,100,000,252 coins.", queuedMessage.getRuneLiteFormattedMessage()); + } } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/raids/RaidsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/raids/RaidsPluginTest.java index 3bb07bf9a3..d687d98e5b 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/raids/RaidsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/raids/RaidsPluginTest.java @@ -30,32 +30,20 @@ import com.google.inject.testing.fieldbinder.Bind; import com.google.inject.testing.fieldbinder.BoundFieldModule; import java.util.concurrent.ScheduledExecutorService; import net.runelite.api.Client; -import net.runelite.api.InventoryID; -import net.runelite.api.Item; -import net.runelite.api.ItemContainer; -import net.runelite.api.ItemID; -import net.runelite.api.events.WidgetLoaded; -import net.runelite.api.widgets.WidgetID; import net.runelite.client.Notifier; -import net.runelite.client.chat.ChatMessageManager; -import net.runelite.client.chat.QueuedMessage; import net.runelite.client.config.ChatColorConfig; import net.runelite.client.config.RuneLiteConfig; -import net.runelite.client.game.ItemManager; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ImageCapture; import net.runelite.client.ws.PartyService; import net.runelite.http.api.chat.ChatClient; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; import org.mockito.Mock; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.mockito.junit.MockitoJUnitRunner; @@ -78,14 +66,6 @@ public class RaidsPluginTest @Bind RuneLiteConfig runeliteConfig; - @Mock - @Bind - ItemManager itemManager; - - @Mock - @Bind - ChatMessageManager chatMessageManager; - @Mock @Bind ImageCapture imageCapture; @@ -164,30 +144,4 @@ public class RaidsPluginTest assertFalse(raidsPlugin.getRotationMatches()); } - - @Test - public void testLootValue() - { - when(raidsConfig.showLootValue()).thenReturn(true); - - ItemContainer itemContainer = mock(ItemContainer.class); - when(itemContainer.getItems()).thenReturn(new Item[]{ - new Item(ItemID.TWISTED_BOW, 1), - new Item(ItemID.PURE_ESSENCE, 42) - }); - when(client.getItemContainer(InventoryID.CHAMBERS_OF_XERIC_CHEST)).thenReturn(itemContainer); - - when(itemManager.getItemPrice(ItemID.TWISTED_BOW)).thenReturn(1_100_000_000); - when(itemManager.getItemPrice(ItemID.PURE_ESSENCE)).thenReturn(6); - - WidgetLoaded widgetLoaded = new WidgetLoaded(); - widgetLoaded.setGroupId(WidgetID.CHAMBERS_OF_XERIC_REWARD_GROUP_ID); - raidsPlugin.onWidgetLoaded(widgetLoaded); - - ArgumentCaptor captor = ArgumentCaptor.forClass(QueuedMessage.class); - verify(chatMessageManager).queue(captor.capture()); - - QueuedMessage queuedMessage = captor.getValue(); - assertEquals("Your loot is worth around 1,100,000,252 coins.", queuedMessage.getRuneLiteFormattedMessage()); - } } From ffafa3a91a64158c8620d08dfcf7eb7b6d5b30d8 Mon Sep 17 00:00:00 2001 From: melkypie <5113962+melkypie@users.noreply.github.com> Date: Sun, 28 Jun 2020 17:17:09 +0300 Subject: [PATCH 54/68] loot tracker: add ability to have end of raid tob chest loot value in a chatmessage --- .../loottracker/LootTrackerPlugin.java | 2 +- .../loottracker/LootTrackerPluginTest.java | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index 6d31251008..de4f6c1ed7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -547,7 +547,7 @@ public class LootTrackerPlugin extends Plugin .map(item -> new ItemStack(item.getId(), item.getQuantity(), client.getLocalPlayer().getLocalLocation())) .collect(Collectors.toList()); - if (config.showRaidsLootValue() && event.equals("Chambers of Xeric")) + if (config.showRaidsLootValue() && (event.equals("Theatre of Blood") || event.equals("Chambers of Xeric"))) { long totalValue = items.stream() .filter(item -> item.getId() > -1) diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java index 43d554ea3e..4b74201060 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/loottracker/LootTrackerPluginTest.java @@ -45,6 +45,7 @@ import net.runelite.api.ItemID; import net.runelite.api.IterableHashTable; import net.runelite.api.MessageNode; import net.runelite.api.Player; +import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.WidgetLoaded; @@ -243,4 +244,45 @@ public class LootTrackerPluginTest QueuedMessage queuedMessage = captor.getValue(); assertEquals("Your loot is worth around 1,100,000,252 coins.", queuedMessage.getRuneLiteFormattedMessage()); } + + @Test + public void testToBRaidsLootValue() + { + when(lootTrackerConfig.priceType()).thenReturn(LootTrackerPriceType.HIGH_ALCHEMY); + when(lootTrackerConfig.showRaidsLootValue()).thenReturn(true); + + LootTrackerPlugin spyPlugin = Mockito.spy(lootTrackerPlugin); + // Make sure we don't execute addLoot, so we don't have to mock LootTrackerPanel and everything else also + doNothing().when(spyPlugin).addLoot(anyString(), anyInt(), any(LootRecordType.class), anyCollection()); + + ItemContainer itemContainer = mock(ItemContainer.class); + when(itemContainer.getItems()).thenReturn(new Item[]{ + new Item(ItemID.SCYTHE_OF_VITUR, 1), + new Item(ItemID.MAHOGANY_SEED, 10) + }); + when(client.getItemContainer(InventoryID.THEATRE_OF_BLOOD_CHEST)).thenReturn(itemContainer); + + ItemComposition compScythe = mock(ItemComposition.class); + when(itemManager.getItemComposition(ItemID.SCYTHE_OF_VITUR)).thenReturn(compScythe); + when(compScythe.getHaPrice()).thenReturn(60_000_000); + + ItemComposition compSeed = mock(ItemComposition.class); + when(itemManager.getItemComposition(ItemID.MAHOGANY_SEED)).thenReturn(compSeed); + when(compSeed.getHaPrice()).thenReturn(2_102); + + when(client.getBaseX()).thenReturn(3232); + when(client.getBaseY()).thenReturn(4320); + LocalPoint localPoint = new LocalPoint(0, 0); + when(client.getLocalPlayer().getLocalLocation()).thenReturn(localPoint); + + WidgetLoaded widgetLoaded = new WidgetLoaded(); + widgetLoaded.setGroupId(WidgetID.THEATRE_OF_BLOOD_GROUP_ID); + spyPlugin.onWidgetLoaded(widgetLoaded); + + ArgumentCaptor captor = ArgumentCaptor.forClass(QueuedMessage.class); + verify(chatMessageManager).queue(captor.capture()); + + QueuedMessage queuedMessage = captor.getValue(); + assertEquals("Your loot is worth around 60,021,020 coins.", queuedMessage.getRuneLiteFormattedMessage()); + } } From 25255c2053de59e467967501794187df9f0ad9fc Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Wed, 15 Jul 2020 00:13:47 -0400 Subject: [PATCH 55/68] chatfilter: Add config section for filter lists (#11900) --- .../plugins/chatfilter/ChatFilterConfig.java | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterConfig.java index c1c2378934..b5d7cf3f77 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterConfig.java @@ -28,26 +28,25 @@ package net.runelite.client.plugins.chatfilter; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.ConfigSection; @ConfigGroup("chatfilter") public interface ChatFilterConfig extends Config { - @ConfigItem( - keyName = "filterType", - name = "Filter type", - description = "Configures how the messages are filtered", - position = 1 + @ConfigSection( + name = "Filter Lists", + description = "Custom Word, Regex, and Username filter lists", + position = 0, + closedByDefault = true ) - default ChatFilterType filterType() - { - return ChatFilterType.CENSOR_WORDS; - } + String filterLists = "filterLists"; @ConfigItem( keyName = "filteredWords", name = "Filtered Words", description = "List of filtered words, separated by commas", - position = 2 + position = 1, + section = filterLists ) default String filteredWords() { @@ -58,7 +57,8 @@ public interface ChatFilterConfig extends Config keyName = "filteredRegex", name = "Filtered Regex", description = "List of regular expressions to filter, one per line", - position = 3 + position = 2, + section = filterLists ) default String filteredRegex() { @@ -69,13 +69,25 @@ public interface ChatFilterConfig extends Config keyName = "filteredNames", name = "Filtered Names", description = "List of filtered names, one per line. Accepts regular expressions", - position = 4 + position = 3, + section = filterLists ) default String filteredNames() { return ""; } + @ConfigItem( + keyName = "filterType", + name = "Filter type", + description = "Configures how the messages are filtered", + position = 4 + ) + default ChatFilterType filterType() + { + return ChatFilterType.CENSOR_WORDS; + } + @ConfigItem( keyName = "filterFriends", name = "Filter Friends", From 8b20626a3b71b24f949e2118e0d763df52f6ae48 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Mon, 15 Jun 2020 13:47:54 -0400 Subject: [PATCH 56/68] agility: Add config for Sepulchre obstacles and skill obstacles This commit moves Sepulchre obstacle IDs into a separate set so their highlighting can be toggled separately. It also adds a toggle to highlight Sepulchre skill obstacles. --- .../client/plugins/agility/AgilityConfig.java | 26 +++++++++++++++++-- .../plugins/agility/AgilityOverlay.java | 4 ++- .../client/plugins/agility/AgilityPlugin.java | 4 ++- .../client/plugins/agility/Obstacles.java | 21 ++++++++++----- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java index 5ecdda516b..2771e6ad5b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java @@ -225,7 +225,7 @@ public interface AgilityConfig extends Config keyName = "highlightSepulchreNpcs", name = "Highlight Sepulchre Projectiles", description = "Highlights arrows and swords in the Sepulchre", - position = 15 + position = 17 ) default boolean highlightSepulchreNpcs() { @@ -236,10 +236,32 @@ public interface AgilityConfig extends Config keyName = "sepulchreHighlightColor", name = "Sepulchre Highlight", description = "Overlay color for arrows and swords", - position = 16 + position = 18 ) default Color sepulchreHighlightColor() { return Color.GREEN; } + + @ConfigItem( + keyName = "highlightSepulchreObstacles", + name = "Highlight Sepulchre Obstacles", + description = "Highlights pillars and stairs in the Sepulchre", + position = 19 + ) + default boolean highlightSepulchreObstacles() + { + return true; + } + + @ConfigItem( + keyName = "highlightSepulchreSkilling", + name = "Highlight Sepulchre Skill Challenges", + description = "Highlights skilling challenges in the Sepulchre", + position = 20 + ) + default boolean highlightSepulchreSkilling() + { + return true; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java index a7118cc1ab..96e52d22f8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java @@ -78,7 +78,9 @@ class AgilityOverlay extends Overlay { if (Obstacles.SHORTCUT_OBSTACLE_IDS.containsKey(object.getId()) && !config.highlightShortcuts() || Obstacles.TRAP_OBSTACLE_IDS.contains(object.getId()) && !config.showTrapOverlay() || - Obstacles.COURSE_OBSTACLE_IDS.contains(object.getId()) && !config.showClickboxes()) + Obstacles.COURSE_OBSTACLE_IDS.contains(object.getId()) && !config.showClickboxes() || + Obstacles.SEPULCHRE_OBSTACLE_IDS.contains(object.getId()) && !config.highlightSepulchreObstacles() || + Obstacles.SEPULCHRE_SKILL_OBSTACLE_IDS.contains(object.getId()) && !config.highlightSepulchreSkilling()) { return; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java index a430c0e6d7..a13d9b3689 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java @@ -438,7 +438,9 @@ public class AgilityPlugin extends Plugin if (Obstacles.COURSE_OBSTACLE_IDS.contains(newObject.getId()) || Obstacles.PORTAL_OBSTACLE_IDS.contains(newObject.getId()) || (Obstacles.TRAP_OBSTACLE_IDS.contains(newObject.getId()) - && Obstacles.TRAP_OBSTACLE_REGIONS.contains(newObject.getWorldLocation().getRegionID()))) + && Obstacles.TRAP_OBSTACLE_REGIONS.contains(newObject.getWorldLocation().getRegionID())) || + Obstacles.SEPULCHRE_OBSTACLE_IDS.contains(newObject.getId()) || + Obstacles.SEPULCHRE_SKILL_OBSTACLE_IDS.contains(newObject.getId())) { obstacles.put(newObject, new Obstacle(tile, null)); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/Obstacles.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/Obstacles.java index b1b58b5f17..dd8809820b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/Obstacles.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/Obstacles.java @@ -95,12 +95,7 @@ class Obstacles ZIP_LINE_11645, ZIP_LINE_11646, // Prifddinas LADDER_36221, TIGHTROPE_36225, CHIMNEY_36227, ROOF_EDGE, DARK_HOLE_36229, LADDER_36231, LADDER_36232, - ROPE_BRIDGE_36233, TIGHTROPE_36234, ROPE_BRIDGE_36235, TIGHTROPE_36236, TIGHTROPE_36237, DARK_HOLE_36238, - // Hallowed Sepulchre - GATE_38460, PLATFORM_38455, PLATFORM_38456, PLATFORM_38457, PLATFORM_38458, PLATFORM_38459, - PLATFORM_38470, PLATFORM_38477, STAIRS_38462, STAIRS_38463, STAIRS_38464, STAIRS_38465, - STAIRS_38466, STAIRS_38467, STAIRS_38468, STAIRS_38469, STAIRS_38471, STAIRS_38472, - STAIRS_38473, STAIRS_38474, STAIRS_38475, STAIRS_38476 + ROPE_BRIDGE_36233, TIGHTROPE_36234, ROPE_BRIDGE_36235, TIGHTROPE_36236, TIGHTROPE_36237, DARK_HOLE_36238 ); static final Set PORTAL_OBSTACLE_IDS = ImmutableSet.of( @@ -129,4 +124,18 @@ class Obstacles } SHORTCUT_OBSTACLE_IDS = builder.build(); } + + static final Set SEPULCHRE_OBSTACLE_IDS = ImmutableSet.of( + // Stairs and Platforms (and one Gate) + GATE_38460, PLATFORM_38455, PLATFORM_38456, PLATFORM_38457, PLATFORM_38458, PLATFORM_38459, + PLATFORM_38470, PLATFORM_38477, STAIRS_38462, STAIRS_38463, STAIRS_38464, STAIRS_38465, + STAIRS_38466, STAIRS_38467, STAIRS_38468, STAIRS_38469, STAIRS_38471, STAIRS_38472, + STAIRS_38473, STAIRS_38474, STAIRS_38475, STAIRS_38476 + ); + + static final Set SEPULCHRE_SKILL_OBSTACLE_IDS = ImmutableSet.of( + // Grapple, Portal, and Bridge skill obstacles + // They are multilocs, thus we use the NullObjectID + NULL_39524, NULL_39525, NULL_39526, NULL_39527, NULL_39528, NULL_39533 + ); } From bc417d587d2ce2ba904809a3a02f84c3369d49c9 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Tue, 7 Jul 2020 13:46:39 -0400 Subject: [PATCH 57/68] agility: Add Hallowed Sepulchre config section --- .../client/plugins/agility/AgilityConfig.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java index 2771e6ad5b..de9962d678 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java @@ -28,11 +28,19 @@ import java.awt.Color; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.ConfigSection; import net.runelite.client.config.Units; @ConfigGroup("agility") public interface AgilityConfig extends Config { + @ConfigSection( + name = "Hallowed Sepulchre", + description = "Settings for Hallowed Sepulchre highlights", + position = 17 + ) + String sepulchreSection = "Hallowed Sepulchre"; + @ConfigItem( keyName = "showClickboxes", name = "Show Clickboxes", @@ -223,9 +231,10 @@ public interface AgilityConfig extends Config @ConfigItem( keyName = "highlightSepulchreNpcs", - name = "Highlight Sepulchre Projectiles", + name = "Highlight Projectiles", description = "Highlights arrows and swords in the Sepulchre", - position = 17 + position = 17, + section = sepulchreSection ) default boolean highlightSepulchreNpcs() { @@ -234,9 +243,10 @@ public interface AgilityConfig extends Config @ConfigItem( keyName = "sepulchreHighlightColor", - name = "Sepulchre Highlight", + name = "Projectile Color", description = "Overlay color for arrows and swords", - position = 18 + position = 18, + section = sepulchreSection ) default Color sepulchreHighlightColor() { @@ -245,9 +255,10 @@ public interface AgilityConfig extends Config @ConfigItem( keyName = "highlightSepulchreObstacles", - name = "Highlight Sepulchre Obstacles", + name = "Highlight Obstacles", description = "Highlights pillars and stairs in the Sepulchre", - position = 19 + position = 19, + section = sepulchreSection ) default boolean highlightSepulchreObstacles() { @@ -256,9 +267,10 @@ public interface AgilityConfig extends Config @ConfigItem( keyName = "highlightSepulchreSkilling", - name = "Highlight Sepulchre Skill Challenges", + name = "Highlight Skill Challenges", description = "Highlights skilling challenges in the Sepulchre", - position = 20 + position = 20, + section = sepulchreSection ) default boolean highlightSepulchreSkilling() { From 82a99a2b2be5df8d53b8b28b73416c6850df6c41 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 15 Jul 2020 14:51:31 -0400 Subject: [PATCH 58/68] inventoryid: add trade inventories --- .../src/main/java/net/runelite/api/InventoryID.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runelite-api/src/main/java/net/runelite/api/InventoryID.java b/runelite-api/src/main/java/net/runelite/api/InventoryID.java index dfe25ff2ed..e4795cbf31 100644 --- a/runelite-api/src/main/java/net/runelite/api/InventoryID.java +++ b/runelite-api/src/main/java/net/runelite/api/InventoryID.java @@ -33,6 +33,14 @@ public enum InventoryID * Reward from fishing trawler */ FISHING_TRAWLER_REWARD(0), + /** + * The trade inventory. + */ + TRADE(90), + /** + * The other trade inventory. + */ + TRADEOTHER(90 | 0x8000), /** * Standard player inventory. */ From 69534cc3cf54bb4853e116994a2daf1e39cfd19a Mon Sep 17 00:00:00 2001 From: Cyborger1 <45152844+Cyborger1@users.noreply.github.com> Date: Wed, 15 Jul 2020 16:20:27 -0400 Subject: [PATCH 59/68] notifier: make flash cancelling more responsive Currently the cancel check is only performed when the flash is on, and not off, making it perform one last flash when you provide input to the client when the flash is off. --- .../java/net/runelite/client/Notifier.java | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/Notifier.java b/runelite-client/src/main/java/net/runelite/client/Notifier.java index ce5db852c1..fc3083c997 100644 --- a/runelite-client/src/main/java/net/runelite/client/Notifier.java +++ b/runelite-client/src/main/java/net/runelite/client/Notifier.java @@ -217,6 +217,28 @@ public class Notifier FlashNotification flashNotification = runeLiteConfig.flashNotification(); + if (Instant.now().minusMillis(MINIMUM_FLASH_DURATION_MILLIS).isAfter(flashStart)) + { + switch (flashNotification) + { + case FLASH_TWO_SECONDS: + case SOLID_TWO_SECONDS: + flashStart = null; + return; + case SOLID_UNTIL_CANCELLED: + case FLASH_UNTIL_CANCELLED: + // Any interaction with the client since the notification started will cancel it after the minimum duration + if ((client.getMouseIdleTicks() < MINIMUM_FLASH_DURATION_TICKS + || client.getKeyboardIdleTicks() < MINIMUM_FLASH_DURATION_TICKS + || client.getMouseLastPressedMillis() > mouseLastPressedMillis) && clientUI.isFocused()) + { + flashStart = null; + return; + } + break; + } + } + if (client.getGameCycle() % 40 >= 20 // For solid colour, fall through every time. && (flashNotification == FlashNotification.FLASH_TWO_SECONDS @@ -229,29 +251,6 @@ public class Notifier graphics.setColor(FLASH_COLOR); graphics.fill(new Rectangle(client.getCanvas().getSize())); graphics.setColor(color); - - if (!Instant.now().minusMillis(MINIMUM_FLASH_DURATION_MILLIS).isAfter(flashStart)) - { - return; - } - - switch (flashNotification) - { - case FLASH_TWO_SECONDS: - case SOLID_TWO_SECONDS: - flashStart = null; - break; - case SOLID_UNTIL_CANCELLED: - case FLASH_UNTIL_CANCELLED: - // Any interaction with the client since the notification started will cancel it after the minimum duration - if ((client.getMouseIdleTicks() < MINIMUM_FLASH_DURATION_TICKS - || client.getKeyboardIdleTicks() < MINIMUM_FLASH_DURATION_TICKS - || client.getMouseLastPressedMillis() > mouseLastPressedMillis) && clientUI.isFocused()) - { - flashStart = null; - } - break; - } } private void sendNotification( From 41a8d4605eda25d18caff2fea7e40c2d02a66940 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Thu, 16 Jul 2020 09:04:59 -0400 Subject: [PATCH 60/68] worldmap: Update minigame locations for Ferox Enclave --- .../runelite/client/plugins/worldmap/MinigameLocation.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/MinigameLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/MinigameLocation.java index 6524dee2d8..a7145c8ee9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/MinigameLocation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/MinigameLocation.java @@ -34,6 +34,7 @@ enum MinigameLocation BARBARIAN_ASSAULT("Barbarian Assault", new WorldPoint(2531, 3569, 0)), BURGH_DE_ROTT_RAMBLE("Burgh de Rott Ramble", new WorldPoint(3434, 3487, 0)), CASTLE_WARS("Castle Wars", new WorldPoint(2439, 3092, 0)), + CASTLE_WARS_PORTAL("Castle Wars Portal", new WorldPoint(3140, 3626, 0)), DUEL_ARENA("Duel Arena", new WorldPoint(3313, 3238, 0)), MAGE_ARENA("Mage Arena", new WorldPoint(3095, 3957, 0)), NIGHTMARE_ZONE("Nightmare Zone", new WorldPoint(2606, 3115, 0)), @@ -43,7 +44,7 @@ enum MinigameLocation TEMPLE_TREKKING("Temple Trekking", new WorldPoint(3479, 3240, 0)), TZHAAR_FIGHT_CAVE("TzHaar Fight Cave", new WorldPoint(2437, 5168, 0)), TZHAAR_FIGHT_PIT("TzHaar Fight Pit", new WorldPoint(2398, 5177, 0)), - LAST_MAN_STANDING("Last Man Standing", new WorldPoint(3403, 3177, 0)), + LAST_MAN_STANDING("Last Man Standing", new WorldPoint(3138, 3635, 0)), INFERNO("Inferno", new WorldPoint(2495, 5118, 0)), BRIMHAVEN_AGILITY_ARENA("Brimhaven Agility Arena", new WorldPoint(2809, 3191, 0)), FISHING_TRAWLER("Fishing Trawler", new WorldPoint(2667, 3163, 0)), @@ -64,9 +65,7 @@ enum MinigameLocation RAT_PITS_ARDOUGNE("Rat Pits", new WorldPoint(2561, 3318, 0)), RAT_PITS_KELDAGRIM("Rat Pits", new WorldPoint(2913, 10188, 0)), TEARS_OF_GUTHIX("Tears of Guthix", new WorldPoint(3257, 9517, 0)), - CLAN_WARS_1("Clan Wars", new WorldPoint(3349, 3164, 0)), - CLAN_WARS_2("Clan Wars", new WorldPoint(3365, 3175, 0)), - CLAN_WARS_3("Clan Wars", new WorldPoint(3374, 3159, 0)), + CLAN_WARS("Clan Wars", new WorldPoint(3133, 3621, 0)), ANIMATION_ROOM("Animation Room", new WorldPoint(2853, 3537, 0)), DUMMY_ROOM("Dummy Room", new WorldPoint(2857, 3551, 0)), CATAPULT_ROOM("Catapult Room", new WorldPoint(2842, 3545, 0)), From 5873b01fc7368eb6ca621dafe5016f93e895fa81 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Thu, 16 Jul 2020 09:06:16 -0400 Subject: [PATCH 61/68] worldmap: Add Citharede Abbey and Eagles Outpost mining spots --- .../runelite/client/plugins/worldmap/MiningSiteLocation.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/MiningSiteLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/MiningSiteLocation.java index e1d0653209..21358d1e0f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/MiningSiteLocation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/MiningSiteLocation.java @@ -59,6 +59,7 @@ enum MiningSiteLocation BRIMHAVEN_NORTH(new WorldPoint(2732, 3225, 0), new Rock(10, Ore.GOLD)), BRIMHAVEN_SOUTH_(new WorldPoint(2743, 3150, 0), new Rock(6, Ore.GOLD)), CENTRAL_FREMENIK_ISLES(new WorldPoint(2374, 3850, 0), new Rock(7, Ore.COAL), new Rock(1, Ore.RUNITE)), + CITHAREDE_ABBEY(new WorldPoint(3400, 3170, 0), new Rock(3, Ore.IRON), new Rock (3, Ore.COAL)), COAL_TRUCKS(new WorldPoint(2580, 3484, 0), new Rock(18, Ore.COAL)), CRAFTING_GUILD(new WorldPoint(2939, 3283, 0), new Rock(6, Ore.CLAY), new Rock(6, Ore.SILVER), new Rock(7, Ore.GOLD)), CRANDOR_NORTH_EAST(new WorldPoint(2860, 3287, 0), new Rock(3, Ore.GOLD)), @@ -80,6 +81,7 @@ enum MiningSiteLocation DWARVEN_WEST_BOTTOM(new WorldPoint(3028, 9809, 0), new Rock(3, Ore.CLAY), new Rock(4, Ore.COPPER)), DWARVEN_WEST_TOP(new WorldPoint(3031, 9828, 0), new Rock(3, Ore.COPPER), new Rock(2, Ore.TIN), new Rock(2, Ore.IRON)), FREMENIK_ISLES_EAST(new WorldPoint(2405, 3867, 0), new Rock(3, Ore.COPPER), new Rock(3, Ore.TIN), new Rock(4, Ore.COAL)), + EAGLES_OUTPOST(new WorldPoint(3424, 3164, 0), new Rock(7, Ore.CLAY)), EDGEVILLE_DUNGEON(new WorldPoint(3138, 9874, 0), new Rock(2, Ore.COPPER), new Rock(2, Ore.TIN), new Rock(3, Ore.IRON), new Rock(3, Ore.SILVER), new Rock(6, Ore.COAL), new Rock(1, Ore.MITHRIL), new Rock(2, Ore.ADAMANTITE)), From 564510417eee0d853f2bca7079f109efe3ba4bf1 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Thu, 16 Jul 2020 09:07:14 -0400 Subject: [PATCH 62/68] =?UTF-8?q?worldmap:=20Add=20Ferox=20Enclave?= =?UTF-8?q?=E2=80=94Ring=20of=20dueling=20teleport=20location?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runelite/client/plugins/worldmap/TeleportLocationData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TeleportLocationData.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TeleportLocationData.java index 87eee1b1bb..d2753e8010 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TeleportLocationData.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TeleportLocationData.java @@ -78,7 +78,7 @@ enum TeleportLocationData CORPOREAL_BEAST(TeleportType.JEWELLERY, "Games Necklace" , "Corporeal Beast", new WorldPoint(2967, 4384, 0), "games_necklace_teleport_icon.png"), WINTERTODT_CAMP(TeleportType.JEWELLERY, "Games Necklace" , "Wintertodt Camp", new WorldPoint(1624, 3938, 0), "games_necklace_teleport_icon.png"), DUEL_ARENA(TeleportType.JEWELLERY, "Ring of Dueling" , "Duel Arena", new WorldPoint(3315, 3235, 0), "ring_of_dueling_teleport_icon.png"), - CLAN_WARS(TeleportType.JEWELLERY, "Ring of Dueling" , "Clan Wars", new WorldPoint(3387, 3158, 0), "ring_of_dueling_teleport_icon.png"), + FEROX_ENCLAVE(TeleportType.JEWELLERY, "Ring of Dueling" , "Ferox Enclave", new WorldPoint(3151, 3636, 0), "ring_of_dueling_teleport_icon.png"), CASTLE_WARS(TeleportType.JEWELLERY, "Ring of Dueling" , "Castle Wars", new WorldPoint(2441, 3091, 0), "ring_of_dueling_teleport_icon.png"), WARRIORS_GUILD(TeleportType.JEWELLERY, "Combat Bracelet" , "Warriors' Guild", new WorldPoint(2883, 3549, 0), "combat_bracelet_teleport_icon.png"), CHAMPIONS_GUILD(TeleportType.JEWELLERY, "Combat Bracelet" , "Champions' Guild", new WorldPoint(3189, 3368, 0), "combat_bracelet_teleport_icon.png"), From b3fa285d1a9c45c322e9aade2c819caeccaa9ee9 Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Thu, 16 Jul 2020 09:49:43 -0400 Subject: [PATCH 63/68] worldmap: Add Ferox Enclave canoe location --- .../client/plugins/worldmap/TransportationPointLocation.java | 1 + 1 file changed, 1 insertion(+) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPointLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPointLocation.java index 9c67107d27..d7a683076e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPointLocation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TransportationPointLocation.java @@ -139,6 +139,7 @@ enum TransportationPointLocation CANOE_CHAMPIONSGUILD("Canoe", new WorldPoint(3202, 3344, 0)), CANOE_EDGEVILLE("Canoe", new WorldPoint(3130, 3509, 0)), CANOE_LUMBRIDGE("Canoe", new WorldPoint(3241, 3238, 0)), + CANOE_FEROXENCLAVE("Canoe", new WorldPoint(3155, 3630, 0)), //Gnome Gliders GNOME_GLIDER_KHARID("Gnome Glider", new WorldPoint(3278, 3213, 0)), From 72ae9a20ae8de6c08982b7dfea4f43517a548bed Mon Sep 17 00:00:00 2001 From: Broooklyn <54762282+Broooklyn@users.noreply.github.com> Date: Thu, 16 Jul 2020 10:04:41 -0400 Subject: [PATCH 64/68] clues: Update text and description for clan cup clue --- .../runelite/client/plugins/cluescrolls/clues/CrypticClue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java index f9ff8a6ec1..da9d600fe9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/clues/CrypticClue.java @@ -179,7 +179,7 @@ public class CrypticClue extends ClueScroll implements TextClueScroll, NpcClueSc new CrypticClue("Leader of the Yak City.", "Mawnis Burowgar", new WorldPoint(2336, 3799, 0), "Talk to Mawnis Burowgar in Neitiznot."), new CrypticClue("Speak to Arhein in Catherby.", "Arhein", new WorldPoint(2803, 3430, 0), "Arhein is just south of the Catherby bank."), new CrypticClue("Speak to Doric, who lives north of Falador.", "Doric", new WorldPoint(2951, 3451, 0), "Doric is found north of Falador and east of the Taverley gate."), - new CrypticClue("Between where the best are commemorated for a year, and a celebratory cup, not just for beer.", new WorldPoint(3388, 3152, 0), "Dig at the Clan Cup Trophy at Clan Wars."), + new CrypticClue("Where the best are commemorated, and a celebratory cup, not just for beer.", new WorldPoint(3388, 3152, 0), "Dig at the Clan Cup Trophy south-west of Citharede Abbey."), new CrypticClue("'See you in your dreams' said the vegetable man.", "Dominic Onion", new WorldPoint(2608, 3116, 0), "Speak to Dominic Onion at the Nightmare Zone teleport spot."), new CrypticClue("Try not to step on any aquatic nasties while searching this crate.", CRATE_18204, new WorldPoint(2764, 3273, 0), "Search the crate in Bailey's house on the Fishing Platform."), new CrypticClue("The cheapest water for miles around, but they react badly to religious icons.", CRATE_354, new WorldPoint(3178, 2987, 0), "Search the crates in the General Store tent in the Desert Bandit Camp."), From bd190d87ba18a38d408d1029f383359a6bf7baa8 Mon Sep 17 00:00:00 2001 From: Runelite auto updater Date: Thu, 16 Jul 2020 16:24:36 +0000 Subject: [PATCH 65/68] Release 1.6.22 --- cache-client/pom.xml | 2 +- cache-updater/pom.xml | 2 +- cache/pom.xml | 2 +- http-api/pom.xml | 2 +- http-service/pom.xml | 2 +- pom.xml | 4 ++-- runelite-api/pom.xml | 2 +- runelite-client/pom.xml | 2 +- runelite-script-assembler-plugin/pom.xml | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cache-client/pom.xml b/cache-client/pom.xml index e4ad9c110e..35e0cc8d34 100644 --- a/cache-client/pom.xml +++ b/cache-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.6.22-SNAPSHOT + 1.6.22 cache-client diff --git a/cache-updater/pom.xml b/cache-updater/pom.xml index 4ef55c6c0c..8db61eb2c3 100644 --- a/cache-updater/pom.xml +++ b/cache-updater/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.6.22-SNAPSHOT + 1.6.22 Cache Updater diff --git a/cache/pom.xml b/cache/pom.xml index 1858764382..75610afdb7 100644 --- a/cache/pom.xml +++ b/cache/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.6.22-SNAPSHOT + 1.6.22 cache diff --git a/http-api/pom.xml b/http-api/pom.xml index dcd491b4f1..e565a73e30 100644 --- a/http-api/pom.xml +++ b/http-api/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.6.22-SNAPSHOT + 1.6.22 Web API diff --git a/http-service/pom.xml b/http-service/pom.xml index f9b9b2ef1c..c120a0ac54 100644 --- a/http-service/pom.xml +++ b/http-service/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.6.22-SNAPSHOT + 1.6.22 Web Service diff --git a/pom.xml b/pom.xml index abd5bdceab..609d71dd8b 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.6.22-SNAPSHOT + 1.6.22 pom RuneLite @@ -61,7 +61,7 @@ https://github.com/runelite/runelite scm:git:git://github.com/runelite/runelite scm:git:git@github.com:runelite/runelite - HEAD + runelite-parent-1.6.22 diff --git a/runelite-api/pom.xml b/runelite-api/pom.xml index 762eda5697..fdf46e9110 100644 --- a/runelite-api/pom.xml +++ b/runelite-api/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.6.22-SNAPSHOT + 1.6.22 runelite-api diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index d37b581c7f..affbd53bdd 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.6.22-SNAPSHOT + 1.6.22 client diff --git a/runelite-script-assembler-plugin/pom.xml b/runelite-script-assembler-plugin/pom.xml index 76342015d2..7ce9775e4a 100644 --- a/runelite-script-assembler-plugin/pom.xml +++ b/runelite-script-assembler-plugin/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.6.22-SNAPSHOT + 1.6.22 script-assembler-plugin From 7f354ca5e4779174d5adee0bc02922750e6f152d Mon Sep 17 00:00:00 2001 From: Runelite auto updater Date: Thu, 16 Jul 2020 16:24:47 +0000 Subject: [PATCH 66/68] Bump for 1.6.23-SNAPSHOT --- cache-client/pom.xml | 2 +- cache-updater/pom.xml | 2 +- cache/pom.xml | 2 +- http-api/pom.xml | 2 +- http-service/pom.xml | 2 +- pom.xml | 4 ++-- runelite-api/pom.xml | 2 +- runelite-client/pom.xml | 2 +- runelite-script-assembler-plugin/pom.xml | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cache-client/pom.xml b/cache-client/pom.xml index 35e0cc8d34..8a5c9b82a3 100644 --- a/cache-client/pom.xml +++ b/cache-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.6.22 + 1.6.23-SNAPSHOT cache-client diff --git a/cache-updater/pom.xml b/cache-updater/pom.xml index 8db61eb2c3..9b8003b5d5 100644 --- a/cache-updater/pom.xml +++ b/cache-updater/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.6.22 + 1.6.23-SNAPSHOT Cache Updater diff --git a/cache/pom.xml b/cache/pom.xml index 75610afdb7..b24221c227 100644 --- a/cache/pom.xml +++ b/cache/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.6.22 + 1.6.23-SNAPSHOT cache diff --git a/http-api/pom.xml b/http-api/pom.xml index e565a73e30..7ad2668968 100644 --- a/http-api/pom.xml +++ b/http-api/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.6.22 + 1.6.23-SNAPSHOT Web API diff --git a/http-service/pom.xml b/http-service/pom.xml index c120a0ac54..23f9aa3a80 100644 --- a/http-service/pom.xml +++ b/http-service/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.6.22 + 1.6.23-SNAPSHOT Web Service diff --git a/pom.xml b/pom.xml index 609d71dd8b..61afa59c2f 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.6.22 + 1.6.23-SNAPSHOT pom RuneLite @@ -61,7 +61,7 @@ https://github.com/runelite/runelite scm:git:git://github.com/runelite/runelite scm:git:git@github.com:runelite/runelite - runelite-parent-1.6.22 + HEAD diff --git a/runelite-api/pom.xml b/runelite-api/pom.xml index fdf46e9110..844c748a98 100644 --- a/runelite-api/pom.xml +++ b/runelite-api/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.6.22 + 1.6.23-SNAPSHOT runelite-api diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index affbd53bdd..0415d4f7bd 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.6.22 + 1.6.23-SNAPSHOT client diff --git a/runelite-script-assembler-plugin/pom.xml b/runelite-script-assembler-plugin/pom.xml index 7ce9775e4a..91b30d050d 100644 --- a/runelite-script-assembler-plugin/pom.xml +++ b/runelite-script-assembler-plugin/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.6.22 + 1.6.23-SNAPSHOT script-assembler-plugin From 5a3992b5c4ab9fc09d1faa914d537bf261036ab3 Mon Sep 17 00:00:00 2001 From: ThatGamerBlue Date: Thu, 16 Jul 2020 19:31:09 +0100 Subject: [PATCH 67/68] implement api changes --- .../java/net/runelite/api/ItemDefinition.java | 8 +++ .../net/runelite/api/PlayerAppearance.java | 7 +++ .../java/net/runelite/client/RuneLite.java | 53 +++++++++++++++++-- .../net/runelite/client/game/ItemManager.java | 5 +- .../mixins/RSItemDefinitionMixin.java | 8 +++ 5 files changed, 75 insertions(+), 6 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/ItemDefinition.java b/runelite-api/src/main/java/net/runelite/api/ItemDefinition.java index d215589a07..3bfd527493 100644 --- a/runelite-api/src/main/java/net/runelite/api/ItemDefinition.java +++ b/runelite-api/src/main/java/net/runelite/api/ItemDefinition.java @@ -75,6 +75,14 @@ public interface ItemDefinition */ int getPrice(); + /** + * Get the high alchemy price for this item. All items have a high alchemy price, + * but not all items can be alched. + * + * @return the high alch price + */ + int getHaPrice(); + /** * Checks whether the item is members only. * diff --git a/runelite-api/src/main/java/net/runelite/api/PlayerAppearance.java b/runelite-api/src/main/java/net/runelite/api/PlayerAppearance.java index 2348968eda..c700ee8c3f 100644 --- a/runelite-api/src/main/java/net/runelite/api/PlayerAppearance.java +++ b/runelite-api/src/main/java/net/runelite/api/PlayerAppearance.java @@ -31,6 +31,13 @@ import net.runelite.api.kit.KitType; */ public interface PlayerAppearance { + /** + * Checks if the player is female. + * + * @return true if the player is female + */ + boolean isFemale(); + /** * Gets an array of IDs related to equipment slots. *

    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 3cdaf570e4..c3ba022e05 100644 --- a/runelite-client/src/main/java/net/runelite/client/RuneLite.java +++ b/runelite-client/src/main/java/net/runelite/client/RuneLite.java @@ -44,6 +44,10 @@ import java.net.Authenticator; import java.net.PasswordAuthentication; import java.nio.charset.StandardCharsets; import java.nio.file.Paths; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.cert.X509Certificate; import java.util.Locale; import java.util.Map; import java.util.Optional; @@ -52,6 +56,9 @@ import java.util.UUID; import javax.annotation.Nullable; import javax.inject.Provider; import javax.inject.Singleton; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; import joptsimple.ArgumentAcceptingOptionSpec; import joptsimple.OptionException; import joptsimple.OptionParser; @@ -372,9 +379,16 @@ public class RuneLite log.error("Unable to load settings", ex); } - final OkHttpClient okHttpClient = RuneLiteAPI.CLIENT.newBuilder() - .cache(new Cache(new File(CACHE_DIR, "okhttp"), MAX_OKHTTP_CACHE_SIZE)) - .build(); + final OkHttpClient.Builder okHttpClientBuilder = RuneLiteAPI.CLIENT.newBuilder() + .cache(new Cache(new File(CACHE_DIR, "okhttp"), MAX_OKHTTP_CACHE_SIZE)); + + final boolean insecureSkipTlsVerification = options.has("insecure-skip-tls-verification"); + if (insecureSkipTlsVerification) + { + setupInsecureTrustManager(okHttpClientBuilder); + } + + final OkHttpClient okHttpClient = okHttpClientBuilder.build(); final ClientLoader clientLoader = new ClientLoader(okHttpClient, options.valueOf(updateMode)); Completable.fromAction(clientLoader::get) @@ -668,4 +682,37 @@ public class RuneLite return f; } } + + private static void setupInsecureTrustManager(OkHttpClient.Builder okHttpClientBuilder) + { + try + { + X509TrustManager trustManager = new X509TrustManager() + { + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) + { + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) + { + } + + @Override + public X509Certificate[] getAcceptedIssuers() + { + return new X509Certificate[0]; + } + }; + + SSLContext sc = SSLContext.getInstance("SSL"); + sc.init(null, new TrustManager[]{trustManager}, new SecureRandom()); + okHttpClientBuilder.sslSocketFactory(sc.getSocketFactory(), trustManager); + } + catch (NoSuchAlgorithmException | KeyManagementException ex) + { + log.warn("unable to setup insecure trust manager", ex); + } + } } diff --git a/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java b/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java index 24ece9a377..888531ed6f 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java @@ -48,7 +48,6 @@ import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.Constants; import static net.runelite.api.Constants.CLIENT_DEFAULT_ZOOM; -import static net.runelite.api.Constants.HIGH_ALCHEMY_MULTIPLIER; import net.runelite.api.GameState; import net.runelite.api.ItemDefinition; import net.runelite.api.ItemID; @@ -340,7 +339,7 @@ public class ItemManager return 1000; } - return (int) Math.max(1, composition.getPrice() * HIGH_ALCHEMY_MULTIPLIER); + return Math.max(1, composition.getHaPrice()); } public int getAlchValue(int itemID) @@ -354,7 +353,7 @@ public class ItemManager return 1000; } - return (int) Math.max(1, getItemDefinition(itemID).getPrice() * HIGH_ALCHEMY_MULTIPLIER); + return Math.max(1, getItemDefinition(itemID).getHaPrice()); } public int getRepairValue(int itemId) diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSItemDefinitionMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSItemDefinitionMixin.java index b0d67ee943..fc1d84f24d 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSItemDefinitionMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSItemDefinitionMixin.java @@ -89,4 +89,12 @@ public abstract class RSItemDefinitionMixin implements RSItemDefinition return client.getRSItemDefinition(modelOverride).getModel(quantity); } + + @Inject + @Override + public int getHaPrice() + { + int price = getPrice(); + return (int) ((float) price * 0.6f); + } } From 3ca8b4031004ae9ac6da312e6c5eb4a42e8c2473 Mon Sep 17 00:00:00 2001 From: ThatGamerBlue Date: Thu, 16 Jul 2020 21:23:05 +0100 Subject: [PATCH 68/68] bump version number --- buildSrc/src/main/kotlin/Dependencies.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 30add58c17..2af65a27e7 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -27,7 +27,7 @@ object ProjectVersions { const val launcherVersion = "2.2.0" const val rlVersion = "1.6.22" - const val openosrsVersion = "3.3.9" + const val openosrsVersion = "3.4.0" const val rsversion = 190 const val cacheversion = 165