timers: Track home and minigame teleports using vars (#14842)
This commit is contained in:
@@ -221,6 +221,16 @@ public enum VarPlayer
|
|||||||
SETTINGS_TRANSPARENT_CHAT_TRADE_REQUEST(3006),
|
SETTINGS_TRANSPARENT_CHAT_TRADE_REQUEST(3006),
|
||||||
SETTINGS_TRANSPARENT_CHAT_CHALLENGE_REQUEST(3007),
|
SETTINGS_TRANSPARENT_CHAT_CHALLENGE_REQUEST(3007),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The difference, measured in minutes, between the time home teleport spell was last used and midnight, January 1, 1970 UTC.
|
||||||
|
*/
|
||||||
|
LAST_HOME_TELEPORT(892),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The difference, measured in minutes, between the time minigame teleport was last used and midnight, January 1, 1970 UTC.
|
||||||
|
*/
|
||||||
|
LAST_MINIGAME_TELEPORT(888),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final int id;
|
private final int id;
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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,
|
|
||||||
TRAILBLAZER_AREA_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(),
|
|
||||||
WidgetInfo.SPELL_KOUREND_HOME_TELEPORT.getId(),
|
|
||||||
WidgetInfo.SPELL_CATHERBY_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;
|
|
||||||
}
|
|
||||||
else if (widgetId == WidgetInfo.TRAILBLAZER_AREA_TELEPORT.getId())
|
|
||||||
{
|
|
||||||
return TRAILBLAZER_AREA_TELEPORT;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,6 +29,7 @@ package net.runelite.client.plugins.timers;
|
|||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -45,7 +46,6 @@ import net.runelite.api.ItemContainer;
|
|||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import static net.runelite.api.ItemID.FIRE_CAPE;
|
import static net.runelite.api.ItemID.FIRE_CAPE;
|
||||||
import static net.runelite.api.ItemID.INFERNAL_CAPE;
|
import static net.runelite.api.ItemID.INFERNAL_CAPE;
|
||||||
import net.runelite.api.MenuAction;
|
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
import net.runelite.api.NpcID;
|
import net.runelite.api.NpcID;
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
@@ -152,11 +152,12 @@ public class TimersPlugin extends Plugin
|
|||||||
private int lastPoisonVarp;
|
private int lastPoisonVarp;
|
||||||
private int lastPvpVarb;
|
private int lastPvpVarb;
|
||||||
private int lastCorruptionVarb;
|
private int lastCorruptionVarb;
|
||||||
|
private int lastHomeTeleport;
|
||||||
|
private int lastMinigameTeleport;
|
||||||
private int lastImbuedHeartVarb;
|
private int lastImbuedHeartVarb;
|
||||||
private boolean imbuedHeartTimerActive;
|
private boolean imbuedHeartTimerActive;
|
||||||
private int nextPoisonTick;
|
private int nextPoisonTick;
|
||||||
private WorldPoint lastPoint;
|
private WorldPoint lastPoint;
|
||||||
private TeleportWidget lastTeleportClicked;
|
|
||||||
private int lastAnimation;
|
private int lastAnimation;
|
||||||
private boolean widgetHiddenChangedOnPvpWorld;
|
private boolean widgetHiddenChangedOnPvpWorld;
|
||||||
private ElapsedTimer tzhaarTimer;
|
private ElapsedTimer tzhaarTimer;
|
||||||
@@ -185,6 +186,11 @@ public class TimersPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
public void startUp()
|
public void startUp()
|
||||||
{
|
{
|
||||||
|
if (config.showHomeMinigameTeleports())
|
||||||
|
{
|
||||||
|
checkTeleport(VarPlayer.LAST_HOME_TELEPORT);
|
||||||
|
checkTeleport(VarPlayer.LAST_MINIGAME_TELEPORT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -193,7 +199,6 @@ 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;
|
lastAnimation = -1;
|
||||||
widgetHiddenChangedOnPvpWorld = false;
|
widgetHiddenChangedOnPvpWorld = false;
|
||||||
lastPoisonVarp = 0;
|
lastPoisonVarp = 0;
|
||||||
@@ -202,6 +207,8 @@ public class TimersPlugin extends Plugin
|
|||||||
staminaTimer = null;
|
staminaTimer = null;
|
||||||
imbuedHeartTimerActive = false;
|
imbuedHeartTimerActive = false;
|
||||||
lastImbuedHeartVarb = 0;
|
lastImbuedHeartVarb = 0;
|
||||||
|
lastHomeTeleport = 0;
|
||||||
|
lastMinigameTeleport = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -214,6 +221,8 @@ public class TimersPlugin extends Plugin
|
|||||||
int pvpVarb = client.getVarbitValue(Varbits.PVP_SPEC_ORB);
|
int pvpVarb = client.getVarbitValue(Varbits.PVP_SPEC_ORB);
|
||||||
int corruptionCooldownVarb = client.getVarbitValue(Varbits.CORRUPTION_COOLDOWN);
|
int corruptionCooldownVarb = client.getVarbitValue(Varbits.CORRUPTION_COOLDOWN);
|
||||||
int imbuedHeartCooldownVarb = client.getVarbitValue(Varbits.IMBUED_HEART_COOLDOWN);
|
int imbuedHeartCooldownVarb = client.getVarbitValue(Varbits.IMBUED_HEART_COOLDOWN);
|
||||||
|
int homeTeleportVarp = client.getVar(VarPlayer.LAST_HOME_TELEPORT);
|
||||||
|
int minigameTeleportVarp = client.getVar(VarPlayer.LAST_MINIGAME_TELEPORT);
|
||||||
|
|
||||||
if (lastRaidVarb != raidVarb)
|
if (lastRaidVarb != raidVarb)
|
||||||
{
|
{
|
||||||
@@ -320,6 +329,18 @@ public class TimersPlugin extends Plugin
|
|||||||
|
|
||||||
lastImbuedHeartVarb = imbuedHeartCooldownVarb;
|
lastImbuedHeartVarb = imbuedHeartCooldownVarb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastHomeTeleport != homeTeleportVarp)
|
||||||
|
{
|
||||||
|
checkTeleport(VarPlayer.LAST_HOME_TELEPORT);
|
||||||
|
lastHomeTeleport = homeTeleportVarp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastMinigameTeleport != minigameTeleportVarp)
|
||||||
|
{
|
||||||
|
checkTeleport(VarPlayer.LAST_MINIGAME_TELEPORT);
|
||||||
|
lastMinigameTeleport = minigameTeleportVarp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -335,6 +356,11 @@ public class TimersPlugin extends Plugin
|
|||||||
removeGameTimer(HOME_TELEPORT);
|
removeGameTimer(HOME_TELEPORT);
|
||||||
removeGameTimer(MINIGAME_TELEPORT);
|
removeGameTimer(MINIGAME_TELEPORT);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
checkTeleport(VarPlayer.LAST_HOME_TELEPORT);
|
||||||
|
checkTeleport(VarPlayer.LAST_MINIGAME_TELEPORT);
|
||||||
|
}
|
||||||
|
|
||||||
if (!config.showAntiFire())
|
if (!config.showAntiFire())
|
||||||
{
|
{
|
||||||
@@ -491,15 +517,6 @@ public class TimersPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getMenuAction() == MenuAction.CC_OP)
|
|
||||||
{
|
|
||||||
TeleportWidget teleportWidget = TeleportWidget.of(event.getParam1());
|
|
||||||
if (teleportWidget != null)
|
|
||||||
{
|
|
||||||
lastTeleportClicked = teleportWidget;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -877,6 +894,37 @@ public class TimersPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkTeleport(VarPlayer varPlayer)
|
||||||
|
{
|
||||||
|
final GameTimer teleport;
|
||||||
|
switch (varPlayer)
|
||||||
|
{
|
||||||
|
case LAST_HOME_TELEPORT:
|
||||||
|
teleport = HOME_TELEPORT;
|
||||||
|
break;
|
||||||
|
case LAST_MINIGAME_TELEPORT:
|
||||||
|
teleport = MINIGAME_TELEPORT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Other var changes are not handled as teleports
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lastTeleport = client.getVar(varPlayer);
|
||||||
|
long lastTeleportSeconds = (long) lastTeleport * 60;
|
||||||
|
Instant teleportExpireInstant = Instant.ofEpochSecond(lastTeleportSeconds).plus(teleport.getDuration().getSeconds(), ChronoUnit.SECONDS);
|
||||||
|
Duration remainingTime = Duration.between(Instant.now(), teleportExpireInstant);
|
||||||
|
|
||||||
|
if (remainingTime.getSeconds() > 0)
|
||||||
|
{
|
||||||
|
createGameTimer(teleport, remainingTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
removeGameTimer(teleport);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameTick(GameTick event)
|
public void onGameTick(GameTick event)
|
||||||
{
|
{
|
||||||
@@ -956,23 +1004,6 @@ public class TimersPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.showHomeMinigameTeleports()
|
|
||||||
&& client.getLocalPlayer().getAnimation() == AnimationID.IDLE
|
|
||||||
&& (lastAnimation == AnimationID.BOOK_HOME_TELEPORT_5
|
|
||||||
|| lastAnimation == AnimationID.COW_HOME_TELEPORT_6
|
|
||||||
|| lastAnimation == AnimationID.LEAGUE_HOME_TELEPORT_6
|
|
||||||
|| lastAnimation == AnimationID.SHATTERED_LEAGUE_HOME_TELEPORT_6))
|
|
||||||
{
|
|
||||||
if (lastTeleportClicked == TeleportWidget.HOME_TELEPORT)
|
|
||||||
{
|
|
||||||
createGameTimer(HOME_TELEPORT);
|
|
||||||
}
|
|
||||||
else if (lastTeleportClicked == TeleportWidget.MINIGAME_TELEPORT)
|
|
||||||
{
|
|
||||||
createGameTimer(MINIGAME_TELEPORT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.showDFSSpecial() && lastAnimation == AnimationID.DRAGONFIRE_SHIELD_SPECIAL)
|
if (config.showDFSSpecial() && lastAnimation == AnimationID.DRAGONFIRE_SHIELD_SPECIAL)
|
||||||
{
|
{
|
||||||
createGameTimer(DRAGON_FIRE_SHIELD);
|
createGameTimer(DRAGON_FIRE_SHIELD);
|
||||||
|
|||||||
Reference in New Issue
Block a user