use of net.runelite.api.Skill in project runelite by runelite.
the class BoostsOverlay method render.
@Override
public Dimension render(Graphics2D graphics) {
panelComponent = new PanelComponent();
boolean overlayActive = false;
for (Skill skill : plugin.getShownSkills()) {
int boosted = client.getBoostedSkillLevel(skill), base = client.getRealSkillLevel(skill);
BoostIndicator indicator = indicators[skill.ordinal()];
if (boosted == base) {
if (indicator != null && infoBoxManager.getInfoBoxes().contains(indicator)) {
infoBoxManager.removeInfoBox(indicator);
}
continue;
}
overlayActive = true;
if (config.displayIndicators()) {
if (indicator == null) {
indicator = new BoostIndicator(skill, iconManager.getSkillImage(skill), plugin, client, config);
indicators[skill.ordinal()] = indicator;
}
if (!infoBoxManager.getInfoBoxes().contains(indicator)) {
infoBoxManager.addInfoBox(indicator);
}
} else {
if (indicator != null && infoBoxManager.getInfoBoxes().contains(indicator)) {
infoBoxManager.removeInfoBox(indicator);
}
String str;
int boost = boosted - base;
Color strColor = getTextColor(boost);
if (!config.useRelativeBoost()) {
str = "<col=" + Integer.toHexString(strColor.getRGB() & 0xFFFFFF) + ">" + boosted + "<col=ffffff>/" + base;
} else {
str = String.valueOf(boost);
if (boost > 0) {
str = "+" + str;
}
}
panelComponent.getLines().add(new PanelComponent.Line(skill.getName(), Color.WHITE, str, strColor));
}
}
Instant lastChange = plugin.getLastChange();
if (config.displayNextChange() && lastChange != null && overlayActive) {
int nextChange = 60 - (int) Duration.between(lastChange, Instant.now()).getSeconds();
if (nextChange > 0) {
panelComponent.getLines().add(new PanelComponent.Line("Next change in", Color.WHITE, String.valueOf(nextChange), Color.WHITE));
}
}
return panelComponent.getLines().isEmpty() ? null : panelComponent.render(graphics);
}
use of net.runelite.api.Skill in project runelite by runelite.
the class BoostsPlugin method onBoostedLevelChange.
@Subscribe
void onBoostedLevelChange(BoostedLevelChanged boostedLevelChanged) {
Skill skill = boostedLevelChanged.getSkill();
// Ignore changes to hitpoints or prayer
if (skill == Skill.HITPOINTS || skill == Skill.PRAYER) {
return;
}
int skillIdx = skill.ordinal();
int last = lastSkillLevels[skillIdx];
int cur = client.getBoostedSkillLevel(skill);
// Check if stat goes +1 or -2
if (cur == last + 1 || cur == last - 1) {
log.debug("Skill {} healed", skill);
lastChange = Instant.now();
}
lastSkillLevels[skillIdx] = cur;
}
use of net.runelite.api.Skill in project runelite by runelite.
the class AttackIndicatorPluginTest method testWarning.
/*
* Verify that red text is displayed when attacking with a style that gains experience
* in one of the unwanted skills.
*/
@Test
public void testWarning() {
ConfigChanged warnForAttackEvent = new ConfigChanged();
warnForAttackEvent.setGroup("attackIndicator");
warnForAttackEvent.setKey("warnForAttack");
warnForAttackEvent.setNewValue("true");
attackPlugin.onConfigChanged(warnForAttackEvent);
// Verify there is a warned skill
Set<Skill> warnedSkills = attackPlugin.getWarnedSkills();
assertTrue(warnedSkills.contains(Skill.ATTACK));
// Set mock client to attack in style that gives attack xp
when(client.getSetting(Setting.ATTACK_STYLE)).thenReturn(AttackStyle.ACCURATE.ordinal());
// verify that earning xp in a warned skill will display red text on the widget
attackPlugin.onAttackStyleChange(new VarbitChanged());
assertTrue(attackPlugin.isWarnedSkillSelected());
// Switch to attack style that doesn't give attack xp
when(client.getSetting(Setting.ATTACK_STYLE)).thenReturn(AttackStyle.AGGRESSIVE.ordinal());
// Verify the widget will now display white text
attackPlugin.onAttackStyleChange(new VarbitChanged());
warnedSkills = attackPlugin.getWarnedSkills();
assertTrue(warnedSkills.contains(Skill.ATTACK));
assertFalse(attackPlugin.isWarnedSkillSelected());
}
use of net.runelite.api.Skill in project runelite by runelite.
the class XpGlobesPlugin method onExperienceChanged.
@Subscribe
public void onExperienceChanged(ExperienceChanged event) {
Skill skill = event.getSkill();
int currentXp = client.getSkillExperience(skill);
int currentLevel = Experience.getLevelForXp(currentXp);
int skillIdx = skill.ordinal();
XpGlobe cachedGlobe = globeCache[skillIdx];
// ExperienceChanged event occurs when stats drain/boost check we have an change to actual xp
if (cachedGlobe != null && (cachedGlobe.getCurrentXp() >= currentXp)) {
return;
}
int startingXp = Experience.getXpForLevel(currentLevel);
int goalXp = currentLevel + 1 <= Experience.MAX_VIRT_LEVEL ? Experience.getXpForLevel(currentLevel + 1) : -1;
if (cachedGlobe != null) {
cachedGlobe.setSkill(skill);
cachedGlobe.setCurrentXp(currentXp);
cachedGlobe.setCurrentLevel(currentLevel);
cachedGlobe.setGoalXp(goalXp);
cachedGlobe.setTime(Instant.now());
cachedGlobe.setSkillProgressRadius(startingXp, currentXp, goalXp);
this.addXpGlobe(globeCache[skillIdx], MAXIMUM_SHOWN_GLOBES);
} else {
// dont draw non cached globes, this is triggered on login to setup all of the initial values
globeCache[skillIdx] = new XpGlobe(skill, currentXp, currentLevel, goalXp);
}
}
use of net.runelite.api.Skill in project runelite by runelite.
the class RSClientMixin method experiencedChanged.
@FieldHook("skillExperiences")
@Inject
public static void experiencedChanged(int idx) {
ExperienceChanged experienceChanged = new ExperienceChanged();
Skill[] possibleSkills = Skill.values();
// We subtract one here because 'Overall' isn't considered a skill that's updated.
if (idx < possibleSkills.length - 1) {
Skill updatedSkill = possibleSkills[idx];
experienceChanged.setSkill(updatedSkill);
eventBus.post(experienceChanged);
}
}
Aggregations