From f09f630c9022186c7f371436f383decc48cb4ece Mon Sep 17 00:00:00 2001 From: WLoumakis Date: Wed, 18 Dec 2019 16:43:00 -0500 Subject: [PATCH 1/2] skill calc: use target level if available Co-authored-by: Adam --- .../skillcalculator/SkillCalculator.java | 71 ++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) 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 5b53380daa..e6410eb712 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; @@ -130,8 +132,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(); @@ -433,4 +445,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(); + } + } } From 56f2829640a3aadeb761e457b0d0349bdd6c4b79 Mon Sep 17 00:00:00 2001 From: 15987632 Date: Thu, 2 Jan 2020 14:30:49 -0500 Subject: [PATCH 2/2] world hopper plugin: make world pings persist across world fetches --- .../worldhopper/WorldHopperPlugin.java | 25 ++++++++++++++++--- .../worldhopper/WorldSwitcherPanel.java | 2 +- .../plugins/worldhopper/WorldTableRow.java | 11 +++++--- 3 files changed, 31 insertions(+), 7 deletions(-) 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 e46ab2ec4c..238338f63b 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 @@ -160,6 +160,8 @@ public class WorldHopperPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private int currentPing; + private final Map storedPings = new HashMap<>(); + private final HotkeyListener previousKeyListener = new HotkeyListener(() -> config.previousKey()) { @Override @@ -754,7 +756,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)); } @@ -795,7 +797,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)); } @@ -819,9 +821,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 (!config.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 a531dabaf4..9f15b8a068 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), world1 -> { plugin.hopTo(world1); 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 31449ff61b..2aea475eb0 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 @@ -91,7 +91,7 @@ class WorldTableRow extends JPanel private Color lastBackground; private boolean current; - 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.current = current; this.world = world; @@ -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); @@ -282,7 +282,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)); @@ -292,6 +292,11 @@ class WorldTableRow extends JPanel column.add(pingField, BorderLayout.EAST); + if (ping != null) + { + setPing(ping); + } + return column; }