net.runelite.api.Skill Java Examples

The following examples show how to use net.runelite.api.Skill. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XpTrackerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Reset internal state and re-initialize all skills with XP currently cached by the RS client
 * This is called by the user manually clicking resetSkillState in the UI.
 * It reloads the current skills from the client after resetting internal state.
 */
void resetAndInitState()
{
	resetState();

	for (Skill skill : Skill.values())
	{
		long currentXp;
		if (skill == Skill.OVERALL)
		{
			currentXp = client.getOverallExperience();
		}
		else
		{
			currentXp = client.getSkillExperience(skill);
		}

		xpState.initializeSkill(skill, currentXp);
		removeOverlay(skill);
	}
}
 
Example #2
Source File: HitPointsRenderer.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void update(Client client, StatusBarsOverlay overlay)
{
	maximumValue = client.getRealSkillLevel(Skill.HITPOINTS);
	currentValue = client.getBoostedSkillLevel(Skill.HITPOINTS);
	restore = overlay.getRestoreValue(Skill.HITPOINTS.getName());

	final int poisonState = client.getVar(VarPlayer.IS_POISONED);

	if (poisonState > 0 && poisonState < 50)
	{
		standardColor = COLOR_POISON;
	}
	else if (poisonState >= 1000000)
	{
		standardColor = COLOR_VENOM;
	}
	else
	{
		standardColor = COLOR_STANDARD;
	}
}
 
Example #3
Source File: Hooks.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Subscribe
public void onScriptCallbackEvent(ScriptCallbackEvent scriptCallbackEvent)
{
	if (!scriptCallbackEvent.getEventName().equals("fakeXpDrop"))
	{
		return;
	}

	final int[] intStack = client.getIntStack();
	final int intStackSize = client.getIntStackSize();

	final int statId = intStack[intStackSize - 2];
	final int xp = intStack[intStackSize - 1];

	Skill skill = Skill.values()[statId];
	FakeXpDrop fakeXpDrop = new FakeXpDrop(
		skill,
		xp
	);
	eventBus.post(fakeXpDrop);
}
 
Example #4
Source File: XpPanel.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
static String buildXpTrackerUrl(final Actor player, final Skill skill)
{
	if (player == null)
	{
		return "";
	}

	return new HttpUrl.Builder()
		.scheme("https")
		.host("runelite.net")
		.addPathSegment("xp")
		.addPathSegment("show")
		.addPathSegment(skill.getName().toLowerCase())
		.addPathSegment(player.getName())
		.addPathSegment("1week")
		.addPathSegment("now")
		.build()
		.toString();
}
 
Example #5
Source File: PortalWeaknessOverlay.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Inject
PortalWeaknessOverlay(
	final PestControlPlugin plugin,
	final Client client,
	final ItemManager itemManager,
	final SkillIconManager skillIconManager
)
{
	this.plugin = plugin;
	this.client = client;

	this.magicImage = skillIconManager.getSkillImage(Skill.MAGIC);
	this.rangedImage = skillIconManager.getSkillImage(Skill.RANGED);

	this.stabImage = itemManager.getImage(ItemID.WHITE_DAGGER);
	this.slashImage = itemManager.getImage(ItemID.WHITE_SCIMITAR);
	this.crushImage = itemManager.getImage(ItemID.WHITE_WARHAMMER);

	setPosition(OverlayPosition.DYNAMIC);
	setLayer(OverlayLayer.UNDER_WIDGETS);
}
 
Example #6
Source File: CombatLevelPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onGameTick(GameTick event)
{
	if (client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}

	Widget combatLevelWidget = client.getWidget(WidgetInfo.COMBAT_LEVEL);
	if (combatLevelWidget == null || !config.showPreciseCombatLevel())
	{
		return;
	}

	double combatLevelPrecise = Experience.getCombatLevelPrecise(
		client.getRealSkillLevel(Skill.ATTACK),
		client.getRealSkillLevel(Skill.STRENGTH),
		client.getRealSkillLevel(Skill.DEFENCE),
		client.getRealSkillLevel(Skill.HITPOINTS),
		client.getRealSkillLevel(Skill.MAGIC),
		client.getRealSkillLevel(Skill.RANGED),
		client.getRealSkillLevel(Skill.PRAYER)
	);

	combatLevelWidget.setText("Combat Lvl: " + DECIMAL_FORMAT.format(combatLevelPrecise));
}
 
