Java Code Examples for net.runelite.api.Skill#values()

The following examples show how to use net.runelite.api.Skill#values() . 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: BoostsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void startUp() throws Exception
{
	overlayManager.add(boostsOverlay);

	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, client, config));
		}
	}
}
 
Example 2
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 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: XpTrackerPlugin.java    From plugins with GNU General Public License v3.0 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 5
Source File: SkillIconManager.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public BufferedImage getSkillImage(Skill skill, boolean small)
{
	int skillIdx = skill.ordinal() + (small ? Skill.values().length : 0);
	BufferedImage skillImage = null;

	if (imgCache[skillIdx] != null)
	{
		return imgCache[skillIdx];
	}

	String skillIconPath = (small ? "/skill_icons_small/" : "/skill_icons/")
		+ skill.getName().toLowerCase() + ".png";
	log.debug("Loading skill icon from {}", skillIconPath);
	skillImage = ImageUtil.getResourceStreamFromClass(getClass(), skillIconPath);
	imgCache[skillIdx] = skillImage;

	return skillImage;
}
 
Example 6
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 7
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 8
Source File: VirtualLevelsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 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 9
Source File: XpTrackerPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
void pauseAllSkills(boolean pause)
{
	for (Skill skill : Skill.values())
	{
		pauseSkill(skill, pause);
	}
}
 
Example 10
Source File: BoostsPlugin.java    From plugins with GNU General Public License v3.0 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 11
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 12
Source File: XpTrackerPlugin.java    From plugins with GNU General Public License v3.0 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: 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 14
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 15
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 16
Source File: XpPanel.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
XpPanel(XpTrackerPlugin xpTrackerPlugin, XpTrackerConfig xpTrackerConfig, Client client, SkillIconManager iconManager)
{
	super();

	setBorder(new EmptyBorder(6, 6, 6, 6));
	setBackground(ColorScheme.DARK_GRAY_COLOR);
	setLayout(new BorderLayout());

	final JPanel layoutPanel = new JPanel();
	BoxLayout boxLayout = new BoxLayout(layoutPanel, BoxLayout.Y_AXIS);
	layoutPanel.setLayout(boxLayout);
	add(layoutPanel, BorderLayout.NORTH);

	overallPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
	overallPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
	overallPanel.setLayout(new BorderLayout());
	overallPanel.setVisible(false); // this will only become visible when the player gets exp

	// Create open xp tracker menu
	final JMenuItem openXpTracker = new JMenuItem("Open online tracker");
	openXpTracker.addActionListener(e -> LinkBrowser.browse(XpPanel.buildXpTrackerUrl(client.getLocalPlayer(), Skill.OVERALL)));

	// Create reset all menu
	final JMenuItem reset = new JMenuItem("Reset All");
	reset.addActionListener(e -> xpTrackerPlugin.resetAndInitState());

	// Create pause all menu
	final JMenuItem pauseAll = new JMenuItem("Pause All");
	pauseAll.addActionListener(e -> xpTrackerPlugin.pauseAllSkills(true));

	// Create unpause all menu
	final JMenuItem unpauseAll = new JMenuItem("Unpause All");
	unpauseAll.addActionListener(e -> xpTrackerPlugin.pauseAllSkills(false));


	// Create popup menu
	final JPopupMenu popupMenu = new JPopupMenu();
	popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5));
	popupMenu.add(openXpTracker);
	popupMenu.add(reset);
	popupMenu.add(pauseAll);
	popupMenu.add(unpauseAll);
	overallPanel.setComponentPopupMenu(popupMenu);

	final JLabel overallIcon = new JLabel(new ImageIcon(iconManager.getSkillImage(Skill.OVERALL)));

	final JPanel overallInfo = new JPanel();
	overallInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
	overallInfo.setLayout(new GridLayout(2, 1));
	overallInfo.setBorder(new EmptyBorder(0, 10, 0, 0));

	overallExpGained.setFont(FontManager.getRunescapeSmallFont());
	overallExpHour.setFont(FontManager.getRunescapeSmallFont());

	overallInfo.add(overallExpGained);
	overallInfo.add(overallExpHour);

	overallPanel.add(overallIcon, BorderLayout.WEST);
	overallPanel.add(overallInfo, BorderLayout.CENTER);


	final JComponent infoBoxPanel = new DragAndDropReorderPane();

	layoutPanel.add(overallPanel);
	layoutPanel.add(infoBoxPanel);

	for (Skill skill : Skill.values())
	{
		if (skill == Skill.OVERALL)
		{
			break;
		}
		infoBoxes.put(skill, new XpInfoBox(xpTrackerPlugin, xpTrackerConfig, client, infoBoxPanel, skill, iconManager));
	}

	errorPanel.setContent("Exp trackers", "You have not gained experience yet.");
	add(errorPanel);
}
 
