@@ -44,6 +44,8 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Experience;
|
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.ItemManager;
|
||||||
import net.runelite.client.game.SpriteManager;
|
import net.runelite.client.game.SpriteManager;
|
||||||
import net.runelite.client.plugins.skillcalculator.beans.SkillData;
|
import net.runelite.client.plugins.skillcalculator.beans.SkillData;
|
||||||
@@ -133,8 +135,18 @@ class SkillCalculator extends JPanel
|
|||||||
// Update internal skill/XP values.
|
// Update internal skill/XP values.
|
||||||
currentXP = client.getSkillExperience(calculatorType.getSkill());
|
currentXP = client.getSkillExperience(calculatorType.getSkill());
|
||||||
currentLevel = Experience.getLevelForXp(currentXP);
|
currentLevel = Experience.getLevelForXp(currentXP);
|
||||||
targetLevel = enforceSkillBounds(currentLevel + 1);
|
VarPlayer endGoalVarp = endGoalVarpForSkill(calculatorType.getSkill());
|
||||||
targetXP = Experience.getXpForLevel(targetLevel);
|
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.
|
// Remove all components (action slots) from this panel.
|
||||||
removeAll();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -172,6 +172,8 @@ public class WorldHopperPlugin extends Plugin
|
|||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private int currentPing;
|
private int currentPing;
|
||||||
|
|
||||||
|
private final Map<Integer, Integer> storedPings = new HashMap<>();
|
||||||
|
|
||||||
private final HotkeyListener previousKeyListener = new HotkeyListener(() -> this.previousKey)
|
private final HotkeyListener previousKeyListener = new HotkeyListener(() -> this.previousKey)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -778,7 +780,7 @@ public class WorldHopperPlugin extends Plugin
|
|||||||
|
|
||||||
for (World world : worldResult.getWorlds())
|
for (World world : worldResult.getWorlds())
|
||||||
{
|
{
|
||||||
int ping = Ping.ping(world);
|
int ping = ping(world);
|
||||||
SwingUtilities.invokeLater(() -> panel.updatePing(world.getId(), ping));
|
SwingUtilities.invokeLater(() -> panel.updatePing(world.getId(), ping));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -834,7 +836,7 @@ public class WorldHopperPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ping = Ping.ping(world);
|
int ping = ping(world);
|
||||||
log.trace("Ping for world {} is: {}", world.getId(), ping);
|
log.trace("Ping for world {} is: {}", world.getId(), ping);
|
||||||
SwingUtilities.invokeLater(() -> panel.updatePing(world.getId(), ping));
|
SwingUtilities.invokeLater(() -> panel.updatePing(world.getId(), ping));
|
||||||
}
|
}
|
||||||
@@ -858,9 +860,26 @@ public class WorldHopperPlugin extends Plugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPing = Ping.ping(currentWorld);
|
currentPing = ping(currentWorld);
|
||||||
log.trace("Ping for current world is: {}", currentPing);
|
log.trace("Ping for current world is: {}", currentPing);
|
||||||
|
|
||||||
SwingUtilities.invokeLater(() -> panel.updatePing(currentWorld.getId(), 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ class WorldSwitcherPanel extends PluginPanel
|
|||||||
*/
|
*/
|
||||||
private WorldTableRow buildRow(World world, boolean stripe, boolean current, boolean favorite)
|
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,
|
plugin::hopTo,
|
||||||
(world12, add) ->
|
(world12, add) ->
|
||||||
{
|
{
|
||||||
@@ -408,4 +408,4 @@ class WorldSwitcherPanel extends PluginPanel
|
|||||||
ACTIVITY,
|
ACTIVITY,
|
||||||
PING
|
PING
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ class WorldTableRow extends JPanel
|
|||||||
|
|
||||||
private Color lastBackground;
|
private Color lastBackground;
|
||||||
|
|
||||||
WorldTableRow(World world, boolean current, boolean favorite, Consumer<World> onSelect, BiConsumer<World, Boolean> onFavorite)
|
WorldTableRow(World world, boolean current, boolean favorite, Integer ping, Consumer<World> onSelect, BiConsumer<World, Boolean> onFavorite)
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.onFavorite = onFavorite;
|
this.onFavorite = onFavorite;
|
||||||
@@ -164,7 +164,7 @@ class WorldTableRow extends JPanel
|
|||||||
worldField.setPreferredSize(new Dimension(WORLD_COLUMN_WIDTH, 0));
|
worldField.setPreferredSize(new Dimension(WORLD_COLUMN_WIDTH, 0));
|
||||||
worldField.setOpaque(false);
|
worldField.setOpaque(false);
|
||||||
|
|
||||||
JPanel pingField = buildPingField();
|
JPanel pingField = buildPingField(ping);
|
||||||
pingField.setPreferredSize(new Dimension(PING_COLUMN_WIDTH, 0));
|
pingField.setPreferredSize(new Dimension(PING_COLUMN_WIDTH, 0));
|
||||||
pingField.setOpaque(false);
|
pingField.setOpaque(false);
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ class WorldTableRow extends JPanel
|
|||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel buildPingField()
|
private JPanel buildPingField(Integer ping)
|
||||||
{
|
{
|
||||||
JPanel column = new JPanel(new BorderLayout());
|
JPanel column = new JPanel(new BorderLayout());
|
||||||
column.setBorder(new EmptyBorder(0, 5, 0, 5));
|
column.setBorder(new EmptyBorder(0, 5, 0, 5));
|
||||||
@@ -290,6 +290,11 @@ class WorldTableRow extends JPanel
|
|||||||
|
|
||||||
column.add(pingField, BorderLayout.EAST);
|
column.add(pingField, BorderLayout.EAST);
|
||||||
|
|
||||||
|
if (ping != null)
|
||||||
|
{
|
||||||
|
setPing(ping);
|
||||||
|
}
|
||||||
|
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,4 +346,4 @@ class WorldTableRow extends JPanel
|
|||||||
return FLAG_GER;
|
return FLAG_GER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user