Example #7
Source File: BoostsPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void startUp()
{
	overlayManager.add(boostsOverlay);
	overlayManager.add(combatIconsOverlay);
	updateShownSkills();
	Arrays.fill(lastSkillLevels, -1);

	// Add infoboxes for everything at startup and then determine inside if it will be rendered
	infoBoxManager.addInfoBox(new StatChangeIndicator(true, ImageUtil.getResourceStreamFromClass(getClass(), "debuffed.png"), this, config));
	infoBoxManager.addInfoBox(new StatChangeIndicator(false, ImageUtil.getResourceStreamFromClass(getClass(), "buffed.png"), this, config));

	for (final Skill skill : Skill.values())
	{
		if (skill != Skill.OVERALL)
		{
			infoBoxManager.addInfoBox(new BoostIndicator(skill, skillIconManager.getSkillImage(skill), this, config, client));
		}
	}
}
 
Example #8
Source File: TearsOfGuthixPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
private Skill getLowestPlayerSkill()
{
	final Skill[] playerSkills = Skill.values();
	Skill lowestExperienceSkill = null;
	int lowestExperienceAmount = Integer.MAX_VALUE;

	for (Skill skill : playerSkills)
	{
		int currentSkillExp = client.getSkillExperience(skill);

		if (currentSkillExp < lowestExperienceAmount)
		{
			lowestExperienceAmount = currentSkillExp;
			lowestExperienceSkill = skill;
		}
	}

	return lowestExperienceSkill;
}
 
Example #9
Source File: PartyPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onUserSync(final UserSync event)
{
	final int currentHealth = client.getBoostedSkillLevel(Skill.HITPOINTS);
	final int currentPrayer = client.getBoostedSkillLevel(Skill.PRAYER);
	final int realHealth = client.getRealSkillLevel(Skill.HITPOINTS);
	final int realPrayer = client.getRealSkillLevel(Skill.PRAYER);
	final PartyMember localMember = party.getLocalMember();

	if (localMember != null)
	{
		final SkillUpdate hpUpdate = new SkillUpdate(Skill.HITPOINTS, currentHealth, realHealth);
		hpUpdate.setMemberId(localMember.getMemberId());
		ws.send(hpUpdate);

		final SkillUpdate prayUpdate = new SkillUpdate(Skill.PRAYER, currentPrayer, realPrayer);
		prayUpdate.setMemberId(localMember.getMemberId());
		ws.send(prayUpdate);
	}
}
 
Example #10
Source File: TimersPlugin.java    From plugins with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
private void onStatChanged(StatChanged event)
{
	Skill skill = event.getSkill();

	if (skill != Skill.MAGIC || !config.showImbuedHeart() || !imbuedHeartClicked)
	{
		return;
	}

	int magicLvl = client.getRealSkillLevel(skill);
	int magicBoost = client.getBoostedSkillLevel(skill);
	int heartBoost = 1 + (int) (magicLvl * 0.1);

	if (magicBoost - magicLvl != heartBoost)
	{
		return;
	}

	imbuedHeartClicked = false;
	createGameTimer(IMBUEDHEART);
}
 
Example #11
Source File: AttackStylesPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void resetWarnings()
{
	updateWarnedSkills(config.warnForAttack(), Skill.ATTACK);
	updateWarnedSkills(config.warnForStrength(), Skill.STRENGTH);
	updateWarnedSkills(config.warnForDefence(), Skill.DEFENCE);
	updateWarnedSkills(config.warnForRanged(), Skill.RANGED);
	updateWarnedSkills(config.warnForMagic(), Skill.MAGIC);
}
 
Example #12
Source File: XpTrackerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void rebuildSkills()
{
	// Rebuild calculated values like xp/hr in panel
	for (Skill skill : Skill.values())
	{
		xpPanel.updateSkillExperience(false, xpPauseState.isPaused(skill), skill, xpState.getSkillSnapshot(skill));
	}

	xpPanel.updateTotal(xpState.getTotalSnapshot());
}
 
Example #13
Source File: AttackStylesPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void resetWarnings()
{
	updateWarnedSkills(config.warnForAttack(), Skill.ATTACK);
	updateWarnedSkills(config.warnForStrength(), Skill.STRENGTH);
	updateWarnedSkills(config.warnForDefence(), Skill.DEFENCE);
	updateWarnedSkills(config.warnForRanged(), Skill.RANGED);
	updateWarnedSkills(config.warnForMagic(), Skill.MAGIC);
}
 
Example #14
Source File: XpTrackerPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
void pauseAllSkills(boolean pause)
{
	for (Skill skill : Skill.values())
	{
		pauseSkill(skill, pause);
	}
}
 
