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:
@@ -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
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user