timers plugin: fix sotd timer removal logic
This commit is contained in:
@@ -31,6 +31,10 @@ import net.runelite.api.Actor;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.EquipmentInventorySlot;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Prayer;
|
||||
import net.runelite.api.Varbits;
|
||||
@@ -38,6 +42,7 @@ import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.GraphicChanged;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
@@ -85,7 +90,6 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
)
|
||||
public class TimersPlugin extends Plugin
|
||||
{
|
||||
private int lastEquippedWeapVarb;
|
||||
private int lastRaidVarb;
|
||||
|
||||
@Inject
|
||||
@@ -112,12 +116,6 @@ public class TimersPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onVarbitChange(VarbitChanged event)
|
||||
{
|
||||
int equippedWeap = client.getVar(Varbits.EQUIPPED_WEAPON_TYPE);
|
||||
if (lastEquippedWeapVarb != equippedWeap)
|
||||
{
|
||||
removeGameTimer(STAFF_OF_THE_DEAD);
|
||||
}
|
||||
|
||||
int raidVarb = client.getVar(Varbits.IN_RAID);
|
||||
if (lastRaidVarb != raidVarb)
|
||||
{
|
||||
@@ -529,6 +527,47 @@ public class TimersPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove SOTD timer when weapon is changed
|
||||
*
|
||||
* @param itemContainerChanged
|
||||
*/
|
||||
@Subscribe
|
||||
public void onItemContainerChanged(ItemContainerChanged itemContainerChanged)
|
||||
{
|
||||
ItemContainer container = itemContainerChanged.getItemContainer();
|
||||
if (container == client.getItemContainer(InventoryID.EQUIPMENT))
|
||||
{
|
||||
Item[] items = container.getItems();
|
||||
int weaponIdx = EquipmentInventorySlot.WEAPON.getSlotIdx();
|
||||
|
||||
if (items == null || weaponIdx >= items.length)
|
||||
{
|
||||
removeGameTimer(STAFF_OF_THE_DEAD);
|
||||
return;
|
||||
}
|
||||
|
||||
Item weapon = items[weaponIdx];
|
||||
if (weapon == null)
|
||||
{
|
||||
removeGameTimer(STAFF_OF_THE_DEAD);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (weapon.getId())
|
||||
{
|
||||
case ItemID.STAFF_OF_THE_DEAD:
|
||||
case ItemID.TOXIC_STAFF_OF_THE_DEAD:
|
||||
case ItemID.STAFF_OF_LIGHT:
|
||||
case ItemID.TOXIC_STAFF_UNCHARGED:
|
||||
// don't reset timer if still weilding staff
|
||||
return;
|
||||
default:
|
||||
removeGameTimer(STAFF_OF_THE_DEAD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void createGameTimer(GameTimer timer)
|
||||
{
|
||||
removeGameTimer(timer);
|
||||
|
||||
Reference in New Issue
Block a user