Example #15
Source File: XpTrackerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Reset an individual skill with the client's current known state of the skill
 * Will also clear the skill from the UI.
 * @param skill Skill to reset
 */
void resetSkillState(Skill skill)
{
	int currentXp = client.getSkillExperience(skill);
	xpState.resetSkill(skill, currentXp);
	xpPanel.resetSkill(skill);
	removeOverlay(skill);
}
 
Example #16
Source File: BoostsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void updateBoostedStats()
{
	// Reset is boosted
	isChangedDown = false;
	isChangedUp = false;
	skillsToDisplay.clear();

	// Check if we are still boosted
	for (final Skill skill : Skill.values())
	{
		if (!shownSkills.contains(skill))
		{
			continue;
		}

		final int boosted = client.getBoostedSkillLevel(skill);
		final int base = client.getRealSkillLevel(skill);

		if (boosted > base)
		{
			isChangedUp = true;
		}
		else if (boosted < base)
		{
			isChangedDown = true;
		}

		if (boosted != base)
		{
			skillsToDisplay.add(skill);
		}
	}
}
 
Example #17
Source File: XpTrackerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Reset all skills except for the one provided
 * @param skill Skill to ignore during reset
 */
void resetOtherSkillState(Skill skill)
{
	for (Skill s : Skill.values())
	{
		// Overall is not reset from resetting individual skills
		if (skill != s && s != Skill.OVERALL)
		{
			resetSkillState(s);
		}
	}
}
 
Example #18
Source File: AutoClick.java    From ExternalPlugins with GNU General Public License v3.0 5 votes vote down vote up
private boolean checkHitpoints()
{
	if (!config.autoDisableHp())
	{
		return false;
	}
	return client.getBoostedSkillLevel(Skill.HITPOINTS) <= config.hpThreshold();
}
 
Example #19
Source File: MotherlodeRocksOverlay.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Inject
MotherlodeRocksOverlay(Client client, MotherlodePlugin plugin, MotherlodeConfig config, SkillIconManager iconManager)
{
	setPosition(OverlayPosition.DYNAMIC);
	setLayer(OverlayLayer.ABOVE_SCENE);
	this.client = client;
	this.plugin = plugin;
	this.config = config;

	miningIcon = iconManager.getSkillImage(Skill.MINING);
}
 
Example #20
Source File: VirtualLevelsPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void simulateSkillChange()
{
	// this fires widgets listening for all skill changes
	for (Skill skill : Skill.values())
	{
		if (skill != Skill.OVERALL)
		{
			client.queueChangedSkill(skill);
		}
	}
}
 
Example #21
Source File: XpTrackerPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Reset all skills except for the one provided
 *
 * @param skill Skill to ignore during reset
 */
void resetOtherSkillState(Skill skill)
{
	for (Skill s : Skill.values())
	{
		// Overall is not reset from resetting individual skills
		if (skill != s && s != Skill.OVERALL)
		{
			resetSkillState(s);
		}
	}
}
 
Example #22
Source File: AttackStylesPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(AttackStyle.ACCURATE.ordinal());

	// verify that earning xp in a warned skill will display red text on the widget
	attackPlugin.onVarbitChanged(new VarbitChanged());
	assertTrue(attackPlugin.isWarnedSkillSelected());

	// Switch to attack style that doesn't give attack xp
	when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(AttackStyle.AGGRESSIVE.ordinal());

	// Verify the widget will now display white text
	attackPlugin.onVarbitChanged(new VarbitChanged());
	warnedSkills = attackPlugin.getWarnedSkills();
	assertTrue(warnedSkills.contains(Skill.ATTACK));
	assertFalse(attackPlugin.isWarnedSkillSelected());
}
 
Example #23
Source File: VirtualLevelsPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private void initializePreviousXpMap()
{
	if (client.getGameState() != GameState.LOGGED_IN)
	{
		previousXpMap.clear();
	}
	else
	{
		for (final Skill skill : Skill.values())
		{
			previousXpMap.put(skill, client.getSkillExperience(skill));
		}
	}
}
 
