Assetion Error Fix

This commit is contained in:
BuildTools
2019-07-29 22:07:53 -04:00
parent aedeaa10d2
commit c40689e870
2 changed files with 37 additions and 18 deletions

View File

@@ -72,20 +72,23 @@ class GauntletTimer extends Overlay {
/**
* This is called when the player resets the plugin mid-raid. We do not want to confuse the timer.
* <p>
* TODO: Originally, this function will disable the timer if the plugin is started mid raid.
* Unfortunately, VARBITS can't be checked unless you're on the client thread.
* I've no idea how to access RL's task handler.
* Good luck to you. If you restart plugin mid raid, oh well. Your timer's going to be inaccurate.
*/
public void initStates() {
timeRaidStart = -1L;
timeBossEnter = -1L;
if (client.getGameState() != GameState.STARTING && client.getGameState() != GameState.UNKNOWN) {
if (GauntletUtils.inRaid(client)) {
currentState = RaidState.IN_RAID;
if (GauntletUtils.inBoss(client)) {
currentState = RaidState.IN_BOSS;
}
} else
currentState = RaidState.UNKNOWN;
}
// timeRaidStart = -1L;
// timeBossEnter = -1L;
//
// if (GauntletUtils.inRaid(client)) {
// currentState = RaidState.IN_RAID;
// if (GauntletUtils.inBoss(client)) {
// currentState = RaidState.IN_BOSS;
// }
// } else
// currentState = RaidState.UNKNOWN;
}
/**
@@ -122,13 +125,20 @@ class GauntletTimer extends Overlay {
public void checkStates(boolean checkVarps) {
final Player p = client.getLocalPlayer();
if(p == null)
if (p == null)
return;
if (checkVarps) {
if (currentState == RaidState.UNKNOWN && GauntletUtils.inRaid(client) && !GauntletUtils.inBoss(client) && p.getHealthRatio() != 0) { // Player has started a new raid.
currentState = RaidState.IN_RAID;
timeRaidStart = System.currentTimeMillis();
if (currentState == RaidState.UNKNOWN) {
if (GauntletUtils.inRaid(client) && p.getHealthRatio() != 0) { // Player has started a new raid.
if (!GauntletUtils.inBoss(client)) {
currentState = RaidState.IN_RAID;
timeRaidStart = System.currentTimeMillis();
} else {
currentState = RaidState.IN_RAID;
timeRaidStart = timeBossEnter = System.currentTimeMillis();
}
}
} else if (currentState == RaidState.IN_RAID) {
if (GauntletUtils.inRaid(client)) {
if (GauntletUtils.inBoss(client)) { // Player has begun the boss fight.

View File

@@ -2,6 +2,7 @@ package net.runelite.client.plugins.gauntlet;
import net.runelite.api.Client;
import net.runelite.api.NPC;
import net.runelite.api.Varbits;
public class GauntletUtils {
@@ -138,7 +139,11 @@ public class GauntletUtils {
* @return boolean
*/
public static boolean inRaid(Client client) {
return client.getVarbitValue(client.getVarps(), VARP_RAID_ROOM) == 1;
try {
return client.getVarbitValue(client.getVarps(), VARP_RAID_ROOM) == 1;
} catch (IndexOutOfBoundsException ignore) {
return false;
}
}
/**
@@ -148,6 +153,10 @@ public class GauntletUtils {
* @return boolean
*/
public static boolean inBoss(Client client) {
return client.getVarbitValue(client.getVarps(), VARP_BOSS_ROOM) == 1;
try {
return client.getVarbitValue(client.getVarps(), VARP_BOSS_ROOM) == 1;
} catch (IndexOutOfBoundsException ignore) {
return false;
}
}
}