Example 17
Source File: VirtualLevelsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onScriptCallbackEvent(ScriptCallbackEvent e)
{
	final String eventName = e.getEventName();

	final int[] intStack = client.getIntStack();
	final int intStackSize = client.getIntStackSize();
	final String[] stringStack = client.getStringStack();
	final int stringStackSize = client.getStringStackSize();

	switch (eventName)
	{
		case "skillTabBaseLevel":
			final int skillId = intStack[intStackSize - 2];
			final Skill skill = Skill.values()[skillId];
			final int exp = client.getSkillExperience(skill);

			// alter the local variable containing the level to show
			intStack[intStackSize - 1] = Experience.getLevelForXp(exp);
			break;
		case "skillTabMaxLevel":
			// alter max level constant
			intStack[intStackSize - 1] = Experience.MAX_VIRT_LEVEL;
			break;
		case "skillTabTotalLevel":
			if (!config.virtualTotalLevel())
			{
				break;
			}
			int level = 0;

			for (Skill s : Skill.values())
			{
				if (s == Skill.OVERALL)
				{
					continue;
				}

				level += Experience.getLevelForXp(client.getSkillExperience(s));
			}

			stringStack[stringStackSize - 1] = TOTAL_LEVEL_TEXT_PREFIX + level;
			break;
	}
}
 
Example 18
Source File: XpPanel.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
XpPanel(XpTrackerPlugin xpTrackerPlugin, XpTrackerConfig xpTrackerConfig, Client client, SkillIconManager iconManager)
{
	super();

	setBorder(new EmptyBorder(6, 6, 6, 6));
	setBackground(ColorScheme.DARK_GRAY_COLOR);
	setLayout(new BorderLayout());

	final JPanel layoutPanel = new JPanel();
	BoxLayout boxLayout = new BoxLayout(layoutPanel, BoxLayout.Y_AXIS);
	layoutPanel.setLayout(boxLayout);
	add(layoutPanel, BorderLayout.NORTH);

	overallPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
	overallPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
	overallPanel.setLayout(new BorderLayout());
	overallPanel.setVisible(false); // this will only become visible when the player gets exp

	// Create open xp tracker menu
	final JMenuItem openXpTracker = new JMenuItem("Open online tracker");
	openXpTracker.addActionListener(e -> LinkBrowser.browse(XpPanel.buildXpTrackerUrl(client.getLocalPlayer(), Skill.OVERALL)));

	// Create reset all menu
	final JMenuItem reset = new JMenuItem("Reset All");
	reset.addActionListener(e -> xpTrackerPlugin.resetAndInitState());

	// Create pause all menu
	final JMenuItem pauseAll = new JMenuItem("Pause All");
	pauseAll.addActionListener(e -> xpTrackerPlugin.pauseAllSkills(true));

	// Create unpause all menu
	final JMenuItem unpauseAll = new JMenuItem("Unpause All");
	unpauseAll.addActionListener(e -> xpTrackerPlugin.pauseAllSkills(false));


	// Create popup menu
	final JPopupMenu popupMenu = new JPopupMenu();
	popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5));
	popupMenu.add(openXpTracker);
	popupMenu.add(reset);
	popupMenu.add(pauseAll);
	popupMenu.add(unpauseAll);
	overallPanel.setComponentPopupMenu(popupMenu);

	final JLabel overallIcon = new JLabel(new ImageIcon(iconManager.getSkillImage(Skill.OVERALL)));

	final JPanel overallInfo = new JPanel();
	overallInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
	overallInfo.setLayout(new GridLayout(2, 1));
	overallInfo.setBorder(new EmptyBorder(0, 10, 0, 0));

	overallExpGained.setFont(FontManager.getRunescapeSmallFont());
	overallExpHour.setFont(FontManager.getRunescapeSmallFont());

	overallInfo.add(overallExpGained);
	overallInfo.add(overallExpHour);

	overallPanel.add(overallIcon, BorderLayout.WEST);
	overallPanel.add(overallInfo, BorderLayout.CENTER);

	final JComponent infoBoxPanel = new DragAndDropReorderPane();

	layoutPanel.add(overallPanel);
	layoutPanel.add(infoBoxPanel);

	for (Skill skill : Skill.values())
	{
		if (skill == Skill.OVERALL)
		{
			break;
		}
		infoBoxes.put(skill, new XpInfoBox(xpTrackerPlugin, xpTrackerConfig, client, infoBoxPanel, skill, iconManager));
	}

	errorPanel.setContent("Exp trackers", "You have not gained experience yet.");
	add(errorPanel);
}
 
Example 19
Source File: VirtualLevelsPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onScriptCallbackEvent(ScriptCallbackEvent e)
{
	final String eventName = e.getEventName();

	final int[] intStack = client.getIntStack();
	final int intStackSize = client.getIntStackSize();
	final String[] stringStack = client.getStringStack();
	final int stringStackSize = client.getStringStackSize();

	switch (eventName)
	{
		case "skillTabBaseLevel":
			final int skillId = intStack[intStackSize - 2];
			final Skill skill = Skill.values()[skillId];
			final int exp = client.getSkillExperience(skill);

			// alter the local variable containing the level to show
			intStack[intStackSize - 1] = Experience.getLevelForXp(exp);
			break;
		case "skillTabMaxLevel":
			// alter max level constant
			intStack[intStackSize - 1] = Experience.MAX_VIRT_LEVEL;
			break;
		case "skillTabTotalLevel":
			if (!config.virtualTotalLevel())
			{
				break;
			}
			int level = 0;

			for (Skill s : Skill.values())
			{
				if (s == Skill.OVERALL)
				{
					continue;
				}

				level += Experience.getLevelForXp(client.getSkillExperience(s));
			}

			stringStack[stringStackSize - 1] = TOTAL_LEVEL_TEXT_PREFIX + level;
			break;
	}
}
 
Example 20
Source File: XpGlobesPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void resetGlobeState()
{
	xpGlobes.clear();
	globeCache = new XpGlobe[Skill.values().length - 1];
}