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 2b29cbac07..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 @@ -216,11 +216,69 @@ public interface ItemChargeConfig extends Config return true; } + @ConfigItem( + keyName = "showAmuletOfChemistryCharges", + name = "Show Amulet of Chemistry Charges", + description = "Configures if amulet of chemistry item charge is shown", + position = 16 + ) + default boolean showAmuletOfChemistryCharges() + { + return true; + } + + @ConfigItem( + keyName = "amuletOfChemistry", + name = "", + description = "", + hidden = true + ) + default int amuletOfChemistry() + { + return -1; + } + + @ConfigItem( + keyName = "amuletOfChemistry", + name = "", + description = "" + ) + 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 = 16 + position = 18 ) default boolean recoilNotification() { @@ -231,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 = 17 + position = 19 ) default boolean showBindingNecklaceCharges() { @@ -260,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 = 18 + position = 20 ) default boolean bindingNotification() { @@ -271,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 = 19 + position = 21 ) default boolean showExplorerRingCharges() { @@ -300,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 = 20 + position = 22 ) default boolean showRingOfForgingCount() { @@ -329,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 = 21 + position = 23 ) default boolean ringOfForgingNotification() { @@ -340,7 +398,7 @@ public interface ItemChargeConfig extends Config keyName = "showInfoboxes", name = "Show Infoboxes", description = "Configures whether to show an infobox equipped charge items", - position = 22 + 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 4155410692..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 @@ -31,15 +31,7 @@ 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.ABYSSAL_BRACELET; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.BELLOWS; -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.TELEPORT; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.FRUIT_BASKET; -import static net.runelite.client.plugins.itemcharges.ItemChargeType.SACK; +import static net.runelite.client.plugins.itemcharges.ItemChargeType.*; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.WidgetItemOverlay; import net.runelite.client.ui.overlay.components.TextComponent; @@ -105,6 +97,24 @@ class ItemChargeOverlay extends WidgetItemOverlay charges = config.ringOfForging(); } + else if (itemId == ItemID.AMULET_OF_CHEMISTRY) + { + if (!config.showAmuletOfChemistryCharges()) + { + return; + } + + charges = config.amuletOfChemistry(); + } + else if (itemId == ItemID.AMULET_OF_BOUNTY) + { + if (!config.showAmuletOfBountyCharges()) + { + return; + } + + charges = config.amuletOfBounty(); + } else { ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId); @@ -122,7 +132,9 @@ class ItemChargeOverlay extends WidgetItemOverlay || (type == BELLOWS && !config.showBellowCharges()) || (type == FRUIT_BASKET && !config.showBasketCharges()) || (type == SACK && !config.showSackCharges()) - || (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges())) + || (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges()) + || (type == AMULET_OF_CHEMISTRY && !config.showAmuletOfChemistryCharges()) + || (type == AMULET_OF_BOUNTY && !config.showAmuletOfBountyCharges())) { return; } @@ -143,6 +155,8 @@ class ItemChargeOverlay extends WidgetItemOverlay 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.showAbyssalBraceletCharges() || config.showExplorerRingCharges() || config.showRingOfForgingCount() + || 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 95bff3d854..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 @@ -80,11 +80,27 @@ public class ItemChargePlugin extends Plugin "You can smelt ([0-9+]+|one) more pieces? of iron ore before a ring melts\\."); private static final String RING_OF_FORGING_USED_TEXT = "You retrieve a bar of iron."; private static final String RING_OF_FORGING_BREAK_TEXT = "Your Ring of Forging has melted."; + private static final Pattern AMULET_OF_CHEMISTRY_CHECK_PATTERN = Pattern.compile( + "Your amulet of chemistry has (\\d) charges? left\\." + ); + private static final Pattern AMULET_OF_CHEMISTRY_USED_PATTERN = Pattern.compile( + "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; @@ -151,6 +167,16 @@ public class ItemChargePlugin extends Plugin 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); @@ -187,6 +213,10 @@ public class ItemChargePlugin extends Plugin Matcher bindingNecklaceCheckMatcher = BINDING_CHECK_PATTERN.matcher(event.getMessage()); Matcher bindingNecklaceUsedMatcher = BINDING_USED_PATTERN.matcher(event.getMessage()); 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) { @@ -211,6 +241,38 @@ public class ItemChargePlugin extends Plugin { updateDodgyNecklaceCharges(Integer.parseInt(dodgyProtectMatcher.group(1))); } + else if (amuletOfChemistryCheckMatcher.find()) + { + updateAmuletOfChemistyCharges(Integer.parseInt(amuletOfChemistryCheckMatcher.group(1))); + } + else if (amuletOfChemistryUsedMatcher.find()) + { + final String match = amuletOfChemistryUsedMatcher.group(1); + + int charges = 1; + if (!match.equals("one")) + { + charges = Integer.parseInt(match); + } + + updateAmuletOfChemistyCharges(charges); + } + else if (message.equals(AMULET_OF_CHEMISTRY_BREAK_TEXT)) + { + 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()) @@ -317,6 +379,16 @@ public class ItemChargePlugin extends Plugin { updateJewelleryInfobox(ItemWithSlot.RING_OF_FORGING, items); } + + if (config.showAmuletOfChemistryCharges()) + { + updateJewelleryInfobox(ItemWithSlot.AMULET_OF_CHEMISTY, items); + } + + if (config.showAmuletOfBountyCharges()) + { + updateJewelleryInfobox(ItemWithSlot.AMULET_OF_BOUNTY, items); + } } @Subscribe @@ -362,6 +434,40 @@ public class ItemChargePlugin extends Plugin } } + private void updateAmuletOfChemistyCharges(final int value) + { + config.amuletOfChemistry(value); + + if (config.showInfoboxes() && config.showAmuletOfChemistryCharges()) + { + final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); + + if (itemContainer == null) + { + return; + } + + updateJewelleryInfobox(ItemWithSlot.AMULET_OF_CHEMISTY, itemContainer.getItems()); + } + } + + 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); @@ -440,6 +546,9 @@ public class ItemChargePlugin extends Plugin case "Ring of forging": updateRingOfForgingCharges(MAX_RING_OF_FORGING_CHARGES); break; + case "Amulet of chemistry": + updateAmuletOfChemistyCharges(MAX_AMULET_OF_CHEMISTRY_CHARGES); + break; } } @@ -487,6 +596,14 @@ public class ItemChargePlugin extends Plugin { charges = config.ringOfForging(); } + else if (id == ItemID.AMULET_OF_CHEMISTRY && type == ItemWithSlot.AMULET_OF_CHEMISTY) + { + 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 030b5ab22c..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 @@ -27,6 +27,8 @@ package net.runelite.client.plugins.itemcharges; 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 cfc2338a33..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 @@ -34,6 +34,8 @@ import net.runelite.api.EquipmentInventorySlot; 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),