Assetion Error Fix
This commit is contained in:
@@ -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.
|
* 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() {
|
public void initStates() {
|
||||||
timeRaidStart = -1L;
|
// timeRaidStart = -1L;
|
||||||
timeBossEnter = -1L;
|
// timeBossEnter = -1L;
|
||||||
|
//
|
||||||
if (client.getGameState() != GameState.STARTING && client.getGameState() != GameState.UNKNOWN) {
|
// if (GauntletUtils.inRaid(client)) {
|
||||||
if (GauntletUtils.inRaid(client)) {
|
// currentState = RaidState.IN_RAID;
|
||||||
currentState = RaidState.IN_RAID;
|
// if (GauntletUtils.inBoss(client)) {
|
||||||
if (GauntletUtils.inBoss(client)) {
|
// currentState = RaidState.IN_BOSS;
|
||||||
currentState = RaidState.IN_BOSS;
|
// }
|
||||||
}
|
// } else
|
||||||
} else
|
// currentState = RaidState.UNKNOWN;
|
||||||
currentState = RaidState.UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,9 +129,16 @@ class GauntletTimer extends Overlay {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (checkVarps) {
|
if (checkVarps) {
|
||||||
if (currentState == RaidState.UNKNOWN && GauntletUtils.inRaid(client) && !GauntletUtils.inBoss(client) && p.getHealthRatio() != 0) { // Player has started a new raid.
|
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;
|
currentState = RaidState.IN_RAID;
|
||||||
timeRaidStart = System.currentTimeMillis();
|
timeRaidStart = System.currentTimeMillis();
|
||||||
|
} else {
|
||||||
|
currentState = RaidState.IN_RAID;
|
||||||
|
timeRaidStart = timeBossEnter = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (currentState == RaidState.IN_RAID) {
|
} else if (currentState == RaidState.IN_RAID) {
|
||||||
if (GauntletUtils.inRaid(client)) {
|
if (GauntletUtils.inRaid(client)) {
|
||||||
if (GauntletUtils.inBoss(client)) { // Player has begun the boss fight.
|
if (GauntletUtils.inBoss(client)) { // Player has begun the boss fight.
|
||||||
|
@@ -2,6 +2,7 @@ package net.runelite.client.plugins.gauntlet;
|
|||||||
|
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.NPC;
|
import net.runelite.api.NPC;
|
||||||
|
import net.runelite.api.Varbits;
|
||||||
|
|
||||||
public class GauntletUtils {
|
public class GauntletUtils {
|
||||||
|
|
||||||
@@ -138,7 +139,11 @@ public class GauntletUtils {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean inRaid(Client client) {
|
public static boolean inRaid(Client client) {
|
||||||
|
try {
|
||||||
return client.getVarbitValue(client.getVarps(), VARP_RAID_ROOM) == 1;
|
return client.getVarbitValue(client.getVarps(), VARP_RAID_ROOM) == 1;
|
||||||
|
} catch (IndexOutOfBoundsException ignore) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,6 +153,10 @@ public class GauntletUtils {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean inBoss(Client client) {
|
public static boolean inBoss(Client client) {
|
||||||
|
try {
|
||||||
return client.getVarbitValue(client.getVarps(), VARP_BOSS_ROOM) == 1;
|
return client.getVarbitValue(client.getVarps(), VARP_BOSS_ROOM) == 1;
|
||||||
|
} catch (IndexOutOfBoundsException ignore) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user