Merge pull request #8088 from Adam-/xptracker-overall
xptracker: correct total xp per hour calculation
This commit is contained in:
@@ -782,6 +782,13 @@ public interface Client extends GameEngine
|
|||||||
*/
|
*/
|
||||||
int getSkillExperience(Skill skill);
|
int getSkillExperience(Skill skill);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the total experience of the player
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
long getOverallExperience();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the game drawing mode.
|
* Gets the game drawing mode.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ package net.runelite.client.plugins.xptracker;
|
|||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -95,7 +94,7 @@ class XpInfoBox extends JPanel
|
|||||||
|
|
||||||
private boolean paused = false;
|
private boolean paused = false;
|
||||||
|
|
||||||
XpInfoBox(XpTrackerPlugin xpTrackerPlugin, XpTrackerConfig xpTrackerConfig, Client client, JPanel panel, Skill skill, SkillIconManager iconManager) throws IOException
|
XpInfoBox(XpTrackerPlugin xpTrackerPlugin, XpTrackerConfig xpTrackerConfig, Client client, JPanel panel, Skill skill, SkillIconManager iconManager)
|
||||||
{
|
{
|
||||||
this.xpTrackerConfig = xpTrackerConfig;
|
this.xpTrackerConfig = xpTrackerConfig;
|
||||||
this.panel = panel;
|
this.panel = panel;
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ package net.runelite.client.plugins.xptracker;
|
|||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
@@ -129,20 +128,13 @@ class XpPanel extends PluginPanel
|
|||||||
layoutPanel.add(overallPanel);
|
layoutPanel.add(overallPanel);
|
||||||
layoutPanel.add(infoBoxPanel);
|
layoutPanel.add(infoBoxPanel);
|
||||||
|
|
||||||
try
|
for (Skill skill : Skill.values())
|
||||||
{
|
{
|
||||||
for (Skill skill : Skill.values())
|
if (skill == Skill.OVERALL)
|
||||||
{
|
{
|
||||||
if (skill == Skill.OVERALL)
|
break;
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
infoBoxes.put(skill, new XpInfoBox(xpTrackerPlugin, xpTrackerConfig, client, infoBoxPanel, skill, iconManager));
|
|
||||||
}
|
}
|
||||||
}
|
infoBoxes.put(skill, new XpInfoBox(xpTrackerPlugin, xpTrackerConfig, client, infoBoxPanel, skill, iconManager));
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
log.warn(null, e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
errorPanel.setContent("Exp trackers", "You have not gained experience yet.");
|
errorPanel.setContent("Exp trackers", "You have not gained experience yet.");
|
||||||
@@ -193,7 +185,7 @@ class XpPanel extends PluginPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTotal(XpSnapshotTotal xpSnapshotTotal)
|
void updateTotal(XpSnapshotSingle xpSnapshotTotal)
|
||||||
{
|
{
|
||||||
// if player has gained exp and hasn't switched displays yet, hide error panel and show overall info
|
// if player has gained exp and hasn't switched displays yet, hide error panel and show overall info
|
||||||
if (xpSnapshotTotal.getXpGainedInSession() > 0 && !overallPanel.isVisible())
|
if (xpSnapshotTotal.getXpGainedInSession() > 0 && !overallPanel.isVisible())
|
||||||
@@ -201,11 +193,16 @@ class XpPanel extends PluginPanel
|
|||||||
overallPanel.setVisible(true);
|
overallPanel.setVisible(true);
|
||||||
remove(errorPanel);
|
remove(errorPanel);
|
||||||
}
|
}
|
||||||
|
else if (xpSnapshotTotal.getXpGainedInSession() == 0 && overallPanel.isVisible())
|
||||||
|
{
|
||||||
|
overallPanel.setVisible(false);
|
||||||
|
add(errorPanel);
|
||||||
|
}
|
||||||
|
|
||||||
SwingUtilities.invokeLater(() -> rebuildAsync(xpSnapshotTotal));
|
SwingUtilities.invokeLater(() -> rebuildAsync(xpSnapshotTotal));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rebuildAsync(XpSnapshotTotal xpSnapshotTotal)
|
private void rebuildAsync(XpSnapshotSingle xpSnapshotTotal)
|
||||||
{
|
{
|
||||||
overallExpGained.setText(XpInfoBox.htmlLabel("Gained: ", xpSnapshotTotal.getXpGainedInSession()));
|
overallExpGained.setText(XpInfoBox.htmlLabel("Gained: ", xpSnapshotTotal.getXpGainedInSession()));
|
||||||
overallExpHour.setText(XpInfoBox.htmlLabel("Per hour: ", xpSnapshotTotal.getXpPerHour()));
|
overallExpHour.setText(XpInfoBox.htmlLabel("Per hour: ", xpSnapshotTotal.getXpPerHour()));
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class XpPauseState
|
|||||||
return findPauseState(skill).isPaused();
|
return findPauseState(skill).isPaused();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tickXp(Skill skill, int currentXp, int pauseAfterMinutes)
|
void tickXp(Skill skill, long currentXp, int pauseAfterMinutes)
|
||||||
{
|
{
|
||||||
final XpPauseStateSingle state = findPauseState(skill);
|
final XpPauseStateSingle state = findPauseState(skill);
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class XpPauseStateSingle
|
|||||||
@Getter
|
@Getter
|
||||||
private long lastChangeMillis;
|
private long lastChangeMillis;
|
||||||
@Getter
|
@Getter
|
||||||
private int xp;
|
private long xp;
|
||||||
|
|
||||||
boolean isPaused()
|
boolean isPaused()
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ class XpPauseStateSingle
|
|||||||
return pauseReasons.add(XpPauseReason.PAUSE_MANUAL);
|
return pauseReasons.add(XpPauseReason.PAUSE_MANUAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean xpChanged(int xp)
|
boolean xpChanged(long xp)
|
||||||
{
|
{
|
||||||
this.xp = xp;
|
this.xp = xp;
|
||||||
this.lastChangeMillis = System.currentTimeMillis();
|
this.lastChangeMillis = System.currentTimeMillis();
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Levi <me@levischuck.com>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.client.plugins.xptracker;
|
|
||||||
|
|
||||||
import lombok.Value;
|
|
||||||
|
|
||||||
@Value
|
|
||||||
class XpSnapshotTotal
|
|
||||||
{
|
|
||||||
private final int xpGainedInSession;
|
|
||||||
private final int xpPerHour;
|
|
||||||
|
|
||||||
static XpSnapshotTotal zero()
|
|
||||||
{
|
|
||||||
return new XpSnapshotTotal(0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -40,7 +40,6 @@ class XpState
|
|||||||
{
|
{
|
||||||
private static final double DEFAULT_XP_MODIFIER = 4.0;
|
private static final double DEFAULT_XP_MODIFIER = 4.0;
|
||||||
private static final double SHARED_XP_MODIFIER = DEFAULT_XP_MODIFIER / 3.0;
|
private static final double SHARED_XP_MODIFIER = DEFAULT_XP_MODIFIER / 3.0;
|
||||||
private final XpStateTotal xpTotal = new XpStateTotal();
|
|
||||||
private final Map<Skill, XpStateSingle> xpSkills = new EnumMap<>(Skill.class);
|
private final Map<Skill, XpStateSingle> xpSkills = new EnumMap<>(Skill.class);
|
||||||
private NPC interactedNPC;
|
private NPC interactedNPC;
|
||||||
|
|
||||||
@@ -49,7 +48,6 @@ class XpState
|
|||||||
*/
|
*/
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
xpTotal.reset();
|
|
||||||
xpSkills.clear();
|
xpSkills.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,25 +56,10 @@ class XpState
|
|||||||
* @param skill Skill to reset
|
* @param skill Skill to reset
|
||||||
* @param currentXp Current XP to set to, if unknown set to -1
|
* @param currentXp Current XP to set to, if unknown set to -1
|
||||||
*/
|
*/
|
||||||
void resetSkill(Skill skill, int currentXp)
|
void resetSkill(Skill skill, long currentXp)
|
||||||
{
|
{
|
||||||
xpSkills.remove(skill);
|
xpSkills.remove(skill);
|
||||||
xpSkills.put(skill, new XpStateSingle(skill, currentXp));
|
xpSkills.put(skill, new XpStateSingle(skill, currentXp));
|
||||||
recalculateTotal();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates the total skill changes observed in this session or since the last reset
|
|
||||||
*/
|
|
||||||
void recalculateTotal()
|
|
||||||
{
|
|
||||||
xpTotal.reset();
|
|
||||||
|
|
||||||
for (XpStateSingle state : xpSkills.values())
|
|
||||||
{
|
|
||||||
xpTotal.addXpGainedInSession(state.getXpGained());
|
|
||||||
xpTotal.addXpPerHour(state.getXpHr());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,7 +73,7 @@ class XpState
|
|||||||
* @param goalEndXp Possible XP end goal
|
* @param goalEndXp Possible XP end goal
|
||||||
* @return Whether or not the skill has been initialized, there was no change, or it has been updated
|
* @return Whether or not the skill has been initialized, there was no change, or it has been updated
|
||||||
*/
|
*/
|
||||||
XpUpdateResult updateSkill(Skill skill, int currentXp, int goalStartXp, int goalEndXp)
|
XpUpdateResult updateSkill(Skill skill, long currentXp, int goalStartXp, int goalEndXp)
|
||||||
{
|
{
|
||||||
XpStateSingle state = getSkill(skill);
|
XpStateSingle state = getSkill(skill);
|
||||||
|
|
||||||
@@ -108,7 +91,7 @@ class XpState
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int startXp = state.getStartXp();
|
long startXp = state.getStartXp();
|
||||||
int gainedXp = state.getXpGained();
|
int gainedXp = state.getXpGained();
|
||||||
|
|
||||||
if (startXp + gainedXp > currentXp)
|
if (startXp + gainedXp > currentXp)
|
||||||
@@ -208,11 +191,16 @@ class XpState
|
|||||||
* @param skill Skill to initialize
|
* @param skill Skill to initialize
|
||||||
* @param currentXp Current known XP for the skill
|
* @param currentXp Current known XP for the skill
|
||||||
*/
|
*/
|
||||||
void initializeSkill(Skill skill, int currentXp)
|
void initializeSkill(Skill skill, long currentXp)
|
||||||
{
|
{
|
||||||
xpSkills.put(skill, new XpStateSingle(skill, currentXp));
|
xpSkills.put(skill, new XpStateSingle(skill, currentXp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isInitialized(Skill skill)
|
||||||
|
{
|
||||||
|
return xpSkills.containsKey(skill);
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
XpStateSingle getSkill(Skill skill)
|
XpStateSingle getSkill(Skill skill)
|
||||||
{
|
{
|
||||||
@@ -237,8 +225,8 @@ class XpState
|
|||||||
* @return An immutable snapshot of total information for this session since first login or last reset
|
* @return An immutable snapshot of total information for this session since first login or last reset
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
XpSnapshotTotal getTotalSnapshot()
|
XpSnapshotSingle getTotalSnapshot()
|
||||||
{
|
{
|
||||||
return xpTotal.snapshot();
|
return getSkill(Skill.OVERALL).snapshot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class XpStateSingle
|
|||||||
private final Map<XpActionType, XpAction> actions = new HashMap<>();
|
private final Map<XpActionType, XpAction> actions = new HashMap<>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final int startXp;
|
private final long startXp;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private int xpGained = 0;
|
private int xpGained = 0;
|
||||||
@@ -60,7 +60,7 @@ class XpStateSingle
|
|||||||
return actions.get(type);
|
return actions.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCurrentXp()
|
private long getCurrentXp()
|
||||||
{
|
{
|
||||||
return startXp + xpGained;
|
return startXp + xpGained;
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ class XpStateSingle
|
|||||||
|
|
||||||
private int getXpRemaining()
|
private int getXpRemaining()
|
||||||
{
|
{
|
||||||
return endLevelExp - getCurrentXp();
|
return endLevelExp - (int) getCurrentXp();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getActionsRemaining()
|
private int getActionsRemaining()
|
||||||
@@ -170,7 +170,7 @@ class XpStateSingle
|
|||||||
return toHourly(xpGained);
|
return toHourly(xpGained);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean update(int currentXp, int goalStartXp, int goalEndXp)
|
boolean update(long currentXp, int goalStartXp, int goalEndXp)
|
||||||
{
|
{
|
||||||
if (startXp == -1)
|
if (startXp == -1)
|
||||||
{
|
{
|
||||||
@@ -178,8 +178,8 @@ class XpStateSingle
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int originalXp = xpGained + startXp;
|
long originalXp = xpGained + startXp;
|
||||||
int actionExp = currentXp - originalXp;
|
int actionExp = (int) (currentXp - originalXp);
|
||||||
|
|
||||||
// No experience gained
|
// No experience gained
|
||||||
if (actionExp == 0)
|
if (actionExp == 0)
|
||||||
@@ -210,28 +210,31 @@ class XpStateSingle
|
|||||||
action.setActions(action.getActions() + 1);
|
action.setActions(action.getActions() + 1);
|
||||||
|
|
||||||
// Calculate experience gained
|
// Calculate experience gained
|
||||||
xpGained = currentXp - startXp;
|
xpGained = (int) (currentXp - startXp);
|
||||||
|
|
||||||
// Determine XP goals
|
// Determine XP goals, overall has no goals
|
||||||
if (goalStartXp <= 0 || currentXp > goalEndXp)
|
if (skill != Skill.OVERALL)
|
||||||
{
|
{
|
||||||
startLevelExp = Experience.getXpForLevel(Experience.getLevelForXp(currentXp));
|
if (goalStartXp <= 0 || currentXp > goalEndXp)
|
||||||
}
|
{
|
||||||
else
|
startLevelExp = Experience.getXpForLevel(Experience.getLevelForXp((int) currentXp));
|
||||||
{
|
}
|
||||||
startLevelExp = goalStartXp;
|
else
|
||||||
}
|
{
|
||||||
|
startLevelExp = goalStartXp;
|
||||||
|
}
|
||||||
|
|
||||||
if (goalEndXp <= 0 || currentXp > goalEndXp)
|
if (goalEndXp <= 0 || currentXp > goalEndXp)
|
||||||
{
|
{
|
||||||
int currentLevel = Experience.getLevelForXp(currentXp);
|
int currentLevel = Experience.getLevelForXp((int) currentXp);
|
||||||
endLevelExp = currentLevel + 1 <= Experience.MAX_VIRT_LEVEL
|
endLevelExp = currentLevel + 1 <= Experience.MAX_VIRT_LEVEL
|
||||||
? Experience.getXpForLevel(currentLevel + 1)
|
? Experience.getXpForLevel(currentLevel + 1)
|
||||||
: Experience.MAX_SKILL_XP;
|
: Experience.MAX_SKILL_XP;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
endLevelExp = goalEndXp;
|
endLevelExp = goalEndXp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Levi <me@levischuck.com>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.client.plugins.xptracker;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
class XpStateTotal
|
|
||||||
{
|
|
||||||
private int xpGainedInSession = 0;
|
|
||||||
private int xpPerHour = 0;
|
|
||||||
|
|
||||||
void reset()
|
|
||||||
{
|
|
||||||
xpGainedInSession = 0;
|
|
||||||
xpPerHour = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addXpGainedInSession(int skillXpGainedInSession)
|
|
||||||
{
|
|
||||||
xpGainedInSession += skillXpGainedInSession;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addXpPerHour(int skillXpGainedPerHour)
|
|
||||||
{
|
|
||||||
xpPerHour += skillXpGainedPerHour;
|
|
||||||
}
|
|
||||||
|
|
||||||
XpSnapshotTotal snapshot()
|
|
||||||
{
|
|
||||||
return new XpSnapshotTotal(xpGainedInSession, xpPerHour);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -146,16 +146,6 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
clientToolbar.removeNavigation(navButton);
|
clientToolbar.removeNavigation(navButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getTotalXp()
|
|
||||||
{
|
|
||||||
long total = 0;
|
|
||||||
for (Skill skill : Skill.values())
|
|
||||||
{
|
|
||||||
total += client.getSkillExperience(skill);
|
|
||||||
}
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onGameStateChanged(GameStateChanged event)
|
public void onGameStateChanged(GameStateChanged event)
|
||||||
{
|
{
|
||||||
@@ -195,7 +185,7 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long totalXp = getTotalXp();
|
long totalXp = client.getOverallExperience();
|
||||||
// Don't submit xptrack unless xp threshold is reached
|
// Don't submit xptrack unless xp threshold is reached
|
||||||
if (Math.abs(totalXp - lastXp) > XP_THRESHOLD)
|
if (Math.abs(totalXp - lastXp) > XP_THRESHOLD)
|
||||||
{
|
{
|
||||||
@@ -229,7 +219,16 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
|
|
||||||
for (Skill skill : Skill.values())
|
for (Skill skill : Skill.values())
|
||||||
{
|
{
|
||||||
int currentXp = client.getSkillExperience(skill);
|
long currentXp;
|
||||||
|
if (skill == Skill.OVERALL)
|
||||||
|
{
|
||||||
|
currentXp = client.getOverallExperience();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentXp = client.getSkillExperience(skill);
|
||||||
|
}
|
||||||
|
|
||||||
xpState.initializeSkill(skill, currentXp);
|
xpState.initializeSkill(skill, currentXp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,7 +241,7 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
xpState.reset();
|
xpState.reset();
|
||||||
xpPanel.resetAllInfoBoxes();
|
xpPanel.resetAllInfoBoxes();
|
||||||
xpPanel.updateTotal(XpSnapshotTotal.zero());
|
xpPanel.updateTotal(new XpSnapshotSingle.XpSnapshotSingleBuilder().build());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -254,7 +253,6 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
int currentXp = client.getSkillExperience(skill);
|
int currentXp = client.getSkillExperience(skill);
|
||||||
xpState.resetSkill(skill, currentXp);
|
xpState.resetSkill(skill, currentXp);
|
||||||
xpState.recalculateTotal();
|
|
||||||
xpPanel.resetSkill(skill);
|
xpPanel.resetSkill(skill);
|
||||||
xpPanel.updateTotal(xpState.getTotalSnapshot());
|
xpPanel.updateTotal(xpState.getTotalSnapshot());
|
||||||
}
|
}
|
||||||
@@ -302,10 +300,18 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
final XpUpdateResult updateResult = xpState.updateSkill(skill, currentXp, startGoalXp, endGoalXp);
|
final XpUpdateResult updateResult = xpState.updateSkill(skill, currentXp, startGoalXp, endGoalXp);
|
||||||
final boolean updated = XpUpdateResult.UPDATED.equals(updateResult);
|
xpPanel.updateSkillExperience(updateResult == XpUpdateResult.UPDATED, xpPauseState.isPaused(skill), skill, xpState.getSkillSnapshot(skill));
|
||||||
xpPanel.updateSkillExperience(updated, xpPauseState.isPaused(skill), skill, xpState.getSkillSnapshot(skill));
|
|
||||||
xpState.recalculateTotal();
|
if (skill == Skill.CONSTRUCTION && updateResult == XpUpdateResult.INITIALIZED)
|
||||||
xpPanel.updateTotal(xpState.getTotalSnapshot());
|
{
|
||||||
|
// Construction is the last skill initialized on login, now initialize the total experience
|
||||||
|
xpState.initializeSkill(Skill.OVERALL, client.getOverallExperience());
|
||||||
|
}
|
||||||
|
else if (xpState.isInitialized(Skill.OVERALL))
|
||||||
|
{
|
||||||
|
xpState.updateSkill(Skill.OVERALL, client.getOverallExperience(), -1, -1);
|
||||||
|
xpPanel.updateTotal(xpState.getTotalSnapshot());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -325,7 +331,6 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
xpPanel.updateSkillExperience(updated, xpPauseState.isPaused(skill), skill, xpState.getSkillSnapshot(skill));
|
xpPanel.updateSkillExperience(updated, xpPauseState.isPaused(skill), skill, xpState.getSkillSnapshot(skill));
|
||||||
}
|
}
|
||||||
|
|
||||||
xpState.recalculateTotal();
|
|
||||||
xpPanel.updateTotal(xpState.getTotalSnapshot());
|
xpPanel.updateTotal(xpState.getTotalSnapshot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,7 +340,7 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
rebuildSkills();
|
rebuildSkills();
|
||||||
if (fetchXp)
|
if (fetchXp)
|
||||||
{
|
{
|
||||||
lastXp = getTotalXp();
|
lastXp = client.getOverallExperience();
|
||||||
fetchXp = false;
|
fetchXp = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -464,7 +469,17 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
// Adjust unpause states
|
// Adjust unpause states
|
||||||
for (Skill skill : Skill.values())
|
for (Skill skill : Skill.values())
|
||||||
{
|
{
|
||||||
xpPauseState.tickXp(skill, client.getSkillExperience(skill), xpTrackerConfig.pauseSkillAfter());
|
long skillExperience;
|
||||||
|
if (skill == Skill.OVERALL)
|
||||||
|
{
|
||||||
|
skillExperience = client.getOverallExperience();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
skillExperience = client.getSkillExperience(skill);
|
||||||
|
}
|
||||||
|
|
||||||
|
xpPauseState.tickXp(skill, skillExperience, xpTrackerConfig.pauseSkillAfter());
|
||||||
}
|
}
|
||||||
|
|
||||||
xpPauseState.tickLogout(xpTrackerConfig.pauseOnLogout(), !GameState.LOGIN_SCREEN.equals(client.getGameState()));
|
xpPauseState.tickLogout(xpTrackerConfig.pauseOnLogout(), !GameState.LOGIN_SCREEN.equals(client.getGameState()));
|
||||||
@@ -498,7 +513,6 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
xpPanel.updateSkillExperience(false, xpPauseState.isPaused(skill), skill, xpState.getSkillSnapshot(skill));
|
xpPanel.updateSkillExperience(false, xpPauseState.isPaused(skill), skill, xpState.getSkillSnapshot(skill));
|
||||||
}
|
}
|
||||||
|
|
||||||
xpState.recalculateTotal();
|
|
||||||
xpPanel.updateTotal(xpState.getTotalSnapshot());
|
xpPanel.updateTotal(xpState.getTotalSnapshot());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -504,14 +504,8 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
|
|
||||||
if (skill == Skill.OVERALL)
|
if (skill == Skill.OVERALL)
|
||||||
{
|
{
|
||||||
int totalExperience = 0;
|
logger.debug("getSkillExperience called for {}!", skill);
|
||||||
|
return (int) getOverallExperience();
|
||||||
for (int experience : experiences)
|
|
||||||
{
|
|
||||||
totalExperience += experience;
|
|
||||||
}
|
|
||||||
|
|
||||||
return totalExperience;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int idx = skill.ordinal();
|
int idx = skill.ordinal();
|
||||||
@@ -526,6 +520,22 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
return experiences[idx];
|
return experiences[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Override
|
||||||
|
public long getOverallExperience()
|
||||||
|
{
|
||||||
|
int[] experiences = getSkillExperiences();
|
||||||
|
|
||||||
|
long totalExperience = 0L;
|
||||||
|
|
||||||
|
for (int experience : experiences)
|
||||||
|
{
|
||||||
|
totalExperience += experience;
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalExperience;
|
||||||
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Override
|
@Override
|
||||||
public void refreshChat()
|
public void refreshChat()
|
||||||
|
|||||||
Reference in New Issue
Block a user