From 908fd898308f4235e669ac133a7534e0a4c8cce6 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 29 Jul 2019 08:37:27 -0400 Subject: [PATCH] timers: add divine potions Co-authored-by: Alexsuperfly --- .../client/plugins/timers/GameTimer.java | 8 +++- .../client/plugins/timers/TimersConfig.java | 10 ++++ .../client/plugins/timers/TimersPlugin.java | 46 +++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java index f29915740f..b146107d52 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameTimer.java @@ -78,7 +78,13 @@ enum GameTimer ABYSSAL_SIRE_STUN(ItemID.ABYSSAL_ORPHAN, GameTimerImageType.ITEM, "Abyssal Sire Stun", 30, ChronoUnit.SECONDS, true), HOME_TELEPORT(SpriteID.SPELL_LUMBRIDGE_HOME_TELEPORT, GameTimerImageType.SPRITE, "Home Teleport", 30, ChronoUnit.MINUTES), MINIGAME_TELEPORT(SpriteID.TAB_QUESTS_RED_MINIGAMES, GameTimerImageType.SPRITE, "Minigame Teleport", 20, ChronoUnit.MINUTES), - DRAGON_FIRE_SHIELD(ItemID.DRAGONFIRE_SHIELD_11284, GameTimerImageType.ITEM, "Dragonfire Shield Special", 2, ChronoUnit.MINUTES); + DRAGON_FIRE_SHIELD(ItemID.DRAGONFIRE_SHIELD_11284, GameTimerImageType.ITEM, "Dragonfire Shield Special", 2, ChronoUnit.MINUTES), + DIVINE_SUPER_ATTACK(ItemID.DIVINE_SUPER_ATTACK_POTION4, GameTimerImageType.ITEM, "Divine Super Attack", 5, ChronoUnit.MINUTES, true), + DIVINE_SUPER_STRENGTH(ItemID.DIVINE_SUPER_STRENGTH_POTION4, GameTimerImageType.ITEM, "Divine Super Strength", 5, ChronoUnit.MINUTES, true), + DIVINE_SUPER_DEFENCE(ItemID.DIVINE_SUPER_DEFENCE_POTION4, GameTimerImageType.ITEM, "Divine Super Defence", 5, ChronoUnit.MINUTES, true), + DIVINE_SUPER_COMBAT(ItemID.DIVINE_SUPER_COMBAT_POTION4, GameTimerImageType.ITEM, "Divine Super Combat", 5, ChronoUnit.MINUTES, true), + DIVINE_RANGING(ItemID.DIVINE_RANGING_POTION4, GameTimerImageType.ITEM, "Divine Ranging", 5, ChronoUnit.MINUTES, true), + DIVINE_MAGIC(ItemID.DIVINE_MAGIC_POTION4, GameTimerImageType.ITEM, "Divine Magic", 5, ChronoUnit.MINUTES, true); private final Duration duration; private final Integer graphicId; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java index eef5c4d613..14fb587019 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersConfig.java @@ -91,6 +91,16 @@ public interface TimersConfig extends Config return true; } + @ConfigItem( + keyName = "showDivine", + name = "Divine potion timer", + description = "Configures whether divine potion timer is displayed" + ) + default boolean showDivine() + { + return true; + } + @ConfigItem( keyName = "showCannon", name = "Cannon timer", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java index f3cdbb197f..dbb0838ff6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimersPlugin.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.timers; import com.google.inject.Provides; +import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; import lombok.extern.slf4j.Slf4j; @@ -108,6 +109,7 @@ public class TimersPlugin extends Plugin private static final Pattern DEADMAN_HALF_TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you by (.+)\\. It will expire in 1 minute, 15 seconds\\."); private static final Pattern FULL_TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you by (.+)\\. It will expire in 5 minutes, 0 seconds\\."); private static final Pattern HALF_TELEBLOCK_PATTERN = Pattern.compile("A Tele Block spell has been cast on you by (.+)\\. It will expire in 2 minutes, 30 seconds\\."); + private static final Pattern DIVINE_POTION_PATTERN = Pattern.compile("You drink some of your divine (.+) potion\\."); private TimerTimer freezeTimer; private int freezeTime = -1; // time frozen, in game ticks @@ -268,6 +270,16 @@ public class TimersPlugin extends Plugin removeGameTimer(PRAYER_ENHANCE); } + if (!config.showDivine()) + { + removeGameTimer(DIVINE_SUPER_ATTACK); + removeGameTimer(DIVINE_SUPER_STRENGTH); + removeGameTimer(DIVINE_SUPER_DEFENCE); + removeGameTimer(DIVINE_SUPER_COMBAT); + removeGameTimer(DIVINE_RANGING); + removeGameTimer(DIVINE_MAGIC); + } + if (!config.showCannon()) { removeGameTimer(CANNON); @@ -600,6 +612,40 @@ public class TimersPlugin extends Plugin freezeTimer = createGameTimer(ICEBARRAGE); freezeTime = client.getTickCount(); } + + if (config.showDivine()) + { + Matcher mDivine = DIVINE_POTION_PATTERN.matcher(event.getMessage()); + if (mDivine.find()) + { + switch (mDivine.group(1)) + { + case "super attack": + createGameTimer(DIVINE_SUPER_ATTACK); + break; + + case "super strength": + createGameTimer(DIVINE_SUPER_STRENGTH); + break; + + case "super defence": + createGameTimer(DIVINE_SUPER_DEFENCE); + break; + + case "combat": + createGameTimer(DIVINE_SUPER_COMBAT); + break; + + case "ranging": + createGameTimer(DIVINE_RANGING); + break; + + case "magic": + createGameTimer(DIVINE_MAGIC); + break; + } + } + } } @Subscribe