timers plguin: Add teleport cooldown timers

This adds timers for home teleport and minigame teleport cooldowns.

Fixes runelite/runelite#814
Closes runelite/runelite#2153
This commit is contained in:
Jordan Atwood
2018-09-04 10:55:07 -07:00
parent af6a08bd01
commit cacb9e08aa
4 changed files with 131 additions and 25 deletions

View File

@@ -75,7 +75,9 @@ enum GameTimer
SUPERANTIPOISON(ItemID.SUPERANTIPOISON4, GameTimerImageType.ITEM, "Superantipoison", 346, ChronoUnit.SECONDS), SUPERANTIPOISON(ItemID.SUPERANTIPOISON4, GameTimerImageType.ITEM, "Superantipoison", 346, ChronoUnit.SECONDS),
CHARGE(SpriteID.SPELL_CHARGE, GameTimerImageType.SPRITE, "Charge", 6, ChronoUnit.MINUTES), CHARGE(SpriteID.SPELL_CHARGE, GameTimerImageType.SPRITE, "Charge", 6, ChronoUnit.MINUTES),
STAFF_OF_THE_DEAD(ItemID.STAFF_OF_THE_DEAD, GameTimerImageType.ITEM, "Staff of the Dead", 1, ChronoUnit.MINUTES), STAFF_OF_THE_DEAD(ItemID.STAFF_OF_THE_DEAD, GameTimerImageType.ITEM, "Staff of the Dead", 1, ChronoUnit.MINUTES),
ABYSSAL_SIRE_STUN(ItemID.ABYSSAL_ORPHAN, GameTimerImageType.ITEM, "Abyssal Sire Stun", 30, ChronoUnit.SECONDS); ABYSSAL_SIRE_STUN(ItemID.ABYSSAL_ORPHAN, GameTimerImageType.ITEM, "Abyssal Sire Stun", 30, ChronoUnit.SECONDS),
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);
@Getter @Getter
private final Duration duration; private final Duration duration;

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.timers;
import com.google.common.collect.ImmutableList;
import java.util.Collection;
import javax.annotation.Nullable;
import net.runelite.api.widgets.WidgetInfo;
enum TeleportWidget
{
HOME_TELEPORT,
MINIGAME_TELEPORT;
private static final Collection HOME_TELEPORT_IDS = ImmutableList.of(
WidgetInfo.SPELL_LUMBRIDGE_HOME_TELEPORT.getId(),
WidgetInfo.SPELL_EDGEVILLE_HOME_TELEPORT.getId(),
WidgetInfo.SPELL_LUNAR_HOME_TELEPORT.getId(),
WidgetInfo.SPELL_ARCEUUS_HOME_TELEPORT.getId()
);
private static final Collection MINIGAME_TELEPORT_IDS = ImmutableList.of(
WidgetInfo.MINIGAME_TELEPORT_BUTTON.getId()
);
@Nullable
static TeleportWidget of(int widgetId)
{
if (HOME_TELEPORT_IDS.contains(widgetId))
{
return HOME_TELEPORT;
}
else if (MINIGAME_TELEPORT_IDS.contains(widgetId))
{
return MINIGAME_TELEPORT;
}
return null;
}
}

View File

