itemcharges: Track Amulet of Bounty charges

Closes runelite/runelite#10781
This commit is contained in:
Daniel Bolink
2020-02-12 12:53:08 -08:00
committed by Jordan Atwood
parent 74976f5db2
commit f74a60840d
5 changed files with 103 additions and 9 deletions

View File

@@ -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()
{

View File

@@ -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();
}
}

View File

@@ -87,12 +87,20 @@ public class ItemChargePlugin extends Plugin
"Your amulet of chemistry helps you create a 4-dose potion\\. (?:<col=ff0000>)?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. <col=ff0000>It then crumbles to dust.</col>";
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\\. (?:<col=ff0000>)?It has (\\d) charges? left\\."
);
private static final String AMULET_OF_BOUNTY_BREAK_TEXT = "Your amulet of bounty saves some seeds for you. <col=ff0000>It then crumbles to dust.</col>";
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())
{

View File

@@ -28,6 +28,7 @@ enum ItemChargeType
{
ABYSSAL_BRACELET,
AMULET_OF_CHEMISTRY,
AMULET_OF_BOUNTY,
BELLOWS,
FUNGICIDE_SPRAY,
IMPBOX,

View File

@@ -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),