item charges: fix resetting dodgy necklace, ring of forging, and amulet of chemistry
Co-authored-by: SirGirion <seallproducts@gmail.com>
This commit is contained in:
@@ -33,6 +33,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.EquipmentInventorySlot;
|
||||
@@ -42,15 +43,18 @@ import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.ScriptCallbackEvent;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
@@ -62,6 +66,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
description = "Show number of item charges remaining",
|
||||
tags = {"inventory", "notifications", "overlay"}
|
||||
)
|
||||
@Slf4j
|
||||
public class ItemChargePlugin extends Plugin
|
||||
{
|
||||
private static final Pattern DODGY_CHECK_PATTERN = Pattern.compile(
|
||||
@@ -77,7 +82,7 @@ public class ItemChargePlugin extends Plugin
|
||||
"You bind the temple's power into (mud|lava|steam|dust|smoke|mist) runes\\.");
|
||||
private static final String BINDING_BREAK_TEXT = "Your Binding necklace has disintegrated.";
|
||||
private static final Pattern RING_OF_FORGING_CHECK_PATTERN = Pattern.compile(
|
||||
"You can smelt ([0-9+]+|one) more pieces? of iron ore before a ring melts\\.");
|
||||
"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 = "<col=7f007f>Your Ring of Forging has melted.</col>";
|
||||
private static final Pattern AMULET_OF_CHEMISTRY_CHECK_PATTERN = Pattern.compile(
|
||||
@@ -109,6 +114,9 @@ public class ItemChargePlugin extends Plugin
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ClientThread clientThread;
|
||||
|
||||
@Inject
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@@ -418,6 +426,36 @@ public class ItemChargePlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onWidgetLoaded(WidgetLoaded widgetLoaded)
|
||||
{
|
||||
if (widgetLoaded.getGroupId() == WidgetID.DIALOG_SPRITE_GROUP_ID)
|
||||
{
|
||||
clientThread.invokeLater(() ->
|
||||
{
|
||||
Widget sprite = client.getWidget(WidgetInfo.DIALOG_SPRITE_SPRITE);
|
||||
if (sprite != null)
|
||||
{
|
||||
switch (sprite.getItemId())
|
||||
{
|
||||
case ItemID.DODGY_NECKLACE:
|
||||
log.debug("Reset dodgy necklace");
|
||||
updateDodgyNecklaceCharges(MAX_DODGY_CHARGES);
|
||||
break;
|
||||
case ItemID.RING_OF_FORGING:
|
||||
log.debug("Reset ring of forging");
|
||||
updateRingOfForgingCharges(MAX_RING_OF_FORGING_CHARGES);
|
||||
break;
|
||||
case ItemID.AMULET_OF_CHEMISTRY:
|
||||
log.debug("Reset amulet of chemistry");
|
||||
updateAmuletOfChemistryCharges(MAX_AMULET_OF_CHEMISTRY_CHARGES);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDodgyNecklaceCharges(final int value)
|
||||
{
|
||||
config.dodgyNecklace(value);
|
||||
@@ -536,20 +574,10 @@ public class ItemChargePlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
switch (widgetDestroyItemName.getText())
|
||||
if (widgetDestroyItemName.getText().equals("Binding necklace"))
|
||||
{
|
||||
case "Binding necklace":
|
||||
updateBindingNecklaceCharges(MAX_BINDING_CHARGES);
|
||||
break;
|
||||
case "Dodgy necklace":
|
||||
updateDodgyNecklaceCharges(MAX_DODGY_CHARGES);
|
||||
break;
|
||||
case "Ring of forging":
|
||||
updateRingOfForgingCharges(MAX_RING_OF_FORGING_CHARGES);
|
||||
break;
|
||||
case "Amulet of chemistry":
|
||||
updateAmuletOfChemistryCharges(MAX_AMULET_OF_CHEMISTRY_CHARGES);
|
||||
break;
|
||||
log.debug("Reset binding necklace");
|
||||
updateBindingNecklaceCharges(MAX_BINDING_CHARGES);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user