xptracker: fix initiailizing overall xp on login

The isInitialized() check was not strict enough causing the xp events on
login being calculated twords gained xp

Also fix xp tracker not being initialized on accounts with 0
construction exp due to the result of updateSkill not being INITIALIZED

Closes #8167
This commit is contained in:
Adam
2019-03-11 21:32:10 -04:00
parent 806c045157
commit 60b3ed18c0
2 changed files with 6 additions and 3 deletions

View File

@@ -79,7 +79,7 @@ class XpState
if (state.getStartXp() == -1)
{
if (currentXp > 0)
if (currentXp >= 0)
{
initializeSkill(skill, currentXp);
return XpUpdateResult.INITIALIZED;
@@ -198,7 +198,8 @@ class XpState
boolean isInitialized(Skill skill)
{
return xpSkills.containsKey(skill);
XpStateSingle xpStateSingle = xpSkills.get(skill);
return xpStateSingle != null && xpStateSingle.getStartXp() != -1;
}
@NonNull

View File

@@ -305,7 +305,9 @@ public class XpTrackerPlugin extends Plugin
if (skill == Skill.CONSTRUCTION && updateResult == XpUpdateResult.INITIALIZED)
{
// Construction is the last skill initialized on login, now initialize the total experience
xpState.initializeSkill(Skill.OVERALL, client.getOverallExperience());
long overallXp = client.getOverallExperience();
log.debug("Initializing XP tracker with {} overall exp", overallXp);
xpState.initializeSkill(Skill.OVERALL, overallXp);
}
else if (xpState.isInitialized(Skill.OVERALL))
{