Example #24
Source File: CookingOverlay.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Dimension render(Graphics2D graphics)
{
	CookingSession session = plugin.getSession();
	if (session == null)
	{
		return null;
	}

	if (isCooking() || Duration.between(session.getLastCookingAction(), Instant.now()).getSeconds() < COOK_TIMEOUT)
	{
		panelComponent.getChildren().add(TitleComponent.builder()
			.text("Cooking")
			.color(Color.GREEN)
			.build());
	}
	else
	{
		panelComponent.getChildren().add(TitleComponent.builder()
			.text("NOT cooking")
			.color(Color.RED)
			.build());
	}

	TableComponent tableComponent = new TableComponent();
	tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);
	tableComponent.addRow("Cooked:", session.getCookAmount() + (session.getCookAmount() >= 1 ? " (" + xpTrackerService.getActionsHr(Skill.COOKING) + "/hr)" : ""));
	tableComponent.addRow("Burnt:", session.getBurnAmount() + (session.getBurnAmount() >= 1 ? " (" + FORMAT.format(session.getBurntPercentage()) + "%)" : ""));

	panelComponent.getChildren().add(tableComponent);

	return super.render(graphics);
}
 
Example #25
Source File: SlayerPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testCorrectlyCapturedTaskKill()
{
	final Player player = mock(Player.class);
	when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
	when(client.getLocalPlayer()).thenReturn(player);

	StatChanged statChanged = new StatChanged(
		Skill.SLAYER,
		100,
		2,
		2
	);
	slayerPlugin.onStatChanged(statChanged);

	slayerPlugin.setTaskName("Dagannoth");
	slayerPlugin.setAmount(143);

	statChanged = new StatChanged(
		Skill.SLAYER,
		110,
		2,
		2
	);
	slayerPlugin.onStatChanged(statChanged);

	assertEquals(142, slayerPlugin.getAmount());
}
 
Example #26
Source File: XpGlobesPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onStatChanged(StatChanged statChanged)
{
	Skill skill = statChanged.getSkill();
	int currentXp = statChanged.getXp();
	int currentLevel = statChanged.getLevel();
	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;
	}

	if (config.hideMaxed() && currentLevel >= Experience.MAX_REAL_LEVEL)
	{
		return;
	}

	if (cachedGlobe != null)
	{
		cachedGlobe.setSkill(skill);
		cachedGlobe.setCurrentXp(currentXp);
		cachedGlobe.setCurrentLevel(currentLevel);
		cachedGlobe.setTime(Instant.now());
		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, Instant.now());
	}
}
 
Example #27
Source File: XpTrackerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
void pauseSkill(Skill skill, boolean pause)
{
	if (pause ? xpPauseState.pauseSkill(skill) : xpPauseState.unpauseSkill(skill))
	{
		xpPanel.updateSkillExperience(false, xpPauseState.isPaused(skill), skill, xpState.getSkillSnapshot(skill));
	}
}
 
Example #28
Source File: XpState.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
private double getCombatXPModifier(Skill skill)
{
	if (skill == Skill.HITPOINTS)
	{
		return SHARED_XP_MODIFIER;
	}

	return DEFAULT_XP_MODIFIER;
}
 
Example #29
Source File: SlayerPluginTest.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testJadTaskKill()
{
	final Player player = mock(Player.class);
	when(player.getLocalLocation()).thenReturn(new LocalPoint(0, 0));
	when(client.getLocalPlayer()).thenReturn(player);

	StatChanged statChanged = new StatChanged(
		Skill.SLAYER,
		100,
		2,
		2
	);
	slayerPlugin.onStatChanged(statChanged);

	slayerPlugin.setTaskName("TzTok-Jad");
	slayerPlugin.setAmount(1);

	// One bat kill
	statChanged = new StatChanged(
		Skill.SLAYER,
		110,
		2,
		2
	);
	slayerPlugin.onStatChanged(statChanged);

	assertEquals(1, slayerPlugin.getAmount());

	// One Jad kill
	statChanged = new StatChanged(
		Skill.SLAYER,
		25360,
		-1,
		-1
	);
	slayerPlugin.onStatChanged(statChanged);

	assertEquals(0, slayerPlugin.getAmount());
}
 
Example #30
Source File: AttackStylesPluginTest.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@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.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(AttackStyle.ACCURATE.ordinal());

	// verify that earning xp in a warned skill will display red text on the widget
	attackPlugin.onVarbitChanged(new VarbitChanged());
	assertTrue(attackPlugin.isWarnedSkillSelected());

	// Switch to attack style that doesn't give attack xp
	when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(AttackStyle.AGGRESSIVE.ordinal());

	// Verify the widget will now display white text
	attackPlugin.onVarbitChanged(new VarbitChanged());
	warnedSkills = attackPlugin.getWarnedSkills();
	assertTrue(warnedSkills.contains(Skill.ATTACK));
	assertFalse(attackPlugin.isWarnedSkillSelected());
}