From 437e99f511ddc6df07670293323f4747734bd37a Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 17 Jun 2017 20:59:33 -0400 Subject: [PATCH] xp globes: remove double call to getSkillImage --- .../client/plugins/xpglobes/XpGlobes.java | 4 +- .../plugins/xpglobes/XpGlobesOverlay.java | 50 +++++++++++-------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobes.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobes.java index d4484323b69..6a1a1523acb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobes.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobes.java @@ -33,10 +33,8 @@ import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.Overlay; -import java.time.Duration; import java.time.Instant; import java.util.ArrayList; -import java.util.Date; import java.util.Iterator; import java.util.List; @@ -71,7 +69,7 @@ public Overlay getOverlay() } @Subscribe - private void onExperienceChanged(ExperienceChanged event) + public void onExperienceChanged(ExperienceChanged event) { if (!config.enabled()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java index 822642f7841..05d62fa1bcc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java @@ -46,11 +46,11 @@ public class XpGlobesOverlay extends Overlay { + private static final Logger logger = LoggerFactory.getLogger(XpGlobesOverlay.class); private final XpGlobes plugin; private final Client client = RuneLite.getClient(); private final XpGlobesConfig config; - private static final Logger logger = LoggerFactory.getLogger(XpGlobesOverlay.class); private static final int DEFAULT_CIRCLE_WIDTH = 40; private static final int DEFAULT_CIRCLE_HEIGHT = 40; @@ -117,20 +117,20 @@ private void renderProgressCircle(Graphics2D graphics, XpGlobe skillToDraw, int drawEllipse(graphics, x, y); drawProgressArc( - graphics, - x, y, - DEFAULT_CIRCLE_WIDTH, DEFAULT_CIRCLE_HEIGHT, - PROGRESS_RADIUS_REMAINDER, radiusToGoalXp, - 5, - DEFAULT_PROGRESS_REMAINDER_ARC_COLOR + graphics, + x, y, + DEFAULT_CIRCLE_WIDTH, DEFAULT_CIRCLE_HEIGHT, + PROGRESS_RADIUS_REMAINDER, radiusToGoalXp, + 5, + DEFAULT_PROGRESS_REMAINDER_ARC_COLOR ); drawProgressArc( - graphics, - x, y, - DEFAULT_CIRCLE_WIDTH, DEFAULT_CIRCLE_HEIGHT, - PROGRESS_RADIUS_START, radiusCurrentXp, - 2, - DEFAULT_PROGRESS_ARC_COLOR); + graphics, + x, y, + DEFAULT_CIRCLE_WIDTH, DEFAULT_CIRCLE_HEIGHT, + PROGRESS_RADIUS_START, radiusCurrentXp, + 2, + DEFAULT_PROGRESS_ARC_COLOR); drawSkillImage(graphics, skillToDraw, x, y); } @@ -140,10 +140,10 @@ private void drawProgressArc(Graphics2D graphics, int x, int y, int w, int h, do graphics.setStroke(new BasicStroke(strokeWidth)); graphics.setColor(color); graphics.draw(new Arc2D.Double( - x, y, - w, h, - radiusStart, radiusEnd, - Arc2D.OPEN)); + x, y, + w, h, + radiusStart, radiusEnd, + Arc2D.OPEN)); } private void drawEllipse(Graphics2D graphics, int x, int y) @@ -157,11 +157,17 @@ private void drawEllipse(Graphics2D graphics, int x, int y) private void drawSkillImage(Graphics2D graphics, XpGlobe xpGlobe, int x, int y) { BufferedImage skillImage = getSkillImage(xpGlobe); + + if (skillImage == null) + { + return; + } + graphics.drawImage( - getSkillImage(xpGlobe), - x + (DEFAULT_CIRCLE_WIDTH / 2) - (skillImage.getWidth() / 2), - y + (DEFAULT_CIRCLE_HEIGHT / 2) - (skillImage.getHeight() / 2), - null + skillImage, + x + (DEFAULT_CIRCLE_WIDTH / 2) - (skillImage.getWidth() / 2), + y + (DEFAULT_CIRCLE_HEIGHT / 2) - (skillImage.getHeight() / 2), + null ); } @@ -174,7 +180,7 @@ private BufferedImage getSkillImage(XpGlobe xpGlobe) { return imgCache[skillIdx]; } - + try { String skillIconPath = "/skill_icons/" + xpGlobe.getSkillName().toLowerCase() + ".png";