From b89d535fcbef725326e1fd864a56727941cd950c Mon Sep 17 00:00:00 2001 From: aleios Date: Wed, 22 May 2019 04:30:41 +1000 Subject: [PATCH] itemcharges: Add explorer's ring alchemy charge overlay. (#8867) --- .../main/java/net/runelite/api/Varbits.java | 10 +++- .../plugins/itemcharges/ItemChargeConfig.java | 32 ++++++++++++- .../itemcharges/ItemChargeOverlay.java | 12 ++++- .../plugins/itemcharges/ItemChargePlugin.java | 48 +++++++++++++++++++ .../plugins/itemcharges/ItemChargeType.java | 3 +- .../plugins/itemcharges/ItemWithSlot.java | 2 + 6 files changed, 103 insertions(+), 4 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/Varbits.java b/runelite-api/src/main/java/net/runelite/api/Varbits.java index f1768c2aaf..58cdc80380 100644 --- a/runelite-api/src/main/java/net/runelite/api/Varbits.java +++ b/runelite-api/src/main/java/net/runelite/api/Varbits.java @@ -487,7 +487,15 @@ public enum Varbits /** * The active tab within the quest interface */ - QUEST_TAB(8168); + QUEST_TAB(8168), + + /** + * Explorer ring + */ + EXPLORER_RING_ALCHTYPE(5398), + EXPLORER_RING_TELEPORTS(4552), + EXPLORER_RING_ALCHS(4554), + EXPLORER_RING_RUNENERGY(4553); /** * The raw varbit ID. 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 275aa31d24..84667abcf3 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 @@ -1,5 +1,6 @@ /* * Copyright (c) 2017, Devin French + * Copyright (c) 2019, Aleios * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -244,11 +245,40 @@ public interface ItemChargeConfig extends Config return true; } + @ConfigItem( + keyName = "showExplorerRingCharges", + name = "Show Explorer's Ring Alch Charges", + description = "Configures if explorer's ring alchemy charges are shown", + position = 17 + ) + default boolean showExplorerRingCharges() + { + return true; + } + + @ConfigItem( + keyName = "explorerRing", + name = "", + description = "", + hidden = true + ) + default int explorerRing() + { + return -1; + } + + @ConfigItem( + keyName = "explorerRing", + name = "", + description = "" + ) + void explorerRing(int explorerRing); + @ConfigItem( keyName = "showInfoboxes", name = "Show Infoboxes", description = "Configures whether to show an infobox equipped charge items", - position = 17 + position = 18 ) 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 5082ab2ccd..2c8220e1a6 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 @@ -1,5 +1,6 @@ /* * Copyright (c) 2017, Seth + * Copyright (c) 2019, Aleios * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,6 +85,15 @@ class ItemChargeOverlay extends WidgetItemOverlay charges = config.bindingNecklace(); } + else if (itemId >= ItemID.EXPLORERS_RING_1 && itemId <= ItemID.EXPLORERS_RING_4) + { + if (!config.showExplorerRingCharges()) + { + return; + } + + charges = config.explorerRing(); + } else { ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId); @@ -119,6 +129,6 @@ class ItemChargeOverlay extends WidgetItemOverlay { return config.showTeleportCharges() || config.showDodgyCount() || config.showFungicideCharges() || config.showImpCharges() || config.showWateringCanCharges() || config.showWaterskinCharges() - || config.showBellowCharges() || config.showAbyssalBraceletCharges(); + || config.showBellowCharges() || config.showAbyssalBraceletCharges() || config.showExplorerRingCharges(); } } 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 3a6c44a0fb..d6b4417c55 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 @@ -1,6 +1,7 @@ /* * Copyright (c) 2017, Seth * Copyright (c) 2018, Hydrox6 + * Copyright (c) 2019, Aleios * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,10 +39,12 @@ import net.runelite.api.InventoryID; import net.runelite.api.Item; import net.runelite.api.ItemContainer; import net.runelite.api.ItemID; +import net.runelite.api.Varbits; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ItemContainerChanged; import net.runelite.api.events.ScriptCallbackEvent; +import net.runelite.api.events.VarbitChanged; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.Notifier; @@ -75,6 +78,9 @@ public class ItemChargePlugin extends Plugin 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 int lastExplorerRingCharge = -1; @Inject private Client client; @@ -153,6 +159,11 @@ public class ItemChargePlugin extends Plugin { removeInfobox(ItemWithSlot.BINDING_NECKLACE); } + + if (!config.showExplorerRingCharges()) + { + removeInfobox(ItemWithSlot.EXPLORER_RING); + } } @Subscribe @@ -246,6 +257,11 @@ public class ItemChargePlugin extends Plugin { updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, items); } + + if (config.showExplorerRingCharges()) + { + updateJewelleryInfobox(ItemWithSlot.EXPLORER_RING, items); + } } @Subscribe @@ -263,6 +279,16 @@ public class ItemChargePlugin extends Plugin } } + @Subscribe + private void onVarbitChanged(VarbitChanged event) + { + int explorerRingCharge = client.getVar(Varbits.EXPLORER_RING_ALCHS); + if (lastExplorerRingCharge != explorerRingCharge) + { + updateExplorerRingCharges(explorerRingCharge); + } + } + private void updateDodgyNecklaceCharges(final int value) { config.dodgyNecklace(value); @@ -297,6 +323,24 @@ public class ItemChargePlugin extends Plugin } } + private void updateExplorerRingCharges(final int value) + { + // Note: Varbit counts upwards. We count down from the maximum charges. + config.explorerRing(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()); + } + } + private void checkDestroyWidget() { final int currentTick = client.getTickCount(); @@ -359,6 +403,10 @@ public class ItemChargePlugin extends Plugin { charges = config.bindingNecklace(); } + else if ((id >= ItemID.EXPLORERS_RING_1 && id <= ItemID.EXPLORERS_RING_4) && type == ItemWithSlot.EXPLORER_RING) + { + charges = config.explorerRing(); + } } 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 d941bf0962..827858d4d4 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 @@ -34,5 +34,6 @@ enum ItemChargeType WATERCAN, WATERSKIN, DODGY_NECKLACE, - BINDING_NECKLACE + BINDING_NECKLACE, + EXPLORER_RING } 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 4ec4aa36be..16c2b0fd1b 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 @@ -1,5 +1,6 @@ /* * Copyright (c) 2019, Tomas Slusny + * Copyright (c) 2019, Aleios * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,6 +36,7 @@ enum ItemWithSlot ABYSSAL_BRACELET(ItemChargeType.ABYSSAL_BRACELET, EquipmentInventorySlot.GLOVES), DODGY_NECKLACE(ItemChargeType.DODGY_NECKLACE, EquipmentInventorySlot.AMULET), BINDING_NECKLACE(ItemChargeType.BINDING_NECKLACE, EquipmentInventorySlot.AMULET), + EXPLORER_RING(ItemChargeType.EXPLORER_RING, EquipmentInventorySlot.RING), TELEPORT(ItemChargeType.TELEPORT, EquipmentInventorySlot.WEAPON, EquipmentInventorySlot.AMULET, EquipmentInventorySlot.GLOVES, EquipmentInventorySlot.RING); private final ItemChargeType type;