Add destroy support to Item Charge plugin

This commit is contained in:
TheStonedTurtle
2019-03-16 21:12:54 -07:00
committed by TheStonedTurtle
parent 0489d7de9d
commit f3387bc9f9
3 changed files with 142 additions and 0 deletions

View File

@@ -41,6 +41,9 @@ import net.runelite.api.ItemID;
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.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.Notifier;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
@@ -94,6 +97,9 @@ public class ItemChargePlugin extends Plugin
@Inject
private ItemChargeConfig config;
// Limits destroy callback to once per tick
private int lastCheckTick;
@Provides
ItemChargeConfig getConfig(ConfigManager configManager)
{
@@ -111,6 +117,7 @@ public class ItemChargePlugin extends Plugin
{
overlayManager.remove(overlay);
infoBoxManager.removeIf(ItemChargeInfobox.class::isInstance);
lastCheckTick = -1;
}
@Subscribe
@@ -241,6 +248,21 @@ public class ItemChargePlugin extends Plugin
}
}
@Subscribe
private void onScriptCallbackEvent(ScriptCallbackEvent event)
{
if (!"destroyOnOpKey".equals(event.getEventName()))
{
return;
}
final int yesOption = client.getIntStack()[client.getIntStackSize() - 1];
if (yesOption == 1)
{
checkDestroyWidget();
}
}
private void updateDodgyNecklaceCharges(final int value)
{
config.dodgyNecklace(value);
@@ -275,6 +297,32 @@ public class ItemChargePlugin extends Plugin
}
}
private void checkDestroyWidget()
{
final int currentTick = client.getTickCount();
if (lastCheckTick == currentTick)
{
return;
}
lastCheckTick = currentTick;
final Widget widgetDestroyItemName = client.getWidget(WidgetInfo.DESTROY_ITEM_NAME);
if (widgetDestroyItemName == null)
{
return;
}
switch (widgetDestroyItemName.getText())
{
case "Binding necklace":
updateBindingNecklaceCharges(MAX_BINDING_CHARGES);
break;
case "Dodgy necklace":
updateDodgyNecklaceCharges(MAX_DODGY_CHARGES);
break;
}
}
private void updateJewelleryInfobox(ItemWithSlot item, Item[] items)
{
for (final EquipmentInventorySlot equipmentInventorySlot : item.getSlots())

View File

@@ -0,0 +1 @@
DA7BFF3D4B1135F264904DDCED76BC0CD56CEF4B41E1D7852097E9EECC235B9A

View File

@@ -0,0 +1,93 @@
.id 1651
.int_stack_count 5
.string_stack_count 2
.int_var_count 5
.string_var_count 2
iload 0
iconst 1
if_icmpeq LABEL13
iload 1
iconst -1
if_icmpne LABEL7
jump LABEL74
LABEL7:
sload 1
iload 1
string_indexof_char
iconst -1
if_icmpne LABEL13
jump LABEL74
LABEL13:
iload 0
iconst 1
if_icmpne LABEL17
jump LABEL24
LABEL17:
iconst 584
iconst -1
invoke 1701
iconst 0
if_icmpeq LABEL23
jump LABEL24
LABEL23:
return
LABEL24:
iload 3
sconst "destroyOnOpKey" ; load event name
runelite_callback ; invoke callback
pop_int
iconst 2266
iconst 1
iconst 0
sound_synth
iload 2
iload 4
cc_find
iconst 1
if_icmpeq LABEL34
jump LABEL38
LABEL34:
iconst 16777215
cc_setcolour
sconst "..."
cc_settext
LABEL38:
iconst -1
sconst ""
iload 2
if_setonmouserepeat
iconst -1
sconst ""
iload 2
if_setonmouseleave
iload 2
if_clearops
iconst -1
sconst ""
iload 2
if_setonop
iconst -1
sconst ""
iload 2
if_setonkey
iconst 1652
iload 2
sload 0
iload 3
sload 1
clientclock
iconst 40
add
sconst "Isisi"
iload 2
if_setontimer
iconst 38273024
iload 3
cc_find
iconst 1
if_icmpeq LABEL73
jump LABEL74
LABEL73:
cc_resume_pausebutton
LABEL74:
return