diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java index 0531d89ebf..1293407c5e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java @@ -44,6 +44,8 @@ import javax.swing.JLabel; import javax.swing.JPanel; import net.runelite.api.Client; import net.runelite.api.Experience; +import net.runelite.api.Skill; +import net.runelite.api.VarPlayer; import net.runelite.client.game.ItemManager; import net.runelite.client.game.SpriteManager; import net.runelite.client.plugins.skillcalculator.beans.SkillData; @@ -133,8 +135,18 @@ class SkillCalculator extends JPanel // Update internal skill/XP values. currentXP = client.getSkillExperience(calculatorType.getSkill()); currentLevel = Experience.getLevelForXp(currentXP); - targetLevel = enforceSkillBounds(currentLevel + 1); - targetXP = Experience.getXpForLevel(targetLevel); + VarPlayer endGoalVarp = endGoalVarpForSkill(calculatorType.getSkill()); + int endGoal = client.getVar(endGoalVarp); + if (endGoal != -1) + { + targetLevel = Experience.getLevelForXp(endGoal); + targetXP = endGoal; + } + else + { + targetLevel = enforceSkillBounds(currentLevel + 1); + targetXP = Experience.getXpForLevel(targetLevel); + } // Remove all components (action slots) from this panel. removeAll(); @@ -457,4 +469,59 @@ class SkillCalculator extends JPanel } }; } + + private static VarPlayer endGoalVarpForSkill(final Skill skill) + { + switch (skill) + { + case ATTACK: + return VarPlayer.ATTACK_GOAL_END; + case MINING: + return VarPlayer.MINING_GOAL_END; + case WOODCUTTING: + return VarPlayer.WOODCUTTING_GOAL_END; + case DEFENCE: + return VarPlayer.DEFENCE_GOAL_END; + case MAGIC: + return VarPlayer.MAGIC_GOAL_END; + case RANGED: + return VarPlayer.RANGED_GOAL_END; + case HITPOINTS: + return VarPlayer.HITPOINTS_GOAL_END; + case AGILITY: + return VarPlayer.AGILITY_GOAL_END; + case STRENGTH: + return VarPlayer.STRENGTH_GOAL_END; + case PRAYER: + return VarPlayer.PRAYER_GOAL_END; + case SLAYER: + return VarPlayer.SLAYER_GOAL_END; + case FISHING: + return VarPlayer.FISHING_GOAL_END; + case RUNECRAFT: + return VarPlayer.RUNECRAFT_GOAL_END; + case HERBLORE: + return VarPlayer.HERBLORE_GOAL_END; + case FIREMAKING: + return VarPlayer.FIREMAKING_GOAL_END; + case CONSTRUCTION: + return VarPlayer.CONSTRUCTION_GOAL_END; + case HUNTER: + return VarPlayer.HUNTER_GOAL_END; + case COOKING: + return VarPlayer.COOKING_GOAL_END; + case FARMING: + return VarPlayer.FARMING_GOAL_END; + case CRAFTING: + return VarPlayer.CRAFTING_GOAL_END; + case SMITHING: + return VarPlayer.SMITHING_GOAL_END; + case THIEVING: + return VarPlayer.THIEVING_GOAL_END; + case FLETCHING: + return VarPlayer.FLETCHING_GOAL_END; + default: + throw new IllegalArgumentException(); + } + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java index a9b0e668d8..292e138d95 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperPlugin.java @@ -172,6 +172,8 @@ public class WorldHopperPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private int currentPing; + private final Map storedPings = new HashMap<>(); + private final HotkeyListener previousKeyListener = new HotkeyListener(() -> this.previousKey) { @Override @@ -778,7 +780,7 @@ public class WorldHopperPlugin extends Plugin for (World world : worldResult.getWorlds()) { - int ping = Ping.ping(world); + int ping = ping(world); SwingUtilities.invokeLater(() -> panel.updatePing(world.getId(), ping)); } @@ -834,7 +836,7 @@ public class WorldHopperPlugin extends Plugin return; } - int ping = Ping.ping(world); + int ping = ping(world); log.trace("Ping for world {} is: {}", world.getId(), ping); SwingUtilities.invokeLater(() -> panel.updatePing(world.getId(), ping)); } @@ -858,9 +860,26 @@ public class WorldHopperPlugin extends Plugin return; } - currentPing = Ping.ping(currentWorld); + currentPing = ping(currentWorld); log.trace("Ping for current world is: {}", currentPing); SwingUtilities.invokeLater(() -> panel.updatePing(currentWorld.getId(), currentPing)); } + + Integer getStoredPing(World world) + { + if (!this.ping) + { + return null; + } + + return storedPings.get(world.getId()); + } + + private int ping(World world) + { + int ping = Ping.ping(world); + storedPings.put(world.getId(), ping); + return ping; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java index ce7839226a..28e5d58d70 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java @@ -378,7 +378,7 @@ class WorldSwitcherPanel extends PluginPanel */ private WorldTableRow buildRow(World world, boolean stripe, boolean current, boolean favorite) { - WorldTableRow row = new WorldTableRow(world, current, favorite, + WorldTableRow row = new WorldTableRow(world, current, favorite, plugin.getStoredPing(world), plugin::hopTo, (world12, add) -> { @@ -408,4 +408,4 @@ class WorldSwitcherPanel extends PluginPanel ACTIVITY, PING } -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java index f1e8dad612..8b45a44549 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java @@ -92,7 +92,7 @@ class WorldTableRow extends JPanel private Color lastBackground; - WorldTableRow(World world, boolean current, boolean favorite, Consumer onSelect, BiConsumer onFavorite) + WorldTableRow(World world, boolean current, boolean favorite, Integer ping, Consumer onSelect, BiConsumer onFavorite) { this.world = world; this.onFavorite = onFavorite; @@ -164,7 +164,7 @@ class WorldTableRow extends JPanel worldField.setPreferredSize(new Dimension(WORLD_COLUMN_WIDTH, 0)); worldField.setOpaque(false); - JPanel pingField = buildPingField(); + JPanel pingField = buildPingField(ping); pingField.setPreferredSize(new Dimension(PING_COLUMN_WIDTH, 0)); pingField.setOpaque(false); @@ -280,7 +280,7 @@ class WorldTableRow extends JPanel return column; } - private JPanel buildPingField() + private JPanel buildPingField(Integer ping) { JPanel column = new JPanel(new BorderLayout()); column.setBorder(new EmptyBorder(0, 5, 0, 5)); @@ -290,6 +290,11 @@ class WorldTableRow extends JPanel column.add(pingField, BorderLayout.EAST); + if (ping != null) + { + setPing(ping); + } + return column; } @@ -341,4 +346,4 @@ class WorldTableRow extends JPanel return FLAG_GER; } } -} +} \ No newline at end of file