Add anti-poison timers to anti-venom potions

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2019-01-24 21:39:42 +01:00
parent eacc548a74
commit 34acc6fde2
4 changed files with 38 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ enum GameTimer
DMM_FULLTB(SpriteID.SPELL_TELE_BLOCK, GameTimerImageType.SPRITE, "Deadman Mode Full Teleblock", 150, ChronoUnit.SECONDS, true),
DMM_HALFTB(SpriteID.SPELL_TELE_BLOCK, GameTimerImageType.SPRITE, "Deadman Mode Half Teleblock", 75, ChronoUnit.SECONDS, true),
ANTIVENOMPLUS(ItemID.ANTIVENOM4_12913, GameTimerImageType.ITEM, "Anti-venom+", 3, ChronoUnit.MINUTES, true),
ANTIVENOMPLUS_ANTIPOSION(ItemID.SUPERANTIPOISON4, GameTimerImageType.ITEM, "Anti-venom+ Antipoison", 15, ChronoUnit.MINUTES, 3),
SUPERANTIFIRE(ItemID.SUPER_ANTIFIRE_POTION4, GameTimerImageType.ITEM, "Super antifire", 3, ChronoUnit.MINUTES),
ANTIDOTEPLUSPLUS(ItemID.ANTIDOTE4_5952, GameTimerImageType.ITEM, "Antidote++", 12, ChronoUnit.MINUTES),
BIND(SpriteID.SPELL_BIND, GameTimerImageType.SPRITE, "Bind", GraphicID.BIND, 5, ChronoUnit.SECONDS, true),
@@ -65,6 +66,7 @@ enum GameTimer
VENGEANCE(SpriteID.SPELL_VENGEANCE, GameTimerImageType.SPRITE, "Vengeance", 30, ChronoUnit.SECONDS),
ANTIDOTEPLUS(ItemID.ANTIDOTE4, GameTimerImageType.ITEM, "Antidote+", 518, ChronoUnit.SECONDS),
ANTIVENOM(ItemID.ANTIVENOM4, GameTimerImageType.ITEM, "Anti-venom", 1, ChronoUnit.MINUTES, true),
ANTIVENOM_ANTIPOISON(ItemID.ANTIPOISON4, GameTimerImageType.ITEM, "Anti-venom Antipoison", 12, ChronoUnit.MINUTES, 1),
EXSUPERANTIFIRE(ItemID.EXTENDED_SUPER_ANTIFIRE4, GameTimerImageType.ITEM, "Extended Super AntiFire", 6, ChronoUnit.MINUTES),
SANFEW(ItemID.SANFEW_SERUM4, GameTimerImageType.ITEM, "Sanfew serum", 6, ChronoUnit.MINUTES, true),
OVERLOAD_RAID(ItemID.OVERLOAD_4_20996, GameTimerImageType.ITEM, "Overload", 5, ChronoUnit.MINUTES, true),
@@ -86,10 +88,12 @@ enum GameTimer
private final String description;
@Getter
private final boolean removedOnDeath;
@Getter
private final Duration initialDelay;
private final int imageId;
private final GameTimerImageType imageType;
GameTimer(int imageId, GameTimerImageType idType, String description, Integer graphicId, long time, ChronoUnit unit, boolean removedOnDeath)
GameTimer(int imageId, GameTimerImageType idType, String description, Integer graphicId, long time, ChronoUnit unit, long delay, boolean removedOnDeath)
{
this.description = description;
this.graphicId = graphicId;
@@ -97,6 +101,12 @@ enum GameTimer
this.imageId = imageId;
this.imageType = idType;
this.removedOnDeath = removedOnDeath;
this.initialDelay = Duration.of(delay, unit);
}
GameTimer(int imageId, GameTimerImageType idType, String description, Integer graphicId, long time, ChronoUnit unit, boolean removedOnDeath)
{
this(imageId, idType, description, graphicId, time, unit, 0, removedOnDeath);
}
GameTimer(int imageId, GameTimerImageType idType, String description, long time, ChronoUnit unit, boolean removeOnDeath)
@@ -114,6 +124,11 @@ enum GameTimer
this(imageId, idType, description, graphicId, time, unit, false);
}
GameTimer(int imageId, GameTimerImageType idType, String description, long time, ChronoUnit unit, long delay)
{
this(imageId, idType, description, null, time, unit, delay, false);
}
BufferedImage getImage(ItemManager itemManager, SpriteManager spriteManager)
{
switch (imageType)

View File

@@ -25,6 +25,8 @@
package net.runelite.client.plugins.timers;
import java.awt.image.BufferedImage;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.ui.overlay.infobox.InfoBoxPriority;
@@ -41,9 +43,22 @@ class TimerTimer extends Timer
setPriority(InfoBoxPriority.MED);
}
@Override
public boolean render()
{
final boolean rendered = super.render();
if (rendered)
{
final Duration fromStart = Duration.between(getStartTime(), Instant.now());
return !fromStart.minus(timer.getInitialDelay()).isNegative();
}
return false;
}
public GameTimer getTimer()
{
return timer;
}
}

View File

@@ -239,6 +239,8 @@ public class TimersPlugin extends Plugin
removeGameTimer(SANFEW);
removeGameTimer(ANTIVENOM);
removeGameTimer(ANTIVENOMPLUS);
removeGameTimer(ANTIVENOM_ANTIPOISON);
removeGameTimer(ANTIVENOMPLUS_ANTIPOSION);
}
if (!config.showAntiFire())
@@ -502,6 +504,7 @@ public class TimersPlugin extends Plugin
if (config.showAntiPoison() && event.getMessage().contains(SUPER_ANTIVENOM_DRINK_MESSAGE))
{
createGameTimer(ANTIVENOMPLUS);
createGameTimer(ANTIVENOMPLUS_ANTIPOSION);
}
if (config.showMagicImbue() && event.getMessage().equals(MAGIC_IMBUE_MESSAGE))
@@ -556,6 +559,7 @@ public class TimersPlugin extends Plugin
if (config.showAntiPoison() && event.getMessage().contains(ANTIVENOM_DRINK_MESSAGE))
{
createGameTimer(ANTIVENOM);
createGameTimer(ANTIVENOM_ANTIPOISON);
}
if (config.showAntiPoison() && event.getMessage().contains(SANFEW_SERUM_DRINK_MESSAGE))

View File

@@ -30,8 +30,10 @@ import java.awt.image.BufferedImage;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import lombok.Getter;
import net.runelite.client.plugins.Plugin;
@Getter
public class Timer extends InfoBox
{
private final Instant startTime;