xp trackers: fix not correctly fetching start xp
This commit is contained in:
@@ -33,6 +33,7 @@ import net.runelite.api.GameState;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
@@ -62,6 +63,7 @@ public class CrystalMathLabs extends Plugin
|
||||
private Client client;
|
||||
|
||||
private String lastUsername;
|
||||
private boolean fetchXp;
|
||||
private long lastXp;
|
||||
|
||||
@Subscribe
|
||||
@@ -94,6 +96,16 @@ public class CrystalMathLabs extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick gameTick)
|
||||
{
|
||||
if (fetchXp)
|
||||
{
|
||||
lastXp = getTotalXp();
|
||||
fetchXp = false;
|
||||
}
|
||||
}
|
||||
|
||||
private long getTotalXp()
|
||||
{
|
||||
long total = 0;
|
||||
|
||||
@@ -103,6 +103,7 @@ public class XpTrackerPlugin extends Plugin
|
||||
private XpWorldType lastWorldType;
|
||||
private String lastUsername;
|
||||
private long lastTickMillis = 0;
|
||||
private boolean fetchXp;
|
||||
private long lastXp = 0;
|
||||
|
||||
private final XpClient xpClient = new XpClient();
|
||||
@@ -174,7 +175,8 @@ public class XpTrackerPlugin extends Plugin
|
||||
firstNonNull(type, "<unknown>"));
|
||||
|
||||
lastUsername = client.getUsername();
|
||||
lastXp = getTotalXp();
|
||||
// xp is not available until after login is finished, so fetch it on the next gametick
|
||||
fetchXp = true;
|
||||
lastWorldType = type;
|
||||
resetState();
|
||||
}
|
||||
@@ -331,6 +333,11 @@ public class XpTrackerPlugin extends Plugin
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
rebuildSkills();
|
||||
if (fetchXp)
|
||||
{
|
||||
lastXp = getTotalXp();
|
||||
fetchXp = false;
|
||||
}
|
||||
}
|
||||
|
||||
XpSnapshotSingle getSkillSnapshot(Skill skill)
|
||||
|
||||
Reference in New Issue
Block a user