Java Code Examples for net.runelite.api.Skill#OVERALL
The following examples show how to use
net.runelite.api.Skill#OVERALL .
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 plugins with GNU General Public License v3.0 | 6 votes |
/** * 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: BoostsPlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@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 3
Source File: XpTrackerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
/** * 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 4
Source File: BoostsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@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 5
Source File: VirtualLevelsPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void simulateSkillChange() { // this fires widgets listening for all skill changes for (Skill skill : Skill.values()) { if (skill != Skill.OVERALL) { client.queueChangedSkill(skill); } } }
Example 6
Source File: XpTrackerPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
/** * 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 7
Source File: VirtualLevelsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private void simulateSkillChange() { // this fires widgets listening for all skill changes for (Skill skill : Skill.values()) { if (skill != Skill.OVERALL) { client.queueChangedSkill(skill); } } }
Example 8
Source File: XpTrackerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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 9
Source File: VirtualLevelsPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
@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 10
Source File: XpPanel.java From plugins with GNU General Public License v3.0 | 4 votes |
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 11
Source File: XpStateSingle.java From plugins with GNU General Public License v3.0 | 4 votes |
boolean update(long currentXp, int goalStartXp, int goalEndXp) { if (startXp == -1) { log.warn("Attempted to update skill state " + skill + " but was not initialized with current xp"); return false; } long originalXp = xpGained + startXp; int actionExp = (int) (currentXp - originalXp); // No experience gained if (actionExp == 0) { return false; } // Update EXPERIENCE action final XpAction action = getXpAction(XpActionType.EXPERIENCE); if (action.isActionsHistoryInitialized()) { action.getActionExps()[action.getActionExpIndex()] = actionExp; } else { // populate all values in our action history array with this first value that we see // so the average value of our action history starts out as this first value we see Arrays.fill(action.getActionExps(), actionExp); action.setActionsHistoryInitialized(true); } action.setActionExpIndex((action.getActionExpIndex() + 1) % action.getActionExps().length); action.setActions(action.getActions() + 1); // Calculate experience gained xpGained = (int) (currentXp - startXp); // Determine XP goals, overall has no goals if (skill != Skill.OVERALL) { if (goalStartXp < 0 || currentXp > goalEndXp) { startLevelExp = Experience.getXpForLevel(Experience.getLevelForXp((int) currentXp)); } else { startLevelExp = goalStartXp; } if (goalEndXp <= 0 || currentXp > goalEndXp) { int currentLevel = Experience.getLevelForXp((int) currentXp); endLevelExp = currentLevel + 1 <= Experience.MAX_VIRT_LEVEL ? Experience.getXpForLevel(currentLevel + 1) : Experience.MAX_SKILL_XP; } else { endLevelExp = goalEndXp; } } return true; }
Example 12
Source File: VirtualLevelsPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@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 13
Source File: XpPanel.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
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 14
Source File: XpStateSingle.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
boolean update(long currentXp, int goalStartXp, int goalEndXp) { if (startXp == -1) { log.warn("Attempted to update skill state " + skill + " but was not initialized with current xp"); return false; } long originalXp = xpGained + startXp; int actionExp = (int) (currentXp - originalXp); // No experience gained if (actionExp == 0) { return false; } // Update EXPERIENCE action final XpAction action = getXpAction(XpActionType.EXPERIENCE); if (action.isActionsHistoryInitialized()) { action.getActionExps()[action.getActionExpIndex()] = actionExp; } else { // populate all values in our action history array with this first value that we see // so the average value of our action history starts out as this first value we see for (int i = 0; i < action.getActionExps().length; i++) { action.getActionExps()[i] = actionExp; } action.setActionsHistoryInitialized(true); } action.setActionExpIndex((action.getActionExpIndex() + 1) % action.getActionExps().length); action.setActions(action.getActions() + 1); // Calculate experience gained xpGained = (int) (currentXp - startXp); // Determine XP goals, overall has no goals if (skill != Skill.OVERALL) { if (goalStartXp < 0 || currentXp > goalEndXp) { startLevelExp = Experience.getXpForLevel(Experience.getLevelForXp((int) currentXp)); } else { startLevelExp = goalStartXp; } if (goalEndXp <= 0 || currentXp > goalEndXp) { int currentLevel = Experience.getLevelForXp((int) currentXp); endLevelExp = currentLevel + 1 <= Experience.MAX_VIRT_LEVEL ? Experience.getXpForLevel(currentLevel + 1) : Experience.MAX_SKILL_XP; } else { endLevelExp = goalEndXp; } } return true; }