From f74a60840ddcf1af7f357bb49232e13988c9fa03 Mon Sep 17 00:00:00 2001 From: Daniel Bolink Date: Wed, 12 Feb 2020 12:53:08 -0800 Subject: [PATCH] itemcharges: Track Amulet of Bounty charges Closes runelite/runelite#10781 --- .../plugins/itemcharges/ItemChargeConfig.java | 43 ++++++++++++--- .../itemcharges/ItemChargeOverlay.java | 14 ++++- .../plugins/itemcharges/ItemChargePlugin.java | 53 +++++++++++++++++++ .../plugins/itemcharges/ItemChargeType.java | 1 + .../plugins/itemcharges/ItemWithSlot.java | 1 + 5 files changed, 103 insertions(+), 9 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 98c7cec887..66c14ea22d 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 @@ -245,11 +245,40 @@ public interface ItemChargeConfig extends Config ) void amuletOfChemistry(int amuletOfChemistry); + @ConfigItem( + keyName = "showAmuletOfBountyCharges", + name = "Show Amulet of Bounty Charges", + description = "Configures if amulet of bounty item charge is shown", + position = 17 + ) + default boolean showAmuletOfBountyCharges() + { + return true; + } + + @ConfigItem( + keyName = "amuletOfBounty", + name = "", + description = "", + hidden = true + ) + default int amuletOfBounty() + { + return -1; + } + + @ConfigItem( + keyName = "amuletOfBounty", + name = "", + description = "" + ) + void amuletOfBounty(int amuletOfBounty); + @ConfigItem( keyName = "recoilNotification", name = "Ring of Recoil Notification", description = "Configures if the ring of recoil breaking notification is shown", - position = 17 + position = 18 ) default boolean recoilNotification() { @@ -260,7 +289,7 @@ public interface ItemChargeConfig extends Config keyName = "showBindingNecklaceCharges", name = "Show Binding Necklace Charges", description = "Configures if binding necklace item charge is shown", - position = 18 + position = 19 ) default boolean showBindingNecklaceCharges() { @@ -289,7 +318,7 @@ public interface ItemChargeConfig extends Config keyName = "bindingNotification", name = "Binding Necklace Notification", description = "Configures if the binding necklace breaking notification is shown", - position = 19 + position = 20 ) default boolean bindingNotification() { @@ -300,7 +329,7 @@ public interface ItemChargeConfig extends Config keyName = "showExplorerRingCharges", name = "Show Explorer's Ring Alch Charges", description = "Configures if explorer's ring alchemy charges are shown", - position = 20 + position = 21 ) default boolean showExplorerRingCharges() { @@ -329,7 +358,7 @@ public interface ItemChargeConfig extends Config keyName = "showRingOfForgingCount", name = "Show Ring of Forging Charges", description = "Configures if the Ring of Forging charge count is shown", - position = 21 + position = 22 ) default boolean showRingOfForgingCount() { @@ -358,7 +387,7 @@ public interface ItemChargeConfig extends Config keyName = "ringOfForgingNotification", name = "Ring of Forging Notification", description = "Configures if the Ring of Forging breaking notification is enabled", - position = 22 + position = 23 ) default boolean ringOfForgingNotification() { @@ -369,7 +398,7 @@ public interface ItemChargeConfig extends Config keyName = "showInfoboxes", name = "Show Infoboxes", description = "Configures whether to show an infobox equipped charge items", - position = 23 + position = 24 ) default boolean showInfoboxes() { 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 c0ad1518b6..d23db92cc7 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 @@ -106,6 +106,15 @@ class ItemChargeOverlay extends WidgetItemOverlay charges = config.amuletOfChemistry(); } + else if (itemId == ItemID.AMULET_OF_BOUNTY) + { + if (!config.showAmuletOfBountyCharges()) + { + return; + } + + charges = config.amuletOfBounty(); + } else { ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId); @@ -124,7 +133,8 @@ class ItemChargeOverlay extends WidgetItemOverlay || (type == FRUIT_BASKET && !config.showBasketCharges()) || (type == SACK && !config.showSackCharges()) || (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges()) - || (type == AMULET_OF_CHEMISTRY && !config.showAmuletOfChemistryCharges())) + || (type == AMULET_OF_CHEMISTRY && !config.showAmuletOfChemistryCharges()) + || (type == AMULET_OF_BOUNTY && !config.showAmuletOfBountyCharges())) { return; } @@ -146,7 +156,7 @@ 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.showAmuletOfChemistryCharges() || config.showAmuletOfBountyCharges(); } } 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 a7070bd863..854ce32f82 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 @@ -87,12 +87,20 @@ public class ItemChargePlugin extends Plugin "Your amulet of chemistry helps you create a 4-dose potion\\. (?:)?It has (\\d|one) charges? left\\." ); private static final String AMULET_OF_CHEMISTRY_BREAK_TEXT = "Your amulet of chemistry helps you create a 4-dose potion. It then crumbles to dust."; + private static final Pattern AMULET_OF_BOUNTY_CHECK_PATTERN = Pattern.compile( + "Your amulet of bounty has (\\d+) charges? left\\." + ); + private static final Pattern AMULET_OF_BOUNTY_USED_PATTERN = Pattern.compile( + "Your amulet of bounty saves some seeds for you\\. (?:)?It has (\\d) charges? left\\." + ); + private static final String AMULET_OF_BOUNTY_BREAK_TEXT = "Your amulet of bounty saves some seeds for you. It then crumbles to dust."; private static final int MAX_DODGY_CHARGES = 10; private static final int MAX_BINDING_CHARGES = 16; private static final int MAX_EXPLORER_RING_CHARGES = 30; 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 int lastExplorerRingCharge = -1; @@ -164,6 +172,11 @@ public class ItemChargePlugin extends Plugin removeInfobox(ItemWithSlot.AMULET_OF_CHEMISTY); } + if (!config.showAmuletOfBountyCharges()) + { + removeInfobox(ItemWithSlot.AMULET_OF_BOUNTY); + } + if (!config.showAbyssalBraceletCharges()) { removeInfobox(ItemWithSlot.ABYSSAL_BRACELET); @@ -202,6 +215,8 @@ public class ItemChargePlugin extends Plugin Matcher ringOfForgingCheckMatcher = RING_OF_FORGING_CHECK_PATTERN.matcher(message); Matcher amuletOfChemistryCheckMatcher = AMULET_OF_CHEMISTRY_CHECK_PATTERN.matcher(message); Matcher amuletOfChemistryUsedMatcher = AMULET_OF_CHEMISTRY_USED_PATTERN.matcher(message); + Matcher amuletOfBountyCheckMatcher = AMULET_OF_BOUNTY_CHECK_PATTERN.matcher(message); + Matcher amuletOfBountyUsedMatcher = AMULET_OF_BOUNTY_USED_PATTERN.matcher(message); if (event.getType() == ChatMessageType.GAMEMESSAGE || event.getType() == ChatMessageType.SPAM) { @@ -246,6 +261,18 @@ public class ItemChargePlugin extends Plugin { updateAmuletOfChemistyCharges(MAX_AMULET_OF_CHEMISTRY_CHARGES); } + else if (amuletOfBountyCheckMatcher.find()) + { + updateAmuletOfBountyCharges(Integer.parseInt(amuletOfBountyCheckMatcher.group(1))); + } + else if (amuletOfBountyUsedMatcher.find()) + { + updateAmuletOfBountyCharges(Integer.parseInt(amuletOfBountyUsedMatcher.group(1))); + } + else if (message.equals(AMULET_OF_BOUNTY_BREAK_TEXT)) + { + updateAmuletOfBountyCharges(MAX_AMULET_OF_BOUNTY_CHARGES); + } else if (message.contains(BINDING_BREAK_TEXT)) { if (config.bindingNotification()) @@ -357,6 +384,11 @@ public class ItemChargePlugin extends Plugin { updateJewelleryInfobox(ItemWithSlot.AMULET_OF_CHEMISTY, items); } + + if (config.showAmuletOfBountyCharges()) + { + updateJewelleryInfobox(ItemWithSlot.AMULET_OF_BOUNTY, items); + } } @Subscribe @@ -419,6 +451,23 @@ public class ItemChargePlugin extends Plugin } } + private void updateAmuletOfBountyCharges(final int value) + { + config.amuletOfBounty(value); + + if (config.showInfoboxes() && config.showAmuletOfBountyCharges()) + { + final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); + + if (itemContainer == null) + { + return; + } + + updateJewelleryInfobox(ItemWithSlot.AMULET_OF_BOUNTY, itemContainer.getItems()); + } + } + private void updateBindingNecklaceCharges(final int value) { config.bindingNecklace(value); @@ -551,6 +600,10 @@ public class ItemChargePlugin extends Plugin { charges = config.amuletOfChemistry(); } + else if (id == ItemID.AMULET_OF_BOUNTY && type == ItemWithSlot.AMULET_OF_BOUNTY) + { + charges = config.amuletOfBounty(); + } } 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 77ed3a8a37..475a6d03b9 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 @@ -28,6 +28,7 @@ enum ItemChargeType { ABYSSAL_BRACELET, AMULET_OF_CHEMISTRY, + AMULET_OF_BOUNTY, BELLOWS, FUNGICIDE_SPRAY, IMPBOX, 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 a2126032ee..9af0327a04 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 @@ -35,6 +35,7 @@ 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), DODGY_NECKLACE(ItemChargeType.DODGY_NECKLACE, EquipmentInventorySlot.AMULET), BINDING_NECKLACE(ItemChargeType.BINDING_NECKLACE, EquipmentInventorySlot.AMULET), EXPLORER_RING(ItemChargeType.EXPLORER_RING, EquipmentInventorySlot.RING),