From 7791a63e399dcd8e061fd66f3085a1ae1f200884 Mon Sep 17 00:00:00 2001 From: emiljensen2 <55587410+emiljensen2@users.noreply.github.com> Date: Sun, 9 May 2021 17:38:33 +0200 Subject: [PATCH 01/13] loot tracker: support tob lobby reward chest --- .../runelite/client/plugins/loottracker/LootTrackerPlugin.java | 3 ++- 1 file changed, 2 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 ee9f307838..6ca04ce159 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 @@ -128,6 +128,7 @@ public class LootTrackerPlugin extends Plugin // Activity/Event loot handling private static final Pattern CLUE_SCROLL_PATTERN = Pattern.compile("You have completed [0-9]+ ([a-z]+) Treasure Trails?\\."); private static final int THEATRE_OF_BLOOD_REGION = 12867; + private static final int THEATRE_OF_BLOOD_LOBBY = 14642; // Herbiboar loot handling @VisibleForTesting @@ -551,7 +552,7 @@ public class LootTrackerPlugin extends Plugin return; } int region = WorldPoint.fromLocalInstance(client, client.getLocalPlayer().getLocalLocation()).getRegionID(); - if (region != THEATRE_OF_BLOOD_REGION) + if (region != THEATRE_OF_BLOOD_REGION && region != THEATRE_OF_BLOOD_LOBBY) { return; } From a52d59d2db1559c32a3c6e38d621c980ad22c618 Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Sun, 14 Feb 2021 13:46:01 +0000 Subject: [PATCH 02/13] item charges: add bracelet of slaughter and expeditious bracelet --- .../plugins/itemcharges/ItemChargeConfig.java | 50 ++++++++ .../itemcharges/ItemChargeOverlay.java | 21 +++- .../plugins/itemcharges/ItemChargePlugin.java | 119 ++++++++++++++++++ .../plugins/itemcharges/ItemChargeType.java | 2 + .../plugins/itemcharges/ItemWithSlot.java | 2 + .../itemcharges/ItemChargePluginTest.java | 52 ++++++++ 6 files changed, 245 insertions(+), 1 deletion(-) 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 096501d67b..dfdb592b43 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 @@ -40,8 +40,10 @@ public interface ItemChargeConfig extends Config String KEY_AMULET_OF_BOUNTY = "amuletOfBounty"; String KEY_AMULET_OF_CHEMISTRY = "amuletOfChemistry"; String KEY_BINDING_NECKLACE = "bindingNecklace"; + String KEY_BRACELET_OF_SLAUGHTER = "braceletOfSlaughter"; String KEY_CHRONICLE = "chronicle"; String KEY_DODGY_NECKLACE = "dodgyNecklace"; + String KEY_EXPEDITIOUS_BRACELET = "expeditiousBracelet"; String KEY_EXPLORERS_RING = "explorerRing"; String KEY_RING_OF_FORGING = "ringOfForging"; @@ -353,4 +355,52 @@ public interface ItemChargeConfig extends Config { return false; } + + @ConfigItem( + keyName = "showBraceletOfSlaughterCharges", + name = "Bracelet of Slaughter Charges", + description = "Show Bracelet of Slaughter item charges", + position = 26, + section = chargesSection + ) + default boolean showBraceletOfSlaughterCharges() + { + return true; + } + + @ConfigItem( + keyName = "slaughterNotification", + name = "Bracelet of Slaughter Notification", + description = "Send a notification when a Bracelet of Slaughter breaks", + position = 27, + section = notificationSection + ) + default boolean slaughterNotification() + { + return true; + } + + @ConfigItem( + keyName = "showExpeditiousBraceletCharges", + name = "Expeditious Bracelet Charges", + description = "Show Expeditious Bracelet item charges", + position = 28, + section = chargesSection + ) + default boolean showExpeditiousBraceletCharges() + { + return true; + } + + @ConfigItem( + keyName = "expeditiousNotification", + name = "Expeditious Bracelet Notification", + description = "Send a notification when an Expeditious Bracelet breaks", + position = 29, + section = notificationSection + ) + default boolean expeditiousNotification() + { + return true; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java index 38f00f1892..b028fa444a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java @@ -125,6 +125,24 @@ class ItemChargeOverlay extends WidgetItemOverlay charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_CHRONICLE); } + else if (itemId == ItemID.BRACELET_OF_SLAUGHTER) + { + if (!config.showBraceletOfSlaughterCharges()) + { + return; + } + + charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER); + } + else if (itemId == ItemID.EXPEDITIOUS_BRACELET) + { + if (!config.showExpeditiousBraceletCharges()) + { + return; + } + + charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET); + } else { ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId); @@ -167,7 +185,8 @@ class ItemChargeOverlay extends WidgetItemOverlay || config.showImpCharges() || config.showWateringCanCharges() || config.showWaterskinCharges() || config.showBellowCharges() || config.showBasketCharges() || config.showSackCharges() || config.showAbyssalBraceletCharges() || config.showExplorerRingCharges() || config.showRingOfForgingCount() - || config.showAmuletOfChemistryCharges() || config.showAmuletOfBountyCharges() || config.showPotionDoseCount(); + || config.showAmuletOfChemistryCharges() || config.showAmuletOfBountyCharges() || config.showPotionDoseCount() + || config.showBraceletOfSlaughterCharges() || config.showExpeditiousBraceletCharges(); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java index 546d049931..2c964d6709 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java @@ -113,6 +113,20 @@ public class ItemChargePlugin extends Plugin private static final String CHRONICLE_ONE_CHARGE_TEXT = "You have one charge left in your book."; private static final String CHRONICLE_EMPTY_TEXT = "Your book has run out of charges."; private static final String CHRONICLE_NO_CHARGES_TEXT = "Your book does not have any charges. Purchase some Teleport Cards from Diango."; + private static final Pattern BRACELET_OF_SLAUGHTER_ACTIVATE_PATTERN = Pattern.compile( + "Your bracelet of slaughter prevents your slayer count from decreasing. (?:(?:It has (\\d{1,2}) charges? left)|(It then crumbles to dust))\\." + ); + private static final Pattern BRACELET_OF_SLAUGHTER_CHECK_PATTERN = Pattern.compile( + "Your bracelet of slaughter has (\\d{1,2}) charges? left\\." + ); + private static final String BRACELET_OF_SLAUGHTER_BREAK_TEXT = "Your Bracelet of Slaughter has crumbled to dust."; + private static final Pattern EXPEDITIOUS_BRACELET_ACTIVATE_PATTERN = Pattern.compile( + "Your expeditious bracelet helps you progress your slayer (?:task )?faster. (?:(?:It has (\\d{1,2}) charges? left)|(It then crumbles to dust))\\." + ); + private static final Pattern EXPEDITIOUS_BRACELET_CHECK_PATTERN = Pattern.compile( + "Your expeditious bracelet has (\\d{1,2}) charges? left\\." + ); + private static final String EXPEDITIOUS_BRACELET_BREAK_TEXT = "Your Expeditious Bracelet has crumbled to dust."; private static final int MAX_DODGY_CHARGES = 10; private static final int MAX_BINDING_CHARGES = 16; @@ -120,6 +134,7 @@ public class ItemChargePlugin extends Plugin private static final int MAX_RING_OF_FORGING_CHARGES = 140; private static final int MAX_AMULET_OF_CHEMISTRY_CHARGES = 5; private static final int MAX_AMULET_OF_BOUNTY_CHARGES = 10; + private static final int MAX_SLAYER_BRACELET_CHARGES = 30; private int lastExplorerRingCharge = -1; @@ -247,6 +262,10 @@ public class ItemChargePlugin extends Plugin Matcher amuletOfBountyUsedMatcher = AMULET_OF_BOUNTY_USED_PATTERN.matcher(message); Matcher chronicleAddMatcher = CHRONICLE_ADD_PATTERN.matcher(message); Matcher chronicleUseAndCheckMatcher = CHRONICLE_USE_AND_CHECK_PATTERN.matcher(message); + Matcher slaughterActivateMatcher = BRACELET_OF_SLAUGHTER_ACTIVATE_PATTERN.matcher(message); + Matcher slaughterCheckMatcher = BRACELET_OF_SLAUGHTER_CHECK_PATTERN.matcher(message); + Matcher expeditiousActivateMatcher = EXPEDITIOUS_BRACELET_ACTIVATE_PATTERN.matcher(message); + Matcher expeditiousCheckMatcher = EXPEDITIOUS_BRACELET_CHECK_PATTERN.matcher(message); if (config.recoilNotification() && message.contains(RING_OF_RECOIL_BREAK_MESSAGE)) { @@ -392,6 +411,46 @@ public class ItemChargePlugin extends Plugin { setItemCharges(ItemChargeConfig.KEY_CHRONICLE, 1000); } + else if (slaughterActivateMatcher.find()) + { + final String found = slaughterActivateMatcher.group(1); + if (found == null) + { + updateBraceletOfSlaughterCharges(MAX_SLAYER_BRACELET_CHARGES); + if (config.slaughterNotification()) + { + notifier.notify(BRACELET_OF_SLAUGHTER_BREAK_TEXT); + } + } + else + { + updateBraceletOfSlaughterCharges(Integer.parseInt(found)); + } + } + else if (slaughterCheckMatcher.find()) + { + updateBraceletOfSlaughterCharges(Integer.parseInt(slaughterCheckMatcher.group(1))); + } + else if (expeditiousActivateMatcher.find()) + { + final String found = expeditiousActivateMatcher.group(1); + if (found == null) + { + updateExpeditiousBraceletCharges(MAX_SLAYER_BRACELET_CHARGES); + if (config.expeditiousNotification()) + { + notifier.notify(EXPEDITIOUS_BRACELET_BREAK_TEXT); + } + } + else + { + updateExpeditiousBraceletCharges(Integer.parseInt(found)); + } + } + else if (expeditiousCheckMatcher.find()) + { + updateExpeditiousBraceletCharges(Integer.parseInt(expeditiousCheckMatcher.group(1))); + } } } @@ -444,6 +503,16 @@ public class ItemChargePlugin extends Plugin { updateJewelleryInfobox(ItemWithSlot.AMULET_OF_BOUNTY, items); } + + if (config.showBraceletOfSlaughterCharges()) + { + updateJewelleryInfobox(ItemWithSlot.BRACELET_OF_SLAUGHTER, items); + } + + if (config.showExpeditiousBraceletCharges()) + { + updateJewelleryInfobox(ItemWithSlot.EXPEDITIOUS_BRACELET, items); + } } @Subscribe @@ -496,6 +565,14 @@ public class ItemChargePlugin extends Plugin log.debug("Reset amulet of chemistry"); updateAmuletOfChemistryCharges(MAX_AMULET_OF_CHEMISTRY_CHARGES); break; + case ItemID.BRACELET_OF_SLAUGHTER: + log.debug("Reset bracelet of slaughter"); + updateBraceletOfSlaughterCharges(MAX_SLAYER_BRACELET_CHARGES); + break; + case ItemID.EXPEDITIOUS_BRACELET: + log.debug("Reset expeditious bracelet"); + updateExpeditiousBraceletCharges(MAX_SLAYER_BRACELET_CHARGES); + break; } } }); @@ -605,6 +682,40 @@ public class ItemChargePlugin extends Plugin } } + private void updateBraceletOfSlaughterCharges(final int value) + { + setItemCharges(ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, value); + + if (config.showInfoboxes() && config.showBraceletOfSlaughterCharges()) + { + final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); + + if (itemContainer == null) + { + return; + } + + updateJewelleryInfobox(ItemWithSlot.BRACELET_OF_SLAUGHTER, itemContainer.getItems()); + } + } + + private void updateExpeditiousBraceletCharges(final int value) + { + setItemCharges(ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, value); + + if (config.showInfoboxes() && config.showExpeditiousBraceletCharges()) + { + final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); + + if (itemContainer == null) + { + return; + } + + updateJewelleryInfobox(ItemWithSlot.EXPEDITIOUS_BRACELET, itemContainer.getItems()); + } + } + private void checkDestroyWidget() { final int currentTick = client.getTickCount(); @@ -679,6 +790,14 @@ public class ItemChargePlugin extends Plugin { charges = getItemCharges(ItemChargeConfig.KEY_AMULET_OF_BOUNTY); } + else if (id == ItemID.BRACELET_OF_SLAUGHTER && type == ItemWithSlot.BRACELET_OF_SLAUGHTER) + { + charges = getItemCharges(ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER); + } + else if (id == ItemID.EXPEDITIOUS_BRACELET && type == ItemWithSlot.EXPEDITIOUS_BRACELET) + { + charges = getItemCharges(ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET); + } } else if (itemWithCharge.getType() == type.getType()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java index a3f5fb7a78..7abf9ac0a1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java @@ -31,6 +31,8 @@ enum ItemChargeType AMULET_OF_CHEMISTRY, AMULET_OF_BOUNTY, BELLOWS, + BRACELET_OF_SLAUGHTER, + EXPEDITIOUS_BRACELET, FUNGICIDE_SPRAY, IMPBOX, TELEPORT, diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java index c59741ac52..b46cf11e9e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java @@ -37,7 +37,9 @@ enum ItemWithSlot ABYSSAL_BRACELET(ItemChargeType.ABYSSAL_BRACELET, EquipmentInventorySlot.GLOVES), AMULET_OF_CHEMISTY(ItemChargeType.AMULET_OF_CHEMISTRY, EquipmentInventorySlot.AMULET), AMULET_OF_BOUNTY(ItemChargeType.AMULET_OF_BOUNTY, EquipmentInventorySlot.AMULET), + BRACELET_OF_SLAUGHTER(ItemChargeType.BRACELET_OF_SLAUGHTER, EquipmentInventorySlot.GLOVES), DODGY_NECKLACE(ItemChargeType.DODGY_NECKLACE, EquipmentInventorySlot.AMULET), + EXPEDITIOUS_BRACELET(ItemChargeType.EXPEDITIOUS_BRACELET, EquipmentInventorySlot.GLOVES), BINDING_NECKLACE(ItemChargeType.BINDING_NECKLACE, EquipmentInventorySlot.AMULET), EXPLORER_RING(ItemChargeType.EXPLORER_RING, EquipmentInventorySlot.RING), RING_OF_FORGING(ItemChargeType.RING_OF_FORGING, EquipmentInventorySlot.RING), diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java index a881da8f73..9daa94a2cf 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java @@ -84,6 +84,16 @@ public class ItemChargePluginTest private static final String CHRONICLE_ADD_MULTIPLE_CHARGES = "You add 5 charges to your book. It now has 5 charges."; private static final String CHRONICLE_ADD_FULL = "Your book is fully charged! It has 1,000 charges already."; + private static final String CHECK_BRACELET_OF_SLAUGHTER = "Your bracelet of slaughter has 25 charges left."; + private static final String CHECK_BRACELET_OF_SLAUGHTER_1 = "Your bracelet of slaughter has 1 charge left."; + private static final String ACTIVATE_BRACELET_OF_SLAUGHTER = "Your bracelet of slaughter prevents your slayer count from decreasing. It has 16 charges left."; + private static final String BREAK_BRACELET_OF_SLAUGHTER = "Your bracelet of slaughter prevents your slayer count from decreasing. It then crumbles to dust."; + + private static final String CHECK_EXPEDITIOUS_BRACELET = "Your expeditious bracelet has 6 charges left."; + private static final String CHECK_EXPEDITIOUS_BRACELET_1 = "Your expeditious bracelet has 1 charge left."; + private static final String ACTIVATE_EXPEDITIOUS_BRACELET = "Your expeditious bracelet helps you progress your slayer task faster. It has 11 charges left."; + private static final String BREAK_EXPEDITIOUS_BRACELET = "Your expeditious bracelet helps you progress your slayer task faster. It then crumbles to dust."; + @Mock @Bind private Client client; @@ -268,5 +278,47 @@ public class ItemChargePluginTest itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1000); reset(configManager); + + // Bracelet of Slaughter + chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_BRACELET_OF_SLAUGHTER, "", 0); + itemChargePlugin.onChatMessage(chatMessage); + verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 25); + reset(config); + + chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_BRACELET_OF_SLAUGHTER_1, "", 0); + itemChargePlugin.onChatMessage(chatMessage); + verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 1); + reset(config); + + chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", ACTIVATE_BRACELET_OF_SLAUGHTER, "", 0); + itemChargePlugin.onChatMessage(chatMessage); + verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 16); + reset(config); + + chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_BRACELET_OF_SLAUGHTER, "", 0); + itemChargePlugin.onChatMessage(chatMessage); + verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 30); + reset(config); + + // Expeditious Bracelet + chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_EXPEDITIOUS_BRACELET, "", 0); + itemChargePlugin.onChatMessage(chatMessage); + verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 6); + reset(config); + + chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_EXPEDITIOUS_BRACELET_1, "", 0); + itemChargePlugin.onChatMessage(chatMessage); + verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 1); + reset(config); + + chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", ACTIVATE_EXPEDITIOUS_BRACELET, "", 0); + itemChargePlugin.onChatMessage(chatMessage); + verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 11); + reset(config); + + chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_EXPEDITIOUS_BRACELET, "", 0); + itemChargePlugin.onChatMessage(chatMessage); + verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 30); + reset(config); } } \ No newline at end of file From 18bd40c702d4309a3ef65f95631ef11504e42254 Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Sun, 14 Feb 2021 13:46:34 +0000 Subject: [PATCH 03/13] slayer: remove bracelet charge tracking --- .../client/plugins/slayer/SlayerConfig.java | 2 - .../client/plugins/slayer/SlayerOverlay.java | 19 +--- .../client/plugins/slayer/SlayerPlugin.java | 81 ++--------------- .../plugins/slayer/SlayerPluginTest.java | 89 ------------------- 4 files changed, 6 insertions(+), 185 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerConfig.java index fb01be8487..d16f96fa58 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerConfig.java @@ -44,8 +44,6 @@ public interface SlayerConfig extends Config String TASK_LOC_KEY = "taskLocation"; String STREAK_KEY = "streak"; String POINTS_KEY = "points"; - String EXPEDITIOUS_CHARGES_KEY = "expeditious"; - String SLAUGHTER_CHARGES_KEY = "slaughter"; @ConfigItem( position = 1, diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java index f07954bd6e..d6c656fedc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerOverlay.java @@ -77,8 +77,6 @@ class SlayerOverlay extends WidgetItemOverlay ItemID.SLAYER_RING_ETERNAL, ItemID.ENCHANTED_GEM, ItemID.ETERNAL_GEM, - ItemID.BRACELET_OF_SLAUGHTER, - ItemID.EXPEDITIOUS_BRACELET, ItemID.SLAYER_RING_1, ItemID.SLAYER_RING_2, ItemID.SLAYER_RING_3, @@ -120,26 +118,11 @@ class SlayerOverlay extends WidgetItemOverlay return; } - int slaughterCount = plugin.getSlaughterChargeCount(); - int expeditiousCount = plugin.getExpeditiousChargeCount(); - graphics.setFont(FontManager.getRunescapeSmallFont()); final Rectangle bounds = widgetItem.getCanvasBounds(); final TextComponent textComponent = new TextComponent(); - - switch (itemId) - { - case ItemID.EXPEDITIOUS_BRACELET: - textComponent.setText(String.valueOf(expeditiousCount)); - break; - case ItemID.BRACELET_OF_SLAUGHTER: - textComponent.setText(String.valueOf(slaughterCount)); - break; - default: - textComponent.setText(String.valueOf(amount)); - break; - } + textComponent.setText(String.valueOf(amount)); // Draw the counter in the bottom left for equipment, and top left for jewelry textComponent.setPosition(new Point(bounds.x - 1, bounds.y - 1 + (SLAYER_JEWELRY.contains(itemId) 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 bc9281980e..58f0942de2 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 @@ -105,13 +105,7 @@ public class SlayerPlugin extends Plugin private static final String CHAT_CANCEL_MESSAGE_ZUK = "You no longer have a slayer task as you left the Inferno."; private static final String CHAT_SUPERIOR_MESSAGE = "A superior foe has appeared..."; private static final String CHAT_BRACELET_SLAUGHTER = "Your bracelet of slaughter prevents your slayer"; - private static final Pattern CHAT_BRACELET_SLAUGHTER_REGEX = Pattern.compile("Your bracelet of slaughter prevents your slayer count from decreasing. It has (\\d{1,2}) charges? left\\."); private static final String CHAT_BRACELET_EXPEDITIOUS = "Your expeditious bracelet helps you progress your"; - private static final Pattern CHAT_BRACELET_EXPEDITIOUS_REGEX = Pattern.compile("Your expeditious bracelet helps you progress your slayer (?:task )?faster. It has (\\d{1,2}) charges? left\\."); - private static final String CHAT_BRACELET_SLAUGHTER_CHARGE = "Your bracelet of slaughter has "; - private static final Pattern CHAT_BRACELET_SLAUGHTER_CHARGE_REGEX = Pattern.compile("Your bracelet of slaughter has (\\d{1,2}) charges? left\\."); - private static final String CHAT_BRACELET_EXPEDITIOUS_CHARGE = "Your expeditious bracelet has "; - private static final Pattern CHAT_BRACELET_EXPEDITIOUS_CHARGE_REGEX = Pattern.compile("Your expeditious bracelet has (\\d{1,2}) charges? left\\."); private static final Pattern COMBAT_BRACELET_TASK_UPDATE_MESSAGE = Pattern.compile("^You still need to kill (\\d+) monsters to complete your current Slayer assignment"); //NPC messages @@ -125,9 +119,6 @@ public class SlayerPlugin extends Plugin private static final int GROTESQUE_GUARDIANS_REGION = 6727; - private static final int EXPEDITIOUS_CHARGE = 30; - private static final int SLAUGHTER_CHARGE = 30; - // Chat Command private static final String TASK_COMMAND_STRING = "!task"; private static final Pattern TASK_STRING_VALIDATION = Pattern.compile("[^a-zA-Z0-9' -]"); @@ -200,14 +191,6 @@ public class SlayerPlugin extends Plugin @Setter(AccessLevel.PACKAGE) private String taskLocation; - @Getter(AccessLevel.PACKAGE) - @Setter(AccessLevel.PACKAGE) - private int expeditiousChargeCount; - - @Getter(AccessLevel.PACKAGE) - @Setter(AccessLevel.PACKAGE) - private int slaughterChargeCount; - @Getter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE) private String taskName; @@ -235,8 +218,6 @@ public class SlayerPlugin extends Plugin if (getIntProfileConfig(SlayerConfig.AMOUNT_KEY) != -1 && !getStringProfileConfig(SlayerConfig.TASK_NAME_KEY).isEmpty()) { - setExpeditiousChargeCount(getIntProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY)); - setSlaughterChargeCount(getIntProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY)); clientThread.invoke(() -> setTask(getStringProfileConfig(SlayerConfig.TASK_NAME_KEY), getIntProfileConfig(SlayerConfig.AMOUNT_KEY), getIntProfileConfig(SlayerConfig.INIT_AMOUNT_KEY), @@ -288,8 +269,6 @@ public class SlayerPlugin extends Plugin && !getStringProfileConfig(SlayerConfig.TASK_NAME_KEY).isEmpty() && loginFlag) { - setExpeditiousChargeCount(getIntProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY)); - setSlaughterChargeCount(getIntProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY)); setTask(getStringProfileConfig(SlayerConfig.TASK_NAME_KEY), getIntProfileConfig(SlayerConfig.AMOUNT_KEY), getIntProfileConfig(SlayerConfig.INIT_AMOUNT_KEY), @@ -332,8 +311,6 @@ public class SlayerPlugin extends Plugin setProfileConfig(SlayerConfig.INIT_AMOUNT_KEY, initialAmount); setProfileConfig(SlayerConfig.TASK_NAME_KEY, taskName); setProfileConfig(SlayerConfig.TASK_LOC_KEY, taskLocation); - setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount); - setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount); } @Subscribe @@ -394,22 +371,6 @@ public class SlayerPlugin extends Plugin } } - Widget braceletBreakWidget = client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT); - if (braceletBreakWidget != null) - { - String braceletText = Text.removeTags(braceletBreakWidget.getText()); //remove color and linebreaks - if (braceletText.contains("bracelet of slaughter")) - { - slaughterChargeCount = SLAUGHTER_CHARGE; - setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount); - } - else if (braceletText.contains("expeditious bracelet")) - { - expeditiousChargeCount = EXPEDITIOUS_CHARGE; - setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount); - } - } - Widget rewardsBarWidget = client.getWidget(WidgetInfo.SLAYER_REWARDS_TOPBAR); if (rewardsBarWidget != null) { @@ -460,45 +421,11 @@ public class SlayerPlugin extends Plugin if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER)) { - Matcher mSlaughter = CHAT_BRACELET_SLAUGHTER_REGEX.matcher(chatMsg); - amount++; - slaughterChargeCount = mSlaughter.find() ? Integer.parseInt(mSlaughter.group(1)) : SLAUGHTER_CHARGE; - setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount); } - - if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS)) + else if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS)) { - Matcher mExpeditious = CHAT_BRACELET_EXPEDITIOUS_REGEX.matcher(chatMsg); - amount--; - expeditiousChargeCount = mExpeditious.find() ? Integer.parseInt(mExpeditious.group(1)) : EXPEDITIOUS_CHARGE; - setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount); - } - - if (chatMsg.startsWith(CHAT_BRACELET_EXPEDITIOUS_CHARGE)) - { - Matcher mExpeditious = CHAT_BRACELET_EXPEDITIOUS_CHARGE_REGEX.matcher(chatMsg); - - if (!mExpeditious.find()) - { - return; - } - - expeditiousChargeCount = Integer.parseInt(mExpeditious.group(1)); - setProfileConfig(SlayerConfig.EXPEDITIOUS_CHARGES_KEY, expeditiousChargeCount); - } - - if (chatMsg.startsWith(CHAT_BRACELET_SLAUGHTER_CHARGE)) - { - Matcher mSlaughter = CHAT_BRACELET_SLAUGHTER_CHARGE_REGEX.matcher(chatMsg); - if (!mSlaughter.find()) - { - return; - } - - slaughterChargeCount = Integer.parseInt(mSlaughter.group(1)); - setProfileConfig(SlayerConfig.SLAUGHTER_CHARGES_KEY, slaughterChargeCount); } if (chatMsg.startsWith("You've completed") && (chatMsg.contains("Slayer master") || chatMsg.contains("Slayer Master"))) @@ -939,8 +866,10 @@ public class SlayerPlugin extends Plugin migrateConfigKey(SlayerConfig.TASK_LOC_KEY); migrateConfigKey(SlayerConfig.STREAK_KEY); migrateConfigKey(SlayerConfig.POINTS_KEY); - migrateConfigKey(SlayerConfig.EXPEDITIOUS_CHARGES_KEY); - migrateConfigKey(SlayerConfig.SLAUGHTER_CHARGES_KEY); + configManager.unsetConfiguration(SlayerConfig.GROUP_NAME, "expeditious"); + configManager.unsetConfiguration(SlayerConfig.GROUP_NAME, "slaughter"); + configManager.unsetRSProfileConfiguration(SlayerConfig.GROUP_NAME, "expeditious"); + configManager.unsetRSProfileConfiguration(SlayerConfig.GROUP_NAME, "slaughter"); } private void migrateConfigKey(String key) 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 f10e525ce8..6785721349 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 @@ -120,21 +120,6 @@ public class SlayerPluginTest private static final String BRACLET_SLAUGHTER = "Your bracelet of slaughter prevents your slayer count from decreasing. It has 9 charges left."; private static final String BRACLET_EXPEDITIOUS = "Your expeditious bracelet helps you progress your slayer task faster. It has 9 charges left."; - private static final String BRACLET_SLAUGHTER_V2 = "Your bracelet of slaughter prevents your slayer count from decreasing. It has 1 charge left."; - private static final String BRACLET_EXPEDITIOUS_V2 = "Your expeditious bracelet helps you progress your slayer faster. It has 1 charge left."; - - private static final String BRACLET_SLAUGHTER_V3 = "Your bracelet of slaughter prevents your slayer count from decreasing. It then crumbles to dust."; - private static final String BRACLET_EXPEDITIOUS_V3 = "Your expeditious bracelet helps you progress your slayer faster. It then crumbles to dust."; - - private static final String CHAT_BRACELET_SLAUGHTER_CHARGE = "Your bracelet of slaughter has 12 charges left."; - private static final String CHAT_BRACELET_EXPEDITIOUS_CHARGE = "Your expeditious bracelet has 12 charges left."; - - private static final String CHAT_BRACELET_SLAUGHTER_CHARGE_ONE = "Your bracelet of slaughter has 1 charge left."; - private static final String CHAT_BRACELET_EXPEDITIOUS_CHARGE_ONE = "Your expeditious bracelet has 1 charge left."; - - private static final String BREAK_SLAUGHTER = "The bracelet shatters. Your next bracelet of slaughter
will start afresh from 30 charges."; - private static final String BREAK_EXPEDITIOUS = "The bracelet shatters. Your next expeditious bracelet
will start afresh from 30 charges."; - @Mock @Bind Client client; @@ -730,47 +715,10 @@ public class SlayerPluginTest public void testBraceletSlaughter() { ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_SLAUGHTER, null, 0); - slayerPlugin.setAmount(42); - slayerPlugin.setSlaughterChargeCount(10); slayerPlugin.onChatMessage(chatMessageEvent); - assertEquals(9, slayerPlugin.getSlaughterChargeCount()); - assertEquals(43, slayerPlugin.getAmount()); - - chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_SLAUGHTER_CHARGE, null, 0); - slayerPlugin.onChatMessage(chatMessageEvent); - - assertEquals(12, slayerPlugin.getSlaughterChargeCount()); - - chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_SLAUGHTER_CHARGE_ONE, null, 0); - slayerPlugin.onChatMessage(chatMessageEvent); - - assertEquals(1, slayerPlugin.getSlaughterChargeCount()); - - slayerPlugin.setSlaughterChargeCount(1); - chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_SLAUGHTER_V3, null, 0); - slayerPlugin.onChatMessage(chatMessageEvent); - - assertEquals(30, slayerPlugin.getSlaughterChargeCount()); - - Widget braceletBreakWidget = mock(Widget.class); - when(braceletBreakWidget.getText()).thenReturn(BREAK_SLAUGHTER); - when(client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT)).thenReturn(braceletBreakWidget); - - slayerPlugin.setSlaughterChargeCount(-1); - slayerPlugin.onGameTick(new GameTick()); - assertEquals(30, slayerPlugin.getSlaughterChargeCount()); - - chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_SLAUGHTER_V2, null, 0); - - slayerPlugin.setAmount(42); - slayerPlugin.setSlaughterChargeCount(2); - - slayerPlugin.onChatMessage(chatMessageEvent); - - assertEquals(1, slayerPlugin.getSlaughterChargeCount()); assertEquals(43, slayerPlugin.getAmount()); } @@ -778,48 +726,11 @@ public class SlayerPluginTest public void testBraceletExpeditious() { ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_EXPEDITIOUS, null, 0); - slayerPlugin.setAmount(42); - slayerPlugin.setExpeditiousChargeCount(10); slayerPlugin.onChatMessage(chatMessageEvent); assertEquals(41, slayerPlugin.getAmount()); - assertEquals(9, slayerPlugin.getExpeditiousChargeCount()); - - chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_EXPEDITIOUS_CHARGE, null, 0); - slayerPlugin.onChatMessage(chatMessageEvent); - - assertEquals(12, slayerPlugin.getExpeditiousChargeCount()); - - chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", CHAT_BRACELET_EXPEDITIOUS_CHARGE_ONE, null, 0); - slayerPlugin.onChatMessage(chatMessageEvent); - - assertEquals(1, slayerPlugin.getExpeditiousChargeCount()); - - slayerPlugin.setExpeditiousChargeCount(1); - chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_EXPEDITIOUS_V3, null, 0); - slayerPlugin.onChatMessage(chatMessageEvent); - - assertEquals(30, slayerPlugin.getExpeditiousChargeCount()); - - Widget braceletBreakWidget = mock(Widget.class); - when(braceletBreakWidget.getText()).thenReturn(BREAK_EXPEDITIOUS); - when(client.getWidget(WidgetInfo.DIALOG_SPRITE_TEXT)).thenReturn(braceletBreakWidget); - - slayerPlugin.setExpeditiousChargeCount(-1); - slayerPlugin.onGameTick(new GameTick()); - assertEquals(30, slayerPlugin.getExpeditiousChargeCount()); - - chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", BRACLET_EXPEDITIOUS_V2, null, 0); - - slayerPlugin.setAmount(42); - slayerPlugin.setExpeditiousChargeCount(2); - - slayerPlugin.onChatMessage(chatMessageEvent); - - assertEquals(41, slayerPlugin.getAmount()); - assertEquals(1, slayerPlugin.getExpeditiousChargeCount()); } @Test From 6dca841c87adfd7d6b1eb24a32c9c2c82cf27d45 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 May 2021 12:46:51 -0400 Subject: [PATCH 04/13] item charges: simplify infobox creation logic This looks at the worn items and matches them to known items with charges, instead of checking the worn items for each known item with charges. Additionally it associates guthix rest to potions, because previously they did not have a config option, and adds an infobox for the chronicle. --- .../itemcharges/ItemChargeInfobox.java | 6 +- .../itemcharges/ItemChargeOverlay.java | 93 +---- .../plugins/itemcharges/ItemChargePlugin.java | 345 ++++-------------- .../plugins/itemcharges/ItemChargeType.java | 46 ++- .../plugins/itemcharges/ItemWithCharge.java | 8 +- .../plugins/itemcharges/ItemWithConfig.java | 74 ++++ .../plugins/itemcharges/ItemWithSlot.java | 57 --- .../itemcharges/ItemChargePluginTest.java | 2 + 8 files changed, 202 insertions(+), 429 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithConfig.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeInfobox.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeInfobox.java index 7ee70d44b5..102c7bfac4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeInfobox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeInfobox.java @@ -27,14 +27,16 @@ package net.runelite.client.plugins.itemcharges; import java.awt.Color; import java.awt.image.BufferedImage; import lombok.Getter; +import lombok.ToString; import net.runelite.api.EquipmentInventorySlot; import net.runelite.client.ui.overlay.infobox.Counter; @Getter +@ToString class ItemChargeInfobox extends Counter { private final ItemChargePlugin plugin; - private final ItemWithSlot item; + private final int item; private final EquipmentInventorySlot slot; ItemChargeInfobox( @@ -42,7 +44,7 @@ class ItemChargeInfobox extends Counter BufferedImage image, String name, int charges, - ItemWithSlot item, + int item, EquipmentInventorySlot slot) { super(image, plugin, charges); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java index b028fa444a..39f081c4e5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java @@ -30,9 +30,19 @@ import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import javax.inject.Inject; -import net.runelite.api.ItemID; import net.runelite.api.widgets.WidgetItem; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.*; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.ABYSSAL_BRACELET; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.AMULET_OF_BOUNTY; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.AMULET_OF_CHEMISTRY; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.BELLOWS; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.FRUIT_BASKET; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.FUNGICIDE_SPRAY; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.IMPBOX; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.POTION; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.SACK; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.TELEPORT; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.WidgetItemOverlay; import net.runelite.client.ui.overlay.components.TextComponent; @@ -62,86 +72,15 @@ class ItemChargeOverlay extends WidgetItemOverlay graphics.setFont(FontManager.getRunescapeSmallFont()); int charges; - if (itemId == ItemID.DODGY_NECKLACE) + ItemWithConfig itemWithConfig = ItemWithConfig.findItem(itemId); + if (itemWithConfig != null) { - if (!config.showDodgyCount()) + if (!itemWithConfig.getType().getEnabled().apply(config)) { return; } - charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_DODGY_NECKLACE); - } - else if (itemId == ItemID.BINDING_NECKLACE) - { - if (!config.showBindingNecklaceCharges()) - { - return; - } - - charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_BINDING_NECKLACE); - } - else if (itemId >= ItemID.EXPLORERS_RING_1 && itemId <= ItemID.EXPLORERS_RING_4) - { - if (!config.showExplorerRingCharges()) - { - return; - } - - charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_EXPLORERS_RING); - } - else if (itemId == ItemID.RING_OF_FORGING) - { - if (!config.showRingOfForgingCount()) - { - return; - } - - charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_RING_OF_FORGING); - } - else if (itemId == ItemID.AMULET_OF_CHEMISTRY) - { - if (!config.showAmuletOfChemistryCharges()) - { - return; - } - - charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY); - } - else if (itemId == ItemID.AMULET_OF_BOUNTY) - { - if (!config.showAmuletOfBountyCharges()) - { - return; - } - - charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_AMULET_OF_BOUNTY); - } - else if (itemId == ItemID.CHRONICLE) - { - if (!config.showTeleportCharges()) - { - return; - } - - charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_CHRONICLE); - } - else if (itemId == ItemID.BRACELET_OF_SLAUGHTER) - { - if (!config.showBraceletOfSlaughterCharges()) - { - return; - } - - charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER); - } - else if (itemId == ItemID.EXPEDITIOUS_BRACELET) - { - if (!config.showExpeditiousBraceletCharges()) - { - return; - } - - charges = itemChargePlugin.getItemCharges(ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET); + charges = itemChargePlugin.getItemCharges(itemWithConfig.getConfigKey()); } else { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java index 2c964d6709..237a2174c0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java @@ -31,6 +31,8 @@ import com.google.common.primitives.Ints; import com.google.inject.Provides; import java.awt.Color; import java.awt.image.BufferedImage; +import java.util.EnumMap; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; @@ -167,6 +169,7 @@ public class ItemChargePlugin extends Plugin // Limits destroy callback to once per tick private int lastCheckTick; + private final Map infoboxes = new EnumMap<>(EquipmentInventorySlot.class); @Provides ItemChargeConfig getConfig(ConfigManager configManager) @@ -185,6 +188,7 @@ public class ItemChargePlugin extends Plugin { overlayManager.remove(overlay); infoBoxManager.removeIf(ItemChargeInfobox.class::isInstance); + infoboxes.clear(); lastCheckTick = -1; } @@ -196,51 +200,7 @@ public class ItemChargePlugin extends Plugin return; } - if (!config.showInfoboxes()) - { - infoBoxManager.removeIf(ItemChargeInfobox.class::isInstance); - return; - } - - if (!config.showTeleportCharges()) - { - removeInfobox(ItemWithSlot.TELEPORT); - } - - if (!config.showAmuletOfChemistryCharges()) - { - removeInfobox(ItemWithSlot.AMULET_OF_CHEMISTY); - } - - if (!config.showAmuletOfBountyCharges()) - { - removeInfobox(ItemWithSlot.AMULET_OF_BOUNTY); - } - - if (!config.showAbyssalBraceletCharges()) - { - removeInfobox(ItemWithSlot.ABYSSAL_BRACELET); - } - - if (!config.showDodgyCount()) - { - removeInfobox(ItemWithSlot.DODGY_NECKLACE); - } - - if (!config.showBindingNecklaceCharges()) - { - removeInfobox(ItemWithSlot.BINDING_NECKLACE); - } - - if (!config.showExplorerRingCharges()) - { - removeInfobox(ItemWithSlot.EXPLORER_RING); - } - - if (!config.showRingOfForgingCount()) - { - removeInfobox(ItemWithSlot.RING_OF_FORGING); - } + clientThread.invoke(this::updateInfoboxes); } @Subscribe @@ -457,62 +417,12 @@ public class ItemChargePlugin extends Plugin @Subscribe public void onItemContainerChanged(ItemContainerChanged event) { - if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT) || !config.showInfoboxes()) + if (event.getContainerId() != InventoryID.EQUIPMENT.getId()) { return; } - final Item[] items = event.getItemContainer().getItems(); - - if (config.showTeleportCharges()) - { - updateJewelleryInfobox(ItemWithSlot.TELEPORT, items); - } - - if (config.showDodgyCount()) - { - updateJewelleryInfobox(ItemWithSlot.DODGY_NECKLACE, items); - } - - if (config.showAbyssalBraceletCharges()) - { - updateJewelleryInfobox(ItemWithSlot.ABYSSAL_BRACELET, items); - } - - if (config.showBindingNecklaceCharges()) - { - updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, items); - } - - if (config.showExplorerRingCharges()) - { - updateJewelleryInfobox(ItemWithSlot.EXPLORER_RING, items); - } - - if (config.showRingOfForgingCount()) - { - updateJewelleryInfobox(ItemWithSlot.RING_OF_FORGING, items); - } - - if (config.showAmuletOfChemistryCharges()) - { - updateJewelleryInfobox(ItemWithSlot.AMULET_OF_CHEMISTY, items); - } - - if (config.showAmuletOfBountyCharges()) - { - updateJewelleryInfobox(ItemWithSlot.AMULET_OF_BOUNTY, items); - } - - if (config.showBraceletOfSlaughterCharges()) - { - updateJewelleryInfobox(ItemWithSlot.BRACELET_OF_SLAUGHTER, items); - } - - if (config.showExpeditiousBraceletCharges()) - { - updateJewelleryInfobox(ItemWithSlot.EXPEDITIOUS_BRACELET, items); - } + updateInfoboxes(); } @Subscribe @@ -582,138 +492,50 @@ public class ItemChargePlugin extends Plugin private void updateDodgyNecklaceCharges(final int value) { setItemCharges(ItemChargeConfig.KEY_DODGY_NECKLACE, value); - - if (config.showInfoboxes() && config.showDodgyCount()) - { - final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); - - if (itemContainer == null) - { - return; - } - - updateJewelleryInfobox(ItemWithSlot.DODGY_NECKLACE, itemContainer.getItems()); - } + updateInfoboxes(); } private void updateAmuletOfChemistryCharges(final int value) { setItemCharges(ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, value); - - if (config.showInfoboxes() && config.showAmuletOfChemistryCharges()) - { - final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); - - if (itemContainer == null) - { - return; - } - - updateJewelleryInfobox(ItemWithSlot.AMULET_OF_CHEMISTY, itemContainer.getItems()); - } + updateInfoboxes(); } private void updateAmuletOfBountyCharges(final int value) { setItemCharges(ItemChargeConfig.KEY_AMULET_OF_BOUNTY, value); - - if (config.showInfoboxes() && config.showAmuletOfBountyCharges()) - { - final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); - - if (itemContainer == null) - { - return; - } - - updateJewelleryInfobox(ItemWithSlot.AMULET_OF_BOUNTY, itemContainer.getItems()); - } + updateInfoboxes(); } private void updateBindingNecklaceCharges(final int value) { setItemCharges(ItemChargeConfig.KEY_BINDING_NECKLACE, value); - - if (config.showInfoboxes() && config.showBindingNecklaceCharges()) - { - final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); - - if (itemContainer == null) - { - return; - } - - updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, itemContainer.getItems()); - } + updateInfoboxes(); } private void updateExplorerRingCharges(final int value) { // Note: Varbit counts upwards. We count down from the maximum charges. setItemCharges(ItemChargeConfig.KEY_EXPLORERS_RING, MAX_EXPLORER_RING_CHARGES - value); - - if (config.showInfoboxes() && config.showExplorerRingCharges()) - { - final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); - - if (itemContainer == null) - { - return; - } - - updateJewelleryInfobox(ItemWithSlot.EXPLORER_RING, itemContainer.getItems()); - } + updateInfoboxes(); } private void updateRingOfForgingCharges(final int value) { setItemCharges(ItemChargeConfig.KEY_RING_OF_FORGING, value); - - if (config.showInfoboxes() && config.showRingOfForgingCount()) - { - final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); - - if (itemContainer == null) - { - return; - } - - updateJewelleryInfobox(ItemWithSlot.RING_OF_FORGING, itemContainer.getItems()); - } + updateInfoboxes(); } private void updateBraceletOfSlaughterCharges(final int value) { setItemCharges(ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, value); - - if (config.showInfoboxes() && config.showBraceletOfSlaughterCharges()) - { - final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); - - if (itemContainer == null) - { - return; - } - - updateJewelleryInfobox(ItemWithSlot.BRACELET_OF_SLAUGHTER, itemContainer.getItems()); - } + updateInfoboxes(); } private void updateExpeditiousBraceletCharges(final int value) { setItemCharges(ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, value); - - if (config.showInfoboxes() && config.showExpeditiousBraceletCharges()) - { - final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); - - if (itemContainer == null) - { - return; - } - - updateJewelleryInfobox(ItemWithSlot.EXPEDITIOUS_BRACELET, itemContainer.getItems()); - } + updateInfoboxes(); } private void checkDestroyWidget() @@ -738,81 +560,85 @@ public class ItemChargePlugin extends Plugin } } - private void updateJewelleryInfobox(ItemWithSlot item, Item[] items) + private void updateInfoboxes() { - for (final EquipmentInventorySlot equipmentInventorySlot : item.getSlots()) - { - updateJewelleryInfobox(item, items, equipmentInventorySlot); - } - } + final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); - private void updateJewelleryInfobox(ItemWithSlot type, Item[] items, EquipmentInventorySlot slot) - { - removeInfobox(type, slot); - - if (slot.getSlotIdx() >= items.length) + if (itemContainer == null) { return; } - final int id = items[slot.getSlotIdx()].getId(); - if (id < 0) + final Item[] items = itemContainer.getItems(); + boolean showInfoboxes = config.showInfoboxes(); + for (EquipmentInventorySlot slot : EquipmentInventorySlot.values()) { - return; - } + if (slot.getSlotIdx() >= items.length) + { + break; + } - final ItemWithCharge itemWithCharge = ItemWithCharge.findItem(id); - int charges = -1; + Item i = items[slot.getSlotIdx()]; + int id = i.getId(); + ItemChargeType type = null; + int charges = -1; - if (itemWithCharge == null) - { - if (id == ItemID.DODGY_NECKLACE && type == ItemWithSlot.DODGY_NECKLACE) + final ItemWithCharge itemWithCharge = ItemWithCharge.findItem(id); + if (itemWithCharge != null) { - charges = getItemCharges(ItemChargeConfig.KEY_DODGY_NECKLACE); + type = itemWithCharge.getType(); + charges = itemWithCharge.getCharges(); } - else if (id == ItemID.BINDING_NECKLACE && type == ItemWithSlot.BINDING_NECKLACE) + else { - charges = getItemCharges(ItemChargeConfig.KEY_BINDING_NECKLACE); + final ItemWithConfig itemWithConfig = ItemWithConfig.findItem(id); + if (itemWithConfig != null) + { + type = itemWithConfig.getType(); + charges = getItemCharges(itemWithConfig.getConfigKey()); + } } - else if ((id >= ItemID.EXPLORERS_RING_1 && id <= ItemID.EXPLORERS_RING_4) && type == ItemWithSlot.EXPLORER_RING) + + boolean enabled = type != null && type.getEnabled().apply(config); + + if (showInfoboxes && enabled && charges > 0) { - charges = getItemCharges(ItemChargeConfig.KEY_EXPLORERS_RING); + ItemChargeInfobox infobox = infoboxes.get(slot); + if (infobox != null) + { + if (infobox.getItem() == id) + { + if (infobox.getCount() == charges) + { + continue; + } + + log.debug("Updating infobox count for {}", infobox); + infobox.setCount(charges); + continue; + } + + log.debug("Rebuilding infobox {}", infobox); + infoBoxManager.removeInfoBox(infobox); + infoboxes.remove(slot); + } + + final String name = itemManager.getItemComposition(id).getName(); + final BufferedImage image = itemManager.getImage(id); + infobox = new ItemChargeInfobox(this, image, name, charges, id, slot); + infoBoxManager.addInfoBox(infobox); + infoboxes.put(slot, infobox); } - else if (id == ItemID.RING_OF_FORGING && type == ItemWithSlot.RING_OF_FORGING) + else { - charges = getItemCharges(ItemChargeConfig.KEY_RING_OF_FORGING); - } - else if (id == ItemID.AMULET_OF_CHEMISTRY && type == ItemWithSlot.AMULET_OF_CHEMISTY) - { - charges = getItemCharges(ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY); - } - else if (id == ItemID.AMULET_OF_BOUNTY && type == ItemWithSlot.AMULET_OF_BOUNTY) - { - charges = getItemCharges(ItemChargeConfig.KEY_AMULET_OF_BOUNTY); - } - else if (id == ItemID.BRACELET_OF_SLAUGHTER && type == ItemWithSlot.BRACELET_OF_SLAUGHTER) - { - charges = getItemCharges(ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER); - } - else if (id == ItemID.EXPEDITIOUS_BRACELET && type == ItemWithSlot.EXPEDITIOUS_BRACELET) - { - charges = getItemCharges(ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET); + ItemChargeInfobox infobox = infoboxes.remove(slot); + if (infobox != null) + { + log.debug("Removing infobox {}", infobox); + infoBoxManager.removeInfoBox(infobox); + } } } - else if (itemWithCharge.getType() == type.getType()) - { - charges = itemWithCharge.getCharges(); - } - - if (charges <= 0) - { - return; - } - - final String name = itemManager.getItemComposition(id).getName(); - final BufferedImage image = itemManager.getImage(id); - final ItemChargeInfobox infobox = new ItemChargeInfobox(this, image, name, charges, type, slot); - infoBoxManager.addInfoBox(infobox); } int getItemCharges(String key) @@ -835,25 +661,6 @@ public class ItemChargePlugin extends Plugin configManager.setRSProfileConfiguration(ItemChargeConfig.GROUP, key, value); } - private void removeInfobox(final ItemWithSlot item) - { - infoBoxManager.removeIf(t -> t instanceof ItemChargeInfobox && ((ItemChargeInfobox) t).getItem() == item); - } - - private void removeInfobox(final ItemWithSlot item, final EquipmentInventorySlot slot) - { - infoBoxManager.removeIf(t -> - { - if (!(t instanceof ItemChargeInfobox)) - { - return false; - } - - final ItemChargeInfobox i = (ItemChargeInfobox) t; - return i.getItem() == item && i.getSlot() == slot; - }); - } - Color getColor(int charges) { Color color = Color.WHITE; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java index 7abf9ac0a1..f713c008c9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java @@ -25,26 +25,32 @@ */ package net.runelite.client.plugins.itemcharges; +import java.util.function.Function; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter enum ItemChargeType { - ABYSSAL_BRACELET, - AMULET_OF_CHEMISTRY, - AMULET_OF_BOUNTY, - BELLOWS, - BRACELET_OF_SLAUGHTER, - EXPEDITIOUS_BRACELET, - FUNGICIDE_SPRAY, - IMPBOX, - TELEPORT, - WATERCAN, - WATERSKIN, - DODGY_NECKLACE, - BINDING_NECKLACE, - EXPLORER_RING, - FRUIT_BASKET, - SACK, - RING_OF_FORGING, - GUTHIX_REST, - CHRONICLE, - POTION, + ABYSSAL_BRACELET(ItemChargeConfig::showAbyssalBraceletCharges), + AMULET_OF_CHEMISTRY(ItemChargeConfig::showAmuletOfChemistryCharges), + AMULET_OF_BOUNTY(ItemChargeConfig::showAmuletOfBountyCharges), + BELLOWS(ItemChargeConfig::showBellowCharges), + BRACELET_OF_SLAUGHTER(ItemChargeConfig::showBraceletOfSlaughterCharges), + EXPEDITIOUS_BRACELET(ItemChargeConfig::showExpeditiousBraceletCharges), + FUNGICIDE_SPRAY(ItemChargeConfig::showFungicideCharges), + IMPBOX(ItemChargeConfig::showImpCharges), + TELEPORT(ItemChargeConfig::showTeleportCharges), + WATERCAN(ItemChargeConfig::showWateringCanCharges), + WATERSKIN(ItemChargeConfig::showWaterskinCharges), + DODGY_NECKLACE(ItemChargeConfig::showDodgyCount), + BINDING_NECKLACE(ItemChargeConfig::showBindingNecklaceCharges), + EXPLORER_RING(ItemChargeConfig::showExplorerRingCharges), + FRUIT_BASKET(ItemChargeConfig::showBasketCharges), + SACK(ItemChargeConfig::showSackCharges), + RING_OF_FORGING(ItemChargeConfig::showRingOfForgingCount), + POTION(ItemChargeConfig::showPotionDoseCount); + + private final Function enabled; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java index b9c1124423..5984389ff4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java @@ -231,10 +231,10 @@ enum ItemWithCharge GLORYT4(TELEPORT, AMULET_OF_GLORY_T4, 4), GLORYT5(TELEPORT, AMULET_OF_GLORY_T5, 5), GLORYT6(TELEPORT, AMULET_OF_GLORY_T6, 6), - GREST1(GUTHIX_REST, GUTHIX_REST1, 1), - GREST2(GUTHIX_REST, GUTHIX_REST2, 2), - GREST3(GUTHIX_REST, GUTHIX_REST3, 3), - GREST4(GUTHIX_REST, GUTHIX_REST4, 4), + GREST1(POTION, GUTHIX_REST1, 1), + GREST2(POTION, GUTHIX_REST2, 2), + GREST3(POTION, GUTHIX_REST3, 3), + GREST4(POTION, GUTHIX_REST4, 4), GUTHIX_BAL1(POTION, GUTHIX_BALANCE1, 1), GUTHIX_BAL2(POTION, GUTHIX_BALANCE2, 2), GUTHIX_BAL3(POTION, GUTHIX_BALANCE3, 3), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithConfig.java new file mode 100644 index 0000000000..ca77f40d15 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithConfig.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021, 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.client.plugins.itemcharges; + +import com.google.common.collect.ImmutableMap; +import java.util.Map; +import javax.annotation.Nullable; +import lombok.AllArgsConstructor; +import lombok.Getter; +import net.runelite.api.ItemID; + +@AllArgsConstructor +@Getter +enum ItemWithConfig +{ + DODGY_NECKLACE(ItemID.DODGY_NECKLACE, ItemChargeConfig.KEY_DODGY_NECKLACE, ItemChargeType.DODGY_NECKLACE), + BINDING_NECKLACE(ItemID.BINDING_NECKLACE, ItemChargeConfig.KEY_BINDING_NECKLACE, ItemChargeType.BINDING_NECKLACE), + EXPLORERS_RING_1(ItemID.EXPLORERS_RING_1, ItemChargeConfig.KEY_EXPLORERS_RING, ItemChargeType.EXPLORER_RING), + EXPLORERS_RING_2(ItemID.EXPLORERS_RING_2, ItemChargeConfig.KEY_EXPLORERS_RING, ItemChargeType.EXPLORER_RING), + EXPLORERS_RING_3(ItemID.EXPLORERS_RING_3, ItemChargeConfig.KEY_EXPLORERS_RING, ItemChargeType.EXPLORER_RING), + EXPLORERS_RING_4(ItemID.EXPLORERS_RING_4, ItemChargeConfig.KEY_EXPLORERS_RING, ItemChargeType.EXPLORER_RING), + RING_OF_FORGING(ItemID.RING_OF_FORGING, ItemChargeConfig.KEY_RING_OF_FORGING, ItemChargeType.RING_OF_FORGING), + AMULET_OF_CHEMISTRY(ItemID.AMULET_OF_CHEMISTRY, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, ItemChargeType.AMULET_OF_CHEMISTRY), + AMULET_OF_BOUNTY(ItemID.AMULET_OF_BOUNTY, ItemChargeConfig.KEY_AMULET_OF_BOUNTY, ItemChargeType.AMULET_OF_BOUNTY), + BRACELET_OF_SLAUGHTER(ItemID.BRACELET_OF_SLAUGHTER, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, ItemChargeType.BRACELET_OF_SLAUGHTER), + EXPEDITIOUS_BRACELET(ItemID.EXPEDITIOUS_BRACELET, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, ItemChargeType.EXPEDITIOUS_BRACELET), + CHRONICLE(ItemID.CHRONICLE, ItemChargeConfig.KEY_CHRONICLE, ItemChargeType.TELEPORT); + + private final int itemId; + private final String configKey; + private final ItemChargeType type; + + private static final Map ID_MAP; + + static + { + ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); + + for (ItemWithConfig item : values()) + { + builder.put(item.getItemId(), item); + } + + ID_MAP = builder.build(); + } + + @Nullable + static ItemWithConfig findItem(int itemId) + { + return ID_MAP.get(itemId); + } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java deleted file mode 100644 index b46cf11e9e..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2019, Tomas Slusny - * Copyright (c) 2019, Aleios - * Copyright (c) 2020, Unmoon - * 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.itemcharges; - -import com.google.common.collect.Sets; -import java.util.Set; -import lombok.Getter; -import net.runelite.api.EquipmentInventorySlot; - -@Getter -enum ItemWithSlot -{ - ABYSSAL_BRACELET(ItemChargeType.ABYSSAL_BRACELET, EquipmentInventorySlot.GLOVES), - AMULET_OF_CHEMISTY(ItemChargeType.AMULET_OF_CHEMISTRY, EquipmentInventorySlot.AMULET), - AMULET_OF_BOUNTY(ItemChargeType.AMULET_OF_BOUNTY, EquipmentInventorySlot.AMULET), - BRACELET_OF_SLAUGHTER(ItemChargeType.BRACELET_OF_SLAUGHTER, EquipmentInventorySlot.GLOVES), - DODGY_NECKLACE(ItemChargeType.DODGY_NECKLACE, EquipmentInventorySlot.AMULET), - EXPEDITIOUS_BRACELET(ItemChargeType.EXPEDITIOUS_BRACELET, EquipmentInventorySlot.GLOVES), - BINDING_NECKLACE(ItemChargeType.BINDING_NECKLACE, EquipmentInventorySlot.AMULET), - EXPLORER_RING(ItemChargeType.EXPLORER_RING, EquipmentInventorySlot.RING), - RING_OF_FORGING(ItemChargeType.RING_OF_FORGING, EquipmentInventorySlot.RING), - CHRONICLE(ItemChargeType.CHRONICLE, EquipmentInventorySlot.SHIELD), - TELEPORT(ItemChargeType.TELEPORT, EquipmentInventorySlot.WEAPON, EquipmentInventorySlot.AMULET, EquipmentInventorySlot.GLOVES, EquipmentInventorySlot.RING); - - private final ItemChargeType type; - private final Set slots; - - ItemWithSlot(final ItemChargeType type, final EquipmentInventorySlot... slots) - { - this.type = type; - this.slots = Sets.newHashSet(slots); - } -} diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java index 9daa94a2cf..2e0f60c19c 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java @@ -32,6 +32,7 @@ import java.util.concurrent.ScheduledExecutorService; import net.runelite.api.ChatMessageType; 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.ChatMessage; @@ -173,6 +174,7 @@ public class ItemChargePluginTest ItemContainer equipmentItemContainer = mock(ItemContainer.class); when(client.getItemContainer(InventoryID.EQUIPMENT)).thenReturn(equipmentItemContainer); when(equipmentItemContainer.contains(ItemID.RING_OF_FORGING)).thenReturn(true); + when(equipmentItemContainer.getItems()).thenReturn(new Item[0]); // Run message chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_RING_OF_FORGING, "", 0); itemChargePlugin.onChatMessage(chatMessage); From 038ba21649e64097d364f59db0cbdb2b3da35021 Mon Sep 17 00:00:00 2001 From: RuneLogApp <82402185+RuneLogApp@users.noreply.github.com> Date: Sun, 9 May 2021 22:51:36 +0100 Subject: [PATCH 05/13] music plugin: add null check to SettingsSideSlider icon on shutdown --- .../java/net/runelite/client/plugins/music/MusicPlugin.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/music/MusicPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/music/MusicPlugin.java index 4fce105ff8..2df8b7a1f7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/music/MusicPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/music/MusicPlugin.java @@ -599,7 +599,10 @@ public class MusicPlugin extends Plugin handle.setSpriteId(SpriteID.SETTINGS_SLIDER_HANDLE_BLUE); } - this.icon.setOnOpListener((Object[]) null); + if (this.icon != null) + { + this.icon.setOnOpListener((Object[]) null); + } Widget root = client.getWidget(this.root); if (root != null) From ab7023fac54ee795638ca2a12cb628126409fe40 Mon Sep 17 00:00:00 2001 From: Hydrox6 Date: Tue, 23 Feb 2021 18:24:26 +0000 Subject: [PATCH 06/13] camera: add option to preserve pitch on compass look menu entries --- .../client/plugins/camera/CameraConfig.java | 15 +++++++++++++-- .../client/plugins/camera/CameraPlugin.java | 6 ++++++ .../src/main/scripts/ToplevelCompassOp.rs2asm | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraConfig.java index 4c406af095..5f019c82ca 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraConfig.java @@ -159,11 +159,22 @@ public interface CameraConfig extends Config return true; } + @ConfigItem( + keyName = "compassLookPreservePitch", + name = "Preserve pitch on compass look", + description = "Preserves the current pitch value (vertical angle) when using the compass look options.", + position = 11 + ) + default boolean compassLookPreservePitch() + { + return false; + } + @ConfigItem( keyName = "invertYaw", name = "Invert Yaw", description = "Makes moving the camera horizontally with the mouse backwards", - position = 11 + position = 12 ) default boolean invertYaw() { @@ -174,7 +185,7 @@ public interface CameraConfig extends Config keyName = "invertPitch", name = "Invert Pitch", description = "Makes moving the camera vertically with the mouse backwards", - position = 12 + position = 13 ) default boolean invertPitch() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraPlugin.java index 3c2076a1aa..904420080a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/camera/CameraPlugin.java @@ -249,6 +249,12 @@ public class CameraPlugin extends Plugin implements KeyListener, MouseListener return; } + if ("lookPreservePitch".equals(event.getEventName()) && config.compassLookPreservePitch()) + { + intStack[intStackSize - 1] = client.getCameraPitch(); + return; + } + if (config.innerLimit()) { // This lets the options panel's slider have an exponential rate diff --git a/runelite-client/src/main/scripts/ToplevelCompassOp.rs2asm b/runelite-client/src/main/scripts/ToplevelCompassOp.rs2asm index 6884cdf1f0..cd3eabe7f1 100644 --- a/runelite-client/src/main/scripts/ToplevelCompassOp.rs2asm +++ b/runelite-client/src/main/scripts/ToplevelCompassOp.rs2asm @@ -47,6 +47,8 @@ LOOK: iconst 0 sound_synth iconst 225 + sconst "lookPreservePitch" + runelite_callback iconst 5 randominc add From 52dc8f85a73889968e22cd05e99e86272aac4216 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 11 May 2021 19:19:21 -0400 Subject: [PATCH 07/13] clientloader: don't use fallback config or client when jav_config is manually specified --- .../src/main/java/net/runelite/client/rs/ClientLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 68b8d13c0f..bc7a98faef 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 @@ -143,7 +143,7 @@ public class ClientLoader implements Supplier catch (IOException ex) { // try again with the fallback config and gamepack - if (!config.isFallback()) + if (javConfigUrl.equals(RuneLiteProperties.getJavConfig()) && !config.isFallback()) { log.warn("Unable to download game client, attempting to use fallback config", ex); config = downloadFallbackConfig(); @@ -404,7 +404,7 @@ public class ClientLoader implements Supplier log.warn("Failed to download gamepack from \"{}\"", url, e); // With fallback config do 1 attempt (there are no additional urls to try) - if (config.isFallback() || attempt >= NUM_ATTEMPTS) + if (!javConfigUrl.equals(RuneLiteProperties.getJavConfig()) || config.isFallback() || attempt >= NUM_ATTEMPTS) { throw e; } From 1581aff73a8892bab962b25e91377db0acb4f2b1 Mon Sep 17 00:00:00 2001 From: Paul Norton Date: Wed, 14 Apr 2021 09:36:16 -0400 Subject: [PATCH 08/13] Add Below Ice Mountain quest Add BIM to the world map plugin quest start locations, and the Camdozaal dungeon to the skybox and discord regions Co-authored-by: Adam --- runelite-api/src/main/java/net/runelite/api/Quest.java | 1 + .../runelite/client/plugins/discord/DiscordGameEventType.java | 1 + .../runelite/client/plugins/worldmap/QuestStartLocation.java | 3 ++- .../resources/net/runelite/client/plugins/skybox/skybox.txt | 4 ++++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/runelite-api/src/main/java/net/runelite/api/Quest.java b/runelite-api/src/main/java/net/runelite/api/Quest.java index 0265ba1ae9..688109214f 100644 --- a/runelite-api/src/main/java/net/runelite/api/Quest.java +++ b/runelite-api/src/main/java/net/runelite/api/Quest.java @@ -31,6 +31,7 @@ import lombok.RequiredArgsConstructor; public enum Quest { //Free Quests + BELOW_ICE_MOUNTAIN(2874, "Below Ice Mountain"), BLACK_KNIGHTS_FORTRESS(299, "Black Knights' Fortress"), COOKS_ASSISTANT(300, "Cook's Assistant"), THE_CORSAIR_CURSE(301, "The Corsair Curse"), 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 7190e70108..788a284740 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 @@ -241,6 +241,7 @@ enum DiscordGameEventType DUNGEON_OURANIA("Ourania Cave", DiscordAreaType.DUNGEONS, 12119), DUNGEON_QUIDAMORTEM_CAVE("Quidamortem Cave", DiscordAreaType.DUNGEONS, 4763), DUNGEON_RASHILIYIAS_TOMB("Rashiliyta's Tomb", DiscordAreaType.DUNGEONS, 11668), + DUNGEON_RUINS_OF_CAMDOZAAL("Ruins of Camdozaal", DiscordAreaType.DUNGEONS, 11609, 11610, 11611, 11865, 11866, 11867, 12121, 12122, 12123), DUNGEON_SALT_MINE("Salt Mine", DiscordAreaType.DUNGEONS, 11425), DUNGEON_SARADOMINSHRINE("Saradomin Shrine (Paterdomus)", DiscordAreaType.DUNGEONS, 13722), DUNGEON_SHADE_CATACOMBS("Shade Catacombs", DiscordAreaType.DUNGEONS, 13975), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java index f731d20e9a..69cefb040c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/QuestStartLocation.java @@ -26,14 +26,15 @@ package net.runelite.client.plugins.worldmap; import lombok.Getter; -import net.runelite.api.coords.WorldPoint; import net.runelite.api.Quest; +import net.runelite.api.coords.WorldPoint; // Some quests are in the same spot, but they are done in order. If multiple // quests start in the same location, an array of quests is expected. enum QuestStartLocation { //Free Quests + BELOW_ICE_MOUNTAIN(Quest.BELOW_ICE_MOUNTAIN, new WorldPoint(3001, 3436, 0)), COOKS_ASSISTANT_RFD(Quest.COOKS_ASSISTANT, new WorldPoint(3211, 3216, 0)), THE_CORSAIR_CURSE(Quest.THE_CORSAIR_CURSE, new WorldPoint(3029, 3273, 0)), DEMON_SLAYER(Quest.DEMON_SLAYER, new WorldPoint(3204, 3424, 0)), diff --git a/runelite-client/src/main/resources/net/runelite/client/plugins/skybox/skybox.txt b/runelite-client/src/main/resources/net/runelite/client/plugins/skybox/skybox.txt index fb8bd463ce..8312e96beb 100644 --- a/runelite-client/src/main/resources/net/runelite/client/plugins/skybox/skybox.txt +++ b/runelite-client/src/main/resources/net/runelite/client/plugins/skybox/skybox.txt @@ -994,3 +994,7 @@ R 33 79 33 80 // Nightmare dungeon (Morytania underground) #0a0a0a R 58 151 60 153 + +// ruins of camdozaal +#292030 +R 45 89 47 91 From 16fdfd14425376c92921fc3478bb5afa2f764fda Mon Sep 17 00:00:00 2001 From: Runelite auto updater Date: Wed, 12 May 2021 15:18:55 +0000 Subject: [PATCH 09/13] Release 1.7.7 --- 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-jshell/pom.xml | 2 +- runelite-script-assembler-plugin/pom.xml | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cache-client/pom.xml b/cache-client/pom.xml index 2a05871bca..4b513814f9 100644 --- a/cache-client/pom.xml +++ b/cache-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.7-SNAPSHOT + 1.7.7 cache-client diff --git a/cache-updater/pom.xml b/cache-updater/pom.xml index 5cbb5fed77..dcbedd421b 100644 --- a/cache-updater/pom.xml +++ b/cache-updater/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.7-SNAPSHOT + 1.7.7 Cache Updater diff --git a/cache/pom.xml b/cache/pom.xml index 9b5ab0b5b1..2f315d3105 100644 --- a/cache/pom.xml +++ b/cache/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.7-SNAPSHOT + 1.7.7 cache diff --git a/http-api/pom.xml b/http-api/pom.xml index 5575de5516..db05cd114c 100644 --- a/http-api/pom.xml +++ b/http-api/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.7-SNAPSHOT + 1.7.7 Web API diff --git a/http-service/pom.xml b/http-service/pom.xml index c326f38204..fecae96252 100644 --- a/http-service/pom.xml +++ b/http-service/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.7-SNAPSHOT + 1.7.7 Web Service diff --git a/pom.xml b/pom.xml index 7ac9d60c86..33cebafdb6 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.7-SNAPSHOT + 1.7.7 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.7.7 diff --git a/runelite-api/pom.xml b/runelite-api/pom.xml index e6ff96e647..b3ecd85993 100644 --- a/runelite-api/pom.xml +++ b/runelite-api/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.7-SNAPSHOT + 1.7.7 runelite-api diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index 120b08c2c7..cebd88fa10 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.7-SNAPSHOT + 1.7.7 client diff --git a/runelite-jshell/pom.xml b/runelite-jshell/pom.xml index a018a1d92a..a89923917c 100644 --- a/runelite-jshell/pom.xml +++ b/runelite-jshell/pom.xml @@ -30,7 +30,7 @@ net.runelite runelite-parent - 1.7.7-SNAPSHOT + 1.7.7 jshell diff --git a/runelite-script-assembler-plugin/pom.xml b/runelite-script-assembler-plugin/pom.xml index 5412a05d9e..015d088c4c 100644 --- a/runelite-script-assembler-plugin/pom.xml +++ b/runelite-script-assembler-plugin/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.7-SNAPSHOT + 1.7.7 script-assembler-plugin From 80eb6f27596664d26168b72577e1a36f7c6f827e Mon Sep 17 00:00:00 2001 From: Runelite auto updater Date: Wed, 12 May 2021 15:19:00 +0000 Subject: [PATCH 10/13] Bump for 1.7.8-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-jshell/pom.xml | 2 +- runelite-script-assembler-plugin/pom.xml | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cache-client/pom.xml b/cache-client/pom.xml index 4b513814f9..4579f05227 100644 --- a/cache-client/pom.xml +++ b/cache-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.7 + 1.7.8-SNAPSHOT cache-client diff --git a/cache-updater/pom.xml b/cache-updater/pom.xml index dcbedd421b..1401cd397f 100644 --- a/cache-updater/pom.xml +++ b/cache-updater/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.7 + 1.7.8-SNAPSHOT Cache Updater diff --git a/cache/pom.xml b/cache/pom.xml index 2f315d3105..05793a12f6 100644 --- a/cache/pom.xml +++ b/cache/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.7 + 1.7.8-SNAPSHOT cache diff --git a/http-api/pom.xml b/http-api/pom.xml index db05cd114c..e1ae3f5194 100644 --- a/http-api/pom.xml +++ b/http-api/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.7 + 1.7.8-SNAPSHOT Web API diff --git a/http-service/pom.xml b/http-service/pom.xml index fecae96252..8d6ca1fa45 100644 --- a/http-service/pom.xml +++ b/http-service/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.7 + 1.7.8-SNAPSHOT Web Service diff --git a/pom.xml b/pom.xml index 33cebafdb6..cb0b8fa9f9 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ net.runelite runelite-parent - 1.7.7 + 1.7.8-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.7.7 + HEAD diff --git a/runelite-api/pom.xml b/runelite-api/pom.xml index b3ecd85993..d3dcff8d77 100644 --- a/runelite-api/pom.xml +++ b/runelite-api/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.7 + 1.7.8-SNAPSHOT runelite-api diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index cebd88fa10..b0eaf9961e 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.7 + 1.7.8-SNAPSHOT client diff --git a/runelite-jshell/pom.xml b/runelite-jshell/pom.xml index a89923917c..deb4c592d2 100644 --- a/runelite-jshell/pom.xml +++ b/runelite-jshell/pom.xml @@ -30,7 +30,7 @@ net.runelite runelite-parent - 1.7.7 + 1.7.8-SNAPSHOT jshell diff --git a/runelite-script-assembler-plugin/pom.xml b/runelite-script-assembler-plugin/pom.xml index 015d088c4c..cebf69870a 100644 --- a/runelite-script-assembler-plugin/pom.xml +++ b/runelite-script-assembler-plugin/pom.xml @@ -29,7 +29,7 @@ net.runelite runelite-parent - 1.7.7 + 1.7.8-SNAPSHOT script-assembler-plugin From ae23301a22bf7208e9cd825ef74e74823355aff3 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 12 May 2021 16:13:53 -0400 Subject: [PATCH 11/13] item charges: add toggle for guthix rest Since guthix rest are not visibly different, but potions are, there are requests to restore the old behavior of having guthix rest on but potions off --- .../plugins/itemcharges/ItemChargeConfig.java | 12 +++++ .../itemcharges/ItemChargeOverlay.java | 47 ++----------------- .../plugins/itemcharges/ItemChargePlugin.java | 2 +- .../plugins/itemcharges/ItemChargeType.java | 7 +-- .../plugins/itemcharges/ItemWithCharge.java | 8 ++-- 5 files changed, 25 insertions(+), 51 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 dfdb592b43..82af2d77d3 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 @@ -403,4 +403,16 @@ public interface ItemChargeConfig extends Config { return true; } + + @ConfigItem( + keyName = "showGuthixRestDoses", + name = "Guthix Rest Doses", + description = "Show Guthix Rest doses", + position = 29, + section = chargesSection + ) + default boolean showGuthixRestDoses() + { + return true; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java index 39f081c4e5..6bba477561 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeOverlay.java @@ -31,18 +31,6 @@ import java.awt.Point; import java.awt.Rectangle; import javax.inject.Inject; import net.runelite.api.widgets.WidgetItem; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.ABYSSAL_BRACELET; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.AMULET_OF_BOUNTY; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.AMULET_OF_CHEMISTRY; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.BELLOWS; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.FRUIT_BASKET; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.FUNGICIDE_SPRAY; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.IMPBOX; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.POTION; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.SACK; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.TELEPORT; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.WidgetItemOverlay; import net.runelite.client.ui.overlay.components.TextComponent; @@ -64,18 +52,11 @@ class ItemChargeOverlay extends WidgetItemOverlay @Override public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem widgetItem) { - if (!displayOverlay()) - { - return; - } - - graphics.setFont(FontManager.getRunescapeSmallFont()); - int charges; ItemWithConfig itemWithConfig = ItemWithConfig.findItem(itemId); if (itemWithConfig != null) { - if (!itemWithConfig.getType().getEnabled().apply(config)) + if (!itemWithConfig.getType().getEnabled().test(config)) { return; } @@ -91,18 +72,7 @@ class ItemChargeOverlay extends WidgetItemOverlay } ItemChargeType type = chargeItem.getType(); - if ((type == TELEPORT && !config.showTeleportCharges()) - || (type == FUNGICIDE_SPRAY && !config.showFungicideCharges()) - || (type == IMPBOX && !config.showImpCharges()) - || (type == WATERCAN && !config.showWateringCanCharges()) - || (type == WATERSKIN && !config.showWaterskinCharges()) - || (type == BELLOWS && !config.showBellowCharges()) - || (type == FRUIT_BASKET && !config.showBasketCharges()) - || (type == SACK && !config.showSackCharges()) - || (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges()) - || (type == AMULET_OF_CHEMISTRY && !config.showAmuletOfChemistryCharges()) - || (type == AMULET_OF_BOUNTY && !config.showAmuletOfBountyCharges()) - || (type == POTION && !config.showPotionDoseCount())) + if (!type.getEnabled().test(config)) { return; } @@ -110,6 +80,8 @@ class ItemChargeOverlay extends WidgetItemOverlay charges = chargeItem.getCharges(); } + graphics.setFont(FontManager.getRunescapeSmallFont()); + final Rectangle bounds = widgetItem.getCanvasBounds(); final TextComponent textComponent = new TextComponent(); textComponent.setPosition(new Point(bounds.x - 1, bounds.y + 15)); @@ -117,15 +89,4 @@ class ItemChargeOverlay extends WidgetItemOverlay textComponent.setColor(itemChargePlugin.getColor(charges)); textComponent.render(graphics); } - - private boolean displayOverlay() - { - return config.showTeleportCharges() || config.showDodgyCount() || config.showFungicideCharges() - || config.showImpCharges() || config.showWateringCanCharges() || config.showWaterskinCharges() - || config.showBellowCharges() || config.showBasketCharges() || config.showSackCharges() - || config.showAbyssalBraceletCharges() || config.showExplorerRingCharges() || config.showRingOfForgingCount() - || config.showAmuletOfChemistryCharges() || config.showAmuletOfBountyCharges() || config.showPotionDoseCount() - || config.showBraceletOfSlaughterCharges() || config.showExpeditiousBraceletCharges(); - - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java index 237a2174c0..c9a7d4ecd2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java @@ -599,7 +599,7 @@ public class ItemChargePlugin extends Plugin } } - boolean enabled = type != null && type.getEnabled().apply(config); + boolean enabled = type != null && type.getEnabled().test(config); if (showInfoboxes && enabled && charges > 0) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java index f713c008c9..294a865c1f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeType.java @@ -25,7 +25,7 @@ */ package net.runelite.client.plugins.itemcharges; -import java.util.function.Function; +import java.util.function.Predicate; import lombok.AllArgsConstructor; import lombok.Getter; @@ -50,7 +50,8 @@ enum ItemChargeType FRUIT_BASKET(ItemChargeConfig::showBasketCharges), SACK(ItemChargeConfig::showSackCharges), RING_OF_FORGING(ItemChargeConfig::showRingOfForgingCount), - POTION(ItemChargeConfig::showPotionDoseCount); + POTION(ItemChargeConfig::showPotionDoseCount), + GUTHIX_REST(ItemChargeConfig::showGuthixRestDoses); - private final Function enabled; + private final Predicate enabled; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java index 5984389ff4..b9c1124423 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java @@ -231,10 +231,10 @@ enum ItemWithCharge GLORYT4(TELEPORT, AMULET_OF_GLORY_T4, 4), GLORYT5(TELEPORT, AMULET_OF_GLORY_T5, 5), GLORYT6(TELEPORT, AMULET_OF_GLORY_T6, 6), - GREST1(POTION, GUTHIX_REST1, 1), - GREST2(POTION, GUTHIX_REST2, 2), - GREST3(POTION, GUTHIX_REST3, 3), - GREST4(POTION, GUTHIX_REST4, 4), + GREST1(GUTHIX_REST, GUTHIX_REST1, 1), + GREST2(GUTHIX_REST, GUTHIX_REST2, 2), + GREST3(GUTHIX_REST, GUTHIX_REST3, 3), + GREST4(GUTHIX_REST, GUTHIX_REST4, 4), GUTHIX_BAL1(POTION, GUTHIX_BALANCE1, 1), GUTHIX_BAL2(POTION, GUTHIX_BALANCE2, 2), GUTHIX_BAL3(POTION, GUTHIX_BALANCE3, 3), From 4740d7f2fc70b5c3ac4f95cd54a2ba0d380db02d Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 12 May 2021 17:20:16 -0400 Subject: [PATCH 12/13] item charges: split up test into separate methods --- .../itemcharges/ItemChargePluginTest.java | 270 ++++++++++++------ 1 file changed, 184 insertions(+), 86 deletions(-) diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java index 2e0f60c19c..f1e9c50edd 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/itemcharges/ItemChargePluginTest.java @@ -28,7 +28,6 @@ import com.google.inject.Guice; import com.google.inject.Inject; import com.google.inject.testing.fieldbinder.Bind; import com.google.inject.testing.fieldbinder.BoundFieldModule; -import java.util.concurrent.ScheduledExecutorService; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.InventoryID; @@ -38,7 +37,7 @@ import net.runelite.api.ItemID; import net.runelite.api.events.ChatMessage; import net.runelite.client.Notifier; import net.runelite.client.config.ConfigManager; -import net.runelite.client.config.RuneLiteConfig; +import net.runelite.client.game.ItemManager; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager; import org.junit.Before; @@ -46,7 +45,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import org.mockito.junit.MockitoJUnitRunner; @@ -99,14 +97,6 @@ public class ItemChargePluginTest @Bind private Client client; - @Mock - @Bind - private ScheduledExecutorService scheduledExecutorService; - - @Mock - @Bind - private RuneLiteConfig runeLiteConfig; - @Mock @Bind private OverlayManager overlayManager; @@ -127,6 +117,10 @@ public class ItemChargePluginTest @Bind private ConfigManager configManager; + @Mock + @Bind + private ItemManager itemManager; + @Inject private ItemChargePlugin itemChargePlugin; @@ -136,39 +130,59 @@ public class ItemChargePluginTest Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); } + // Dodgy necklace @Test - public void testOnChatMessage() + public void testDodgyCheck() { ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_DODGY_NECKLACE, 10); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", PROTECT, "", 0); + @Test + public void testDodgyProtect() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", PROTECT, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_DODGY_NECKLACE, 9); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", PROTECT_1, "", 0); + @Test + public void testDodgyProtect1() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", PROTECT_1, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_DODGY_NECKLACE, 1); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK, "", 0); + @Test + public void testDodgyBreak() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_DODGY_NECKLACE, 10); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_RING_OF_FORGING_ONE, "", 0); + // Ring of forging + @Test + public void testRofOne() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_RING_OF_FORGING_ONE, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_RING_OF_FORGING, 1); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_RING_OF_FORGING_FULL, "", 0); + @Test + public void testRofFull() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_RING_OF_FORGING_FULL, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_RING_OF_FORGING, 140); - reset(configManager); + } + @Test + public void testRof() + { when(configManager.getRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_RING_OF_FORGING, Integer.class)).thenReturn(90); // Create equipment inventory with ring of forging ItemContainer equipmentItemContainer = mock(ItemContainer.class); @@ -176,151 +190,235 @@ public class ItemChargePluginTest when(equipmentItemContainer.contains(ItemID.RING_OF_FORGING)).thenReturn(true); when(equipmentItemContainer.getItems()).thenReturn(new Item[0]); // Run message - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_RING_OF_FORGING, "", 0); + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_RING_OF_FORGING, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_RING_OF_FORGING, 89); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_RING_OF_FORGING, "", 0); + @Test + public void testRofBreak() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_RING_OF_FORGING, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_RING_OF_FORGING, 140); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_AMULET_OF_CHEMISTRY, "", 0); + // Chemistry + @Test + public void testChemistryCheck() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_AMULET_OF_CHEMISTRY, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 5); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_AMULET_OF_CHEMISTRY_1, "", 0); + @Test + public void testChemistry1() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_AMULET_OF_CHEMISTRY_1, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 1); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY, "", 0); + @Test + public void testChemistryUsed4() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 4); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY_3_DOSES, "", 0); + @Test + public void testChemistryUsed3() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY_3_DOSES, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 2); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY_2_DOSES, "", 0); + @Test + public void testChemistryUsed2() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_AMULET_OF_CHEMISTRY_2_DOSES, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 1); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY, "", 0); + @Test + public void testChemistryBreak() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 5); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY_3_DOSES, "", 0); + @Test + public void testChemistryBreak3() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY_3_DOSES, "", 0); + itemChargePlugin.onChatMessage(chatMessage); + } + + @Test + public void testChemistryBreak2() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY_2_DOSES, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 5); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_AMULET_OF_CHEMISTRY_2_DOSES, "", 0); - itemChargePlugin.onChatMessage(chatMessage); - verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_AMULET_OF_CHEMISTRY, 5); - reset(configManager); - - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_FULL, "", 0); + // Chronicle + @Test + public void testChronicleCheckFull() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_FULL, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1000); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_ONE, "", 0); + @Test + public void testChronicleChargeOne() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_ONE, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_EMPTY, "", 0); + @Test + public void testChronicleChargeEmpty() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_CHECK_CHARGES_EMPTY, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 0); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT, "", 0); + @Test + public void testChronicleTeleport() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 999); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_ONE, "", 0); + @Test + public void testChronicleTeleportOne() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_ONE, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_EMPTY, "", 0); + @Test + public void testChronicleTeleportEmpty() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_EMPTY, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 0); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_FAIL, "", 0); + @Test + public void testChronicleTeleportFail() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_TELEPORT_FAIL, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 0); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_SINGLE_CHARGE, "", 0); + @Test + public void testChronicleAddSingleCharge() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_SINGLE_CHARGE, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_SINGLE_CHARGE_FULL, "", 0); + @Test + public void testChronicleAddSingleChargeFull() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_SINGLE_CHARGE_FULL, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1000); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_MULTIPLE_CHARGES, "", 0); + @Test + public void testChronicleAddMultipleCharges() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_MULTIPLE_CHARGES, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 5); - reset(configManager); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_FULL, "", 0); + @Test + public void testChronicleAddFull() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHRONICLE_ADD_FULL, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_CHRONICLE, 1000); - reset(configManager); + } - // Bracelet of Slaughter - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_BRACELET_OF_SLAUGHTER, "", 0); + // Bracelet of Slaughter + @Test + public void testSlaughterCheck() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_BRACELET_OF_SLAUGHTER, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 25); - reset(config); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_BRACELET_OF_SLAUGHTER_1, "", 0); + @Test + public void testSlaughterCheck1() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_BRACELET_OF_SLAUGHTER_1, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 1); - reset(config); + } - chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", ACTIVATE_BRACELET_OF_SLAUGHTER, "", 0); + @Test + public void testSlaughterActivate() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", ACTIVATE_BRACELET_OF_SLAUGHTER, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 16); - reset(config); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_BRACELET_OF_SLAUGHTER, "", 0); + @Test + public void testSlaughterBreak() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_BRACELET_OF_SLAUGHTER, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_BRACELET_OF_SLAUGHTER, 30); - reset(config); + } - // Expeditious Bracelet - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_EXPEDITIOUS_BRACELET, "", 0); + // Expeditious Bracelet + @Test + public void testExpeditiousCheck() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_EXPEDITIOUS_BRACELET, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 6); - reset(config); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_EXPEDITIOUS_BRACELET_1, "", 0); + @Test + public void testExpeditiousCheck1() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK_EXPEDITIOUS_BRACELET_1, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 1); - reset(config); + } - chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", ACTIVATE_EXPEDITIOUS_BRACELET, "", 0); + @Test + public void testExpeditiousActivate() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", ACTIVATE_EXPEDITIOUS_BRACELET, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 11); - reset(config); + } - chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_EXPEDITIOUS_BRACELET, "", 0); + @Test + public void testExpeditiousBreak() + { + ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK_EXPEDITIOUS_BRACELET, "", 0); itemChargePlugin.onChatMessage(chatMessage); verify(configManager).setRSProfileConfiguration(ItemChargeConfig.GROUP, ItemChargeConfig.KEY_EXPEDITIOUS_BRACELET, 30); - reset(config); } } \ No newline at end of file From 4c0abc4511beb6f079629d9989feb0bbdf3323f9 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 13 May 2021 14:19:42 -0400 Subject: [PATCH 13/13] chat message manager: fix recoloring own name with spaces --- .../main/java/net/runelite/client/chat/ChatMessageManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java index 3d14b7a5c4..76038ce8b8 100644 --- a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java +++ b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java @@ -130,7 +130,7 @@ public class ChatMessageManager case PUBLICCHAT: case MODCHAT: { - String sanitizedUsername = Text.removeTags(chatMessage.getName()); + String sanitizedUsername = Text.removeTags(chatMessage.getName()).replace('\u00A0', ' '); if (client.getLocalPlayer().getName().equals(sanitizedUsername)) {