@@ -33,6 +33,17 @@ public interface TimersConfig extends Config
{ {
@ConfigItem( @ConfigItem(
position = 0, position = 0,
keyName = "showHomeMinigameTeleports",
name = "Teleport cooldown timers",
description = "Configures whether timers for home and minigame teleport cooldowns are displayed"
)
default boolean showHomeMinigameTeleports()
{
return true;
}
@ConfigItem(
position = 1,
keyName = "showAntipoison", keyName = "showAntipoison",
name = "Antipoison timer", name = "Antipoison timer",
description = "Configures whether Antipoison timer is displayed" description = "Configures whether Antipoison timer is displayed"
@@ -43,7 +54,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 1, position = 2,
keyName = "showSuperantipoison", keyName = "showSuperantipoison",
name = "Superantipoison timer", name = "Superantipoison timer",
description = "Configures whether Superantipoison timer is displayed" description = "Configures whether Superantipoison timer is displayed"
@@ -54,7 +65,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 2, position = 3,
keyName = "showAntidotePlus", keyName = "showAntidotePlus",
name = "Antidote+ timer", name = "Antidote+ timer",
description = "Configures whether antidote+ timer is displayed" description = "Configures whether antidote+ timer is displayed"
@@ -65,7 +76,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 3, position = 4,
keyName = "showAntidotePlusPlus", keyName = "showAntidotePlusPlus",
name = "Antidote++ timer", name = "Antidote++ timer",
description = "Configures whether antidote++ timer is displayed" description = "Configures whether antidote++ timer is displayed"
@@ -76,7 +87,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 4, position = 5,
keyName = "showSanfew", keyName = "showSanfew",
name = "Sanfew serum timer", name = "Sanfew serum timer",
description = "Configures whether sanfew serum timer is displayed" description = "Configures whether sanfew serum timer is displayed"
@@ -87,7 +98,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 5, position = 6,
keyName = "showAntiVenom", keyName = "showAntiVenom",
name = "Anti-venom timer", name = "Anti-venom timer",
description = "Configures whether antivenom timer is displayed" description = "Configures whether antivenom timer is displayed"
@@ -98,7 +109,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 6, position = 7,
keyName = "showAntiVenomPlus", keyName = "showAntiVenomPlus",
name = "Anti-venom+ timer", name = "Anti-venom+ timer",
description = "Configures whether anti venom+ timer is displayed" description = "Configures whether anti venom+ timer is displayed"
@@ -109,7 +120,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 7, position = 8,
keyName = "showAntiFire", keyName = "showAntiFire",
name = "Antifire timer", name = "Antifire timer",
description = "Configures whether antifire timer is displayed" description = "Configures whether antifire timer is displayed"
@@ -120,7 +131,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 8, position = 9,
keyName = "showExAntiFire", keyName = "showExAntiFire",
name = "Extended antifire timer", name = "Extended antifire timer",
description = "Configures whether extended antifire timer is displayed" description = "Configures whether extended antifire timer is displayed"
@@ -131,7 +142,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 9, position = 10,
keyName = "showSuperAntiFire", keyName = "showSuperAntiFire",
name = "Super antifire timer", name = "Super antifire timer",
description = "Configures whether super antifire timer is displayed" description = "Configures whether super antifire timer is displayed"
@@ -142,7 +153,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 10, position = 11,
keyName = "showExSuperAntifire", keyName = "showExSuperAntifire",
name = "Extended super antifire timer", name = "Extended super antifire timer",
description = "Configures whether extended super antifire timer is displayed" description = "Configures whether extended super antifire timer is displayed"
@@ -153,7 +164,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 11, position = 12,
keyName = "showStamina", keyName = "showStamina",
name = "Stamina timer", name = "Stamina timer",
description = "Configures whether stamina timer is displayed" description = "Configures whether stamina timer is displayed"
@@ -164,7 +175,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 12, position = 13,
keyName = "showOverload", keyName = "showOverload",
name = "Overload timer", name = "Overload timer",
description = "Configures whether overload timer is displayed" description = "Configures whether overload timer is displayed"
@@ -175,7 +186,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 13, position = 14,
keyName = "showPrayerEnhance", keyName = "showPrayerEnhance",
name = "Prayer enhance timer", name = "Prayer enhance timer",
description = "Configures whether prayer enhance timer is displayed" description = "Configures whether prayer enhance timer is displayed"
@@ -186,7 +197,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 14, position = 15,
keyName = "showCannon", keyName = "showCannon",
name = "Cannon timer", name = "Cannon timer",
description = "Configures whether cannon timer is displayed" description = "Configures whether cannon timer is displayed"
@@ -197,7 +208,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 15, position = 16,
keyName = "showMagicImbue", keyName = "showMagicImbue",
name = "Magic imbue timer", name = "Magic imbue timer",
description = "Configures whether magic imbue timer is displayed" description = "Configures whether magic imbue timer is displayed"
@@ -208,7 +219,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 16, position = 17,
keyName = "showCharge", keyName = "showCharge",
name = "Charge timer", name = "Charge timer",
description = "Configures whether to show a timer for the Charge spell" description = "Configures whether to show a timer for the Charge spell"
@@ -219,7 +230,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 17, position = 18,
keyName = "showImbuedHeart", keyName = "showImbuedHeart",
name = "Imbued heart timer", name = "Imbued heart timer",
description = "Configures whether imbued heart timer is displayed" description = "Configures whether imbued heart timer is displayed"
@@ -230,7 +241,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 18, position = 19,
keyName = "showVengeance", keyName = "showVengeance",
name = "Vengeance timer", name = "Vengeance timer",
description = "Configures whether vengeance timer is displayed" description = "Configures whether vengeance timer is displayed"
@@ -241,7 +252,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 19, position = 20,
keyName = "showVengeanceOther", keyName = "showVengeanceOther",
name = "Vengeance Other timer", name = "Vengeance Other timer",
description = "Configures whether vengeance other timer is displayed" description = "Configures whether vengeance other timer is displayed"
@@ -252,7 +263,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 20, position = 21,
keyName = "showTeleblock", keyName = "showTeleblock",
name = "Teleblock timer", name = "Teleblock timer",
description = "Configures whether teleblock timer is displayed" description = "Configures whether teleblock timer is displayed"
@@ -263,7 +274,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 21, position = 22,
keyName = "showFreezes", keyName = "showFreezes",
name = "Freeze timer", name = "Freeze timer",
description = "Configures whether freeze timer is displayed" description = "Configures whether freeze timer is displayed"
@@ -274,7 +285,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 22, position = 23,
keyName = "showGodWarsAltar", keyName = "showGodWarsAltar",
name = "God wars altar timer", name = "God wars altar timer",
description = "Configures whether god wars altar timer is displayed" description = "Configures whether god wars altar timer is displayed"
@@ -285,7 +296,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 23, position = 24,
keyName = "showStaffOfTheDead", keyName = "showStaffOfTheDead",
name = "Staff of the Dead timer", name = "Staff of the Dead timer",
description = "Configures whether staff of the dead timer is displayed" description = "Configures whether staff of the dead timer is displayed"
@@ -296,7 +307,7 @@ public interface TimersConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 24, position = 25,
keyName = "showAbyssalSireStun", keyName = "showAbyssalSireStun",
name = "Abyssal Sire Stun Timer", name = "Abyssal Sire Stun Timer",
description = "Configures whether Abyssal Sire stun timer is displayed" description = "Configures whether Abyssal Sire stun timer is displayed"

View File

@@ -102,6 +102,8 @@ public class TimersPlugin extends Plugin
private int lastRaidVarb; private int lastRaidVarb;
private WorldPoint lastPoint; private WorldPoint lastPoint;
private TeleportWidget lastTeleportClicked;
private int lastAnimation;
@Inject @Inject
private ItemManager itemManager; private ItemManager itemManager;
@@ -130,6 +132,8 @@ public class TimersPlugin extends Plugin
infoBoxManager.removeIf(t -> t instanceof TimerTimer); infoBoxManager.removeIf(t -> t instanceof TimerTimer);
lastRaidVarb = -1; lastRaidVarb = -1;
lastPoint = null; lastPoint = null;
lastTeleportClicked = null;
lastAnimation = -1;
} }
@Subscribe @Subscribe
@@ -147,6 +151,12 @@ public class TimersPlugin extends Plugin
@Subscribe @Subscribe
public void updateConfig(ConfigChanged event) public void updateConfig(ConfigChanged event)
{ {
if (!config.showHomeMinigameTeleports())
{
removeGameTimer(HOME_TELEPORT);
removeGameTimer(MINIGAME_TELEPORT);
}
if (!config.showAntidotePlus()) if (!config.showAntidotePlus())
{ {
removeGameTimer(ANTIDOTEPLUS); removeGameTimer(ANTIDOTEPLUS);
@@ -319,6 +329,12 @@ public class TimersPlugin extends Plugin
createGameTimer(STAMINA); createGameTimer(STAMINA);
return; return;
} }
TeleportWidget teleportWidget = TeleportWidget.of(event.getWidgetId());
if (teleportWidget != null)
{
lastTeleportClicked = teleportWidget;
}
} }
@Subscribe @Subscribe
@@ -560,6 +576,23 @@ public class TimersPlugin extends Plugin
{ {
createGameTimer(VENGEANCEOTHER); createGameTimer(VENGEANCEOTHER);
} }
if (config.showHomeMinigameTeleports()
&& client.getLocalPlayer().getAnimation() == AnimationID.IDLE
&& (lastAnimation == AnimationID.BOOK_HOME_TELEPORT_5
|| lastAnimation == AnimationID.COW_HOME_TELEPORT_6))
{
if (lastTeleportClicked == TeleportWidget.HOME_TELEPORT)
{
createGameTimer(HOME_TELEPORT);
}
else if (lastTeleportClicked == TeleportWidget.MINIGAME_TELEPORT)
{
createGameTimer(MINIGAME_TELEPORT);
}
}
lastAnimation = client.getLocalPlayer().getAnimation();
} }