diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/AgilityShortcutPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/AgilityShortcutPoint.java index 1035378ba2..74f4673c85 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/AgilityShortcutPoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/AgilityShortcutPoint.java @@ -26,19 +26,17 @@ package net.runelite.client.plugins.worldmap; import java.awt.image.BufferedImage; -import lombok.Getter; import net.runelite.client.ui.overlay.worldmap.WorldMapPoint; -public class AgilityShortcutPoint extends WorldMapPoint +class AgilityShortcutPoint extends WorldMapPoint { - @Getter - private AgilityShortcutLocation data; - - AgilityShortcutPoint(AgilityShortcutLocation data, BufferedImage icon) + AgilityShortcutPoint(AgilityShortcutLocation data, BufferedImage icon, boolean showTooltip) { super(data.getLocation(), icon); - this.data = data; - setTooltip(data.getTooltip()); + if (showTooltip) + { + setTooltip(data.getTooltip()); + } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/FairyRingLocation.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/FairyRingLocation.java index 664d4db0e9..db9284e058 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/FairyRingLocation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/FairyRingLocation.java @@ -25,7 +25,6 @@ */ package net.runelite.client.plugins.worldmap; -import java.awt.image.BufferedImage; import lombok.Getter; import net.runelite.api.coords.WorldPoint; @@ -72,20 +71,10 @@ enum FairyRingLocation private final String code; private final WorldPoint location; - private final FairyRingPoint fairyRingPoint; FairyRingLocation(String code, WorldPoint location) { this.code = code; this.location = location; - this.fairyRingPoint = new FairyRingPoint(code, location); - } - - static void setIcon(BufferedImage image) - { - for (FairyRingLocation fairyRingLocation : values()) - { - fairyRingLocation.fairyRingPoint.setImage(image); - } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/FairyRingPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/FairyRingPoint.java index 3422d9cf0e..ef4e55da92 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/FairyRingPoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/FairyRingPoint.java @@ -25,15 +25,18 @@ */ package net.runelite.client.plugins.worldmap; -import net.runelite.api.coords.WorldPoint; -import static net.runelite.client.plugins.worldmap.WorldMapPlugin.BLANK_ICON; +import java.awt.image.BufferedImage; import net.runelite.client.ui.overlay.worldmap.WorldMapPoint; class FairyRingPoint extends WorldMapPoint { - FairyRingPoint(String tooltip, WorldPoint worldPoint) + FairyRingPoint(FairyRingLocation data, BufferedImage icon, boolean showTooltip) { - super(worldPoint, BLANK_ICON); - setTooltip("Fairy Ring - " + tooltip); + super(data.getLocation(), icon); + + if (showTooltip) + { + setTooltip("Fairy Ring - " + data.getCode()); + } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TeleportPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TeleportPoint.java index 831cda90d1..c8c2a778cb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TeleportPoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/TeleportPoint.java @@ -25,22 +25,15 @@ */ package net.runelite.client.plugins.worldmap; -import lombok.Getter; import net.runelite.client.ui.overlay.worldmap.WorldMapPoint; import net.runelite.client.util.ImageUtil; class TeleportPoint extends WorldMapPoint { - @Getter - private final TeleportLocationData data; - TeleportPoint(TeleportLocationData data) { super(data.getLocation(), WorldMapPlugin.BLANK_ICON); - - this.data = data; setTooltip(data.getTooltip()); - setImage(ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, data.getIconPath())); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java index 03a71d0849..86ed3d0f49 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldmap/WorldMapPlugin.java @@ -49,8 +49,8 @@ import net.runelite.client.util.ImageUtil; public class WorldMapPlugin extends Plugin { static final BufferedImage BLANK_ICON; - static final BufferedImage FAIRY_TRAVEL_ICON; - static final BufferedImage NOPE_ICON; + private static final BufferedImage FAIRY_TRAVEL_ICON; + private static final BufferedImage NOPE_ICON; static final String CONFIG_KEY = "worldmap"; static final String CONFIG_KEY_FAIRY_RING_TOOLTIPS = "fairyRingTooltips"; @@ -100,120 +100,11 @@ public class WorldMapPlugin extends Plugin return configManager.getConfig(WorldMapConfig.class); } - @Subscribe - public void onConfigChanged(ConfigChanged event) - { - if (event.getGroup().equals(CONFIG_KEY)) - { - switch (event.getKey()) - { - case CONFIG_KEY_FAIRY_RING_TOOLTIPS: - if (config.fairyRingTooltips()) - { - Arrays.stream(FairyRingLocation.values()) - .map(FairyRingLocation::getFairyRingPoint) - .forEach(worldMapPointManager::add); - } - else - { - worldMapPointManager.removeIf(FairyRingPoint.class::isInstance); - } - break; - case CONFIG_KEY_FAIRY_RING_ICON: - FairyRingLocation.setIcon(config.fairyRingIcon() ? FAIRY_TRAVEL_ICON : BLANK_ICON); - break; - case CONFIG_KEY_AGILITY_SHORTCUT_TOOLTIPS: - case CONFIG_KEY_AGILITY_SHORTCUT_LEVEL_ICON: - worldMapPointManager.removeIf(AgilityShortcutPoint.class::isInstance); - - if (config.agilityShortcutTooltips()) - { - int agilityLevel = client.getRealSkillLevel(Skill.AGILITY); - - Arrays.stream(AgilityShortcutLocation.values()) - .map(value -> new AgilityShortcutPoint(value, config.agilityShortcutLevelIcon() && value.getLevelReq() > agilityLevel ? NOPE_ICON : BLANK_ICON)) - .forEach(worldMapPointManager::add); - } - break; - case CONFIG_KEY_QUEST_START_TOOLTIPS: - worldMapPointManager.removeIf(QuestStartPoint.class::isInstance); - - if (config.questStartTooltips()) - { - Arrays.stream(QuestStartLocation.values()) - .map(value -> new QuestStartPoint(value, BLANK_ICON)) - .forEach(worldMapPointManager::add); - } - break; - case CONFIG_KEY_MINIGAME_TOOLTIP: - if (config.minigameTooltip()) - { - Arrays.stream(MinigameLocation.values()) - .map(value -> new MinigamePoint(value, BLANK_ICON)) - .forEach(worldMapPointManager::add); - } - else - { - worldMapPointManager.removeIf(MinigamePoint.class::isInstance); - } - break; - case CONFIG_KEY_NORMAL_TELEPORT_ICON: - case CONFIG_KEY_ANCIENT_TELEPORT_ICON: - case CONFIG_KEY_LUNAR_TELEPORT_ICON: - case CONFIG_KEY_ARCEUUS_TELEPORT_ICON: - case CONFIG_KEY_JEWELLERY_TELEPORT_ICON: - case CONFIG_KEY_MISC_TELEPORT_ICON: - case CONFIG_KEY_SCROLL_TELEPORT_ICON: - worldMapPointManager.removeIf(TeleportPoint.class::isInstance); - createMagicTeleportPoints(); - break; - } - } - } - @Override protected void startUp() throws Exception { - FairyRingLocation.setIcon(config.fairyRingIcon() ? FAIRY_TRAVEL_ICON : BLANK_ICON); - - if (config.fairyRingTooltips()) - { - Arrays.stream(FairyRingLocation.values()) - .map(FairyRingLocation::getFairyRingPoint) - .forEach(worldMapPointManager::add); - } - - if (config.agilityShortcutTooltips()) - { - Arrays.stream(AgilityShortcutLocation.values()) - .map(value -> new AgilityShortcutPoint(value, BLANK_ICON)) - .forEach(worldMapPointManager::add); - } - - if (config.questStartTooltips()) - { - Arrays.stream(QuestStartLocation.values()) - .map(value -> new QuestStartPoint(value, BLANK_ICON)) - .forEach(worldMapPointManager::add); - } - - if (config.minigameTooltip()) - { - Arrays.stream(MinigameLocation.values()) - .map(value -> new MinigamePoint(value, BLANK_ICON)) - .forEach(worldMapPointManager::add); - } - - if (config.normalTeleportIcon() - || config.ancientTeleportIcon() - || config.lunarTeleportIcon() - || config.arceuusTeleportIcon() - || config.jewelleryTeleportIcon() - || config.miscellaneousTeleportIcon() - || config.scrollTeleportIcon()) - { - createMagicTeleportPoints(); - } + agilityLevel = client.getRealSkillLevel(Skill.AGILITY); + updateShownIcons(); } @Override @@ -224,6 +115,18 @@ public class WorldMapPlugin extends Plugin worldMapPointManager.removeIf(QuestStartPoint.class::isInstance); worldMapPointManager.removeIf(TeleportPoint.class::isInstance); worldMapPointManager.removeIf(MinigamePoint.class::isInstance); + agilityLevel = 0; + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals(CONFIG_KEY)) + { + return; + } + + updateShownIcons(); } @Subscribe @@ -232,20 +135,59 @@ public class WorldMapPlugin extends Plugin if (event.getSkill() == Skill.AGILITY) { int newAgilityLevel = Experience.getLevelForXp(client.getSkillExperience(Skill.AGILITY)); - if (config.agilityShortcutLevelIcon() && newAgilityLevel != agilityLevel) + if (newAgilityLevel != agilityLevel) { agilityLevel = newAgilityLevel; - - worldMapPointManager.removeIf(AgilityShortcutPoint.class::isInstance); - Arrays.stream(AgilityShortcutLocation.values()) - .map(value -> new AgilityShortcutPoint(value, config.agilityShortcutLevelIcon() && value.getLevelReq() > agilityLevel ? NOPE_ICON : BLANK_ICON)) - .forEach(worldMapPointManager::add); + updateAgilityIcons(); } } } - private void createMagicTeleportPoints() + private void updateAgilityIcons() { + worldMapPointManager.removeIf(AgilityShortcutPoint.class::isInstance); + + if (config.agilityShortcutLevelIcon() || config.agilityShortcutTooltips()) + { + Arrays.stream(AgilityShortcutLocation.values()) + .map(value -> new AgilityShortcutPoint(value, + agilityLevel > 0 && config.agilityShortcutLevelIcon() && value.getLevelReq() > agilityLevel ? NOPE_ICON : BLANK_ICON, + config.agilityShortcutTooltips())) + .forEach(worldMapPointManager::add); + } + } + + private void updateShownIcons() + { + updateAgilityIcons(); + + worldMapPointManager.removeIf(FairyRingPoint.class::isInstance); + if (config.fairyRingIcon() || config.fairyRingTooltips()) + { + Arrays.stream(FairyRingLocation.values()) + .map(value -> new FairyRingPoint(value, + config.fairyRingIcon() ? FAIRY_TRAVEL_ICON : BLANK_ICON, + config.fairyRingTooltips())) + .forEach(worldMapPointManager::add); + } + + worldMapPointManager.removeIf(MinigamePoint.class::isInstance); + if (config.minigameTooltip()) + { + Arrays.stream(MinigameLocation.values()) + .map(value -> new MinigamePoint(value, BLANK_ICON)) + .forEach(worldMapPointManager::add); + } + + worldMapPointManager.removeIf(QuestStartPoint.class::isInstance); + if (config.questStartTooltips()) + { + Arrays.stream(QuestStartLocation.values()) + .map(value -> new QuestStartPoint(value, BLANK_ICON)) + .forEach(worldMapPointManager::add); + } + + worldMapPointManager.removeIf(TeleportPoint.class::isInstance); Arrays.stream(TeleportLocationData.values()) .filter(data -> {