Add option to hide both globes and xp tracker after 99 (#5741)

Fixes #2631
This commit is contained in:
Andre
2018-10-03 08:35:42 +01:00
committed by Tomas Slusny
parent f229f942f1
commit 62be01c7ed
5 changed files with 46 additions and 7 deletions

View File

@@ -36,6 +36,11 @@ import static java.lang.Math.max;
*/ */
public class Experience public class Experience
{ {
/**
* Maximum effective skill level at 13,034,431 experience.
*/
public static final int MAX_REAL_LEVEL = 99;
/** /**
* The maximum virtual skill level for any skill (200M experience). * The maximum virtual skill level for any skill (200M experience).
*/ */

View File

@@ -43,11 +43,22 @@ public interface XpGlobesConfig extends Config
return true; return true;
} }
@ConfigItem(
keyName = "hideMaxed",
name = "Hide maxed skills",
description = "Stop globes from showing up for level 99 skills ",
position = 1
)
default boolean hideMaxed()
{
return false;
}
@ConfigItem( @ConfigItem(
keyName = "Progress arc color", keyName = "Progress arc color",
name = "Progress arc color", name = "Progress arc color",
description = "Change the color of the progress arc in the xp orb", description = "Change the color of the progress arc in the xp orb",
position = 1 position = 2
) )
default Color progressArcColor() default Color progressArcColor()
{ {
@@ -58,7 +69,7 @@ public interface XpGlobesConfig extends Config
keyName = "Progress orb outline color", keyName = "Progress orb outline color",
name = "Progress orb outline color", name = "Progress orb outline color",
description = "Change the color of the progress orb outline", description = "Change the color of the progress orb outline",
position = 2 position = 3
) )
default Color progressOrbOutLineColor() default Color progressOrbOutLineColor()
{ {
@@ -69,7 +80,7 @@ public interface XpGlobesConfig extends Config
keyName = "Progress orb background color", keyName = "Progress orb background color",
name = "Progress orb background color", name = "Progress orb background color",
description = "Change the color of the progress orb background", description = "Change the color of the progress orb background",
position = 3 position = 4
) )
default Color progressOrbBackgroundColor() default Color progressOrbBackgroundColor()
{ {
@@ -80,7 +91,7 @@ public interface XpGlobesConfig extends Config
keyName = "Progress arc width", keyName = "Progress arc width",
name = "Progress arc width", name = "Progress arc width",
description = "Change the stroke width of the progress arc", description = "Change the stroke width of the progress arc",
position = 4 position = 5
) )
default int progressArcStrokeWidth() default int progressArcStrokeWidth()
{ {
@@ -91,7 +102,7 @@ public interface XpGlobesConfig extends Config
keyName = "Orb size", keyName = "Orb size",
name = "Size of orbs", name = "Size of orbs",
description = "Change the size of the xp orbs", description = "Change the size of the xp orbs",
position = 5 position = 6
) )
default int xpOrbSize() default int xpOrbSize()
{ {
@@ -102,7 +113,7 @@ public interface XpGlobesConfig extends Config
keyName = "Orb duration", keyName = "Orb duration",
name = "Duration of orbs", name = "Duration of orbs",
description = "Change the duration the xp orbs are visible", description = "Change the duration the xp orbs are visible",
position = 6 position = 7
) )
default int xpOrbDuration() default int xpOrbDuration()
{ {

View File

@@ -104,6 +104,11 @@ public class XpGlobesPlugin extends Plugin
return; return;
} }
if (config.hideMaxed() && currentLevel >= Experience.MAX_REAL_LEVEL)
{
return;
}
int startingXp = Experience.getXpForLevel(currentLevel); int startingXp = Experience.getXpForLevel(currentLevel);
int goalXp = currentLevel + 1 <= Experience.MAX_VIRT_LEVEL ? Experience.getXpForLevel(currentLevel + 1) : -1; int goalXp = currentLevel + 1 <= Experience.MAX_VIRT_LEVEL ? Experience.getXpForLevel(currentLevel + 1) : -1;

View File

@@ -33,6 +33,17 @@ public interface XpTrackerConfig extends Config
{ {
@ConfigItem( @ConfigItem(
position = 0, position = 0,
keyName = "hideMaxed",
name = "Hide maxed skills",
description = "Stop globes from showing up for level 99 skills "
)
default boolean hideMaxed()
{
return false;
}
@ConfigItem(
position = 1,
keyName = "logoutPausing", keyName = "logoutPausing",
name = "Pause on Logout", name = "Pause on Logout",
description = "Configures whether skills should pause on logout" description = "Configures whether skills should pause on logout"
@@ -43,7 +54,7 @@ public interface XpTrackerConfig extends Config
} }
@ConfigItem( @ConfigItem(
position = 1, position = 2,
keyName = "pauseSkillAfter", keyName = "pauseSkillAfter",
name = "Auto pause after", name = "Auto pause after",
description = "Configures how many minutes passes before pausing a skill while in game and there's no XP, 0 means disabled" description = "Configures how many minutes passes before pausing a skill while in game and there's no XP, 0 means disabled"

View File

@@ -36,6 +36,7 @@ import java.util.Objects;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Experience;
import net.runelite.api.GameState; import net.runelite.api.GameState;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.Skill; import net.runelite.api.Skill;
@@ -230,11 +231,17 @@ public class XpTrackerPlugin extends Plugin
{ {
final Skill skill = event.getSkill(); final Skill skill = event.getSkill();
final int currentXp = client.getSkillExperience(skill); final int currentXp = client.getSkillExperience(skill);
final int currentLevel = Experience.getLevelForXp(currentXp);
final VarPlayer startGoal = startGoalVarpForSkill(skill); final VarPlayer startGoal = startGoalVarpForSkill(skill);
final VarPlayer endGoal = endGoalVarpForSkill(skill); final VarPlayer endGoal = endGoalVarpForSkill(skill);
final int startGoalXp = startGoal != null ? client.getVar(startGoal) : -1; final int startGoalXp = startGoal != null ? client.getVar(startGoal) : -1;
final int endGoalXp = endGoal != null ? client.getVar(endGoal) : -1; final int endGoalXp = endGoal != null ? client.getVar(endGoal) : -1;
if (xpTrackerConfig.hideMaxed() && currentLevel >= Experience.MAX_REAL_LEVEL)
{
return;
}
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); final boolean updated = XpUpdateResult.UPDATED.equals(updateResult);