Java Code Examples for net.runelite.api.ItemID#TOXIC_STAFF_OF_THE_DEAD

The following examples show how to use net.runelite.api.ItemID#TOXIC_STAFF_OF_THE_DEAD . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TimersPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Remove SOTD timer and update stamina timer when equipment is changed.
 */
@Subscribe
void onItemContainerChanged(ItemContainerChanged itemContainerChanged)
{
	if (itemContainerChanged.getContainerId() != InventoryID.EQUIPMENT.getId())
	{
		return;
	}

	ItemContainer container = itemContainerChanged.getItemContainer();
	Item weapon = container.getItem(EquipmentInventorySlot.WEAPON.getSlotIdx());
	if (weapon == null ||
		(weapon.getId() != ItemID.STAFF_OF_THE_DEAD &&
			weapon.getId() != ItemID.TOXIC_STAFF_OF_THE_DEAD &&
			weapon.getId() != ItemID.STAFF_OF_LIGHT &&
			weapon.getId() != ItemID.TOXIC_STAFF_UNCHARGED))
	{
		// remove sotd timer if the staff has been unwielded
		removeGameTimer(STAFF_OF_THE_DEAD);
	}

	if (wasWearingEndurance)
	{
		Item ring = container.getItem(EquipmentInventorySlot.RING.getSlotIdx());

		// when using the last ring charge the ring changes to the uncharged version, ignore that and don't
		// halve the timer
		if (ring == null || (ring.getId() != ItemID.RING_OF_ENDURANCE && ring.getId() != ItemID.RING_OF_ENDURANCE_UNCHARGED_24844))
		{
			wasWearingEndurance = false;
			if (staminaTimer != null)
			{
				// Remaining duration gets divided by 2
				Duration remainingDuration = Duration.between(Instant.now(), staminaTimer.getEndTime()).dividedBy(2);
				// This relies on the chat message to be removed, which could be after the timer has been culled;
				// so check there is still remaining time
				if (!remainingDuration.isNegative() && !remainingDuration.isZero())
				{
					log.debug("Halving stamina timer");
					staminaTimer.setDuration(remainingDuration);
				}
			}
		}
	}
}
 
Example 2
Source File: TimersPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Remove SOTD timer and update stamina timer when equipment is changed.
 */
@Subscribe
public void onItemContainerChanged(ItemContainerChanged itemContainerChanged)
{
	if (itemContainerChanged.getContainerId() != InventoryID.EQUIPMENT.getId())
	{
		return;
	}

	ItemContainer container = itemContainerChanged.getItemContainer();

	Item weapon = container.getItem(EquipmentInventorySlot.WEAPON.getSlotIdx());
	if (weapon == null ||
		(weapon.getId() != ItemID.STAFF_OF_THE_DEAD &&
			weapon.getId() != ItemID.TOXIC_STAFF_OF_THE_DEAD &&
			weapon.getId() != ItemID.STAFF_OF_LIGHT &&
			weapon.getId() != ItemID.TOXIC_STAFF_UNCHARGED))
	{
		// remove sotd timer if the staff has been unwielded
		removeGameTimer(STAFF_OF_THE_DEAD);
	}

	if (wasWearingEndurance)
	{
		Item ring = container.getItem(EquipmentInventorySlot.RING.getSlotIdx());

		// when using the last ring charge the ring changes to the uncharged version, ignore that and don't
		// halve the timer
		if (ring == null || (ring.getId() != ItemID.RING_OF_ENDURANCE && ring.getId() != ItemID.RING_OF_ENDURANCE_UNCHARGED_24844))
		{
			wasWearingEndurance = false;
			if (staminaTimer != null)
			{
				// Remaining duration gets divided by 2
				Duration remainingDuration = Duration.between(Instant.now(), staminaTimer.getEndTime()).dividedBy(2);
				// This relies on the chat message to be removed, which could be after the timer has been culled;
				// so check there is still remaining time
				if (!remainingDuration.isNegative() && !remainingDuration.isZero())
				{
					log.debug("Halving stamina timer");
					staminaTimer.setDuration(remainingDuration);
				}
			}
		}
	}
}