Fix WorldMapPlugin
- Make fairy ring tooltips and icons work without each other - Make agility tooltips and icons work without each other - Make plugin work correctly during restarts Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -26,19 +26,17 @@
|
|||||||
package net.runelite.client.plugins.worldmap;
|
package net.runelite.client.plugins.worldmap;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import lombok.Getter;
|
|
||||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
||||||
|
|
||||||
public class AgilityShortcutPoint extends WorldMapPoint
|
class AgilityShortcutPoint extends WorldMapPoint
|
||||||
{
|
{
|
||||||
@Getter
|
AgilityShortcutPoint(AgilityShortcutLocation data, BufferedImage icon, boolean showTooltip)
|
||||||
private AgilityShortcutLocation data;
|
|
||||||
|
|
||||||
AgilityShortcutPoint(AgilityShortcutLocation data, BufferedImage icon)
|
|
||||||
{
|
{
|
||||||
super(data.getLocation(), icon);
|
super(data.getLocation(), icon);
|
||||||
|
|
||||||
this.data = data;
|
if (showTooltip)
|
||||||
setTooltip(data.getTooltip());
|
{
|
||||||
|
setTooltip(data.getTooltip());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.worldmap;
|
package net.runelite.client.plugins.worldmap;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
|
|
||||||
@@ -72,20 +71,10 @@ enum FairyRingLocation
|
|||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
private final WorldPoint location;
|
private final WorldPoint location;
|
||||||
private final FairyRingPoint fairyRingPoint;
|
|
||||||
|
|
||||||
FairyRingLocation(String code, WorldPoint location)
|
FairyRingLocation(String code, WorldPoint location)
|
||||||
{
|
{
|
||||||
this.code = code;
|
this.code = code;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.fairyRingPoint = new FairyRingPoint(code, location);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setIcon(BufferedImage image)
|
|
||||||
{
|
|
||||||
for (FairyRingLocation fairyRingLocation : values())
|
|
||||||
{
|
|
||||||
fairyRingLocation.fairyRingPoint.setImage(image);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,15 +25,18 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.worldmap;
|
package net.runelite.client.plugins.worldmap;
|
||||||
|
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import java.awt.image.BufferedImage;
|
||||||
import static net.runelite.client.plugins.worldmap.WorldMapPlugin.BLANK_ICON;
|
|
||||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
||||||
|
|
||||||
class FairyRingPoint extends WorldMapPoint
|
class FairyRingPoint extends WorldMapPoint
|
||||||
{
|
{
|
||||||
FairyRingPoint(String tooltip, WorldPoint worldPoint)
|
FairyRingPoint(FairyRingLocation data, BufferedImage icon, boolean showTooltip)
|
||||||
{
|
{
|
||||||
super(worldPoint, BLANK_ICON);
|
super(data.getLocation(), icon);
|
||||||
setTooltip("Fairy Ring - " + tooltip);
|
|
||||||
|
if (showTooltip)
|
||||||
|
{
|
||||||
|
setTooltip("Fairy Ring - " + data.getCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,22 +25,15 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.worldmap;
|
package net.runelite.client.plugins.worldmap;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
import net.runelite.client.ui.overlay.worldmap.WorldMapPoint;
|
||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
|
|
||||||
class TeleportPoint extends WorldMapPoint
|
class TeleportPoint extends WorldMapPoint
|
||||||
{
|
{
|
||||||
@Getter
|
|
||||||
private final TeleportLocationData data;
|
|
||||||
|
|
||||||
TeleportPoint(TeleportLocationData data)
|
TeleportPoint(TeleportLocationData data)
|
||||||
{
|
{
|
||||||
super(data.getLocation(), WorldMapPlugin.BLANK_ICON);
|
super(data.getLocation(), WorldMapPlugin.BLANK_ICON);
|
||||||
|
|
||||||
this.data = data;
|
|
||||||
setTooltip(data.getTooltip());
|
setTooltip(data.getTooltip());
|
||||||
|
|
||||||
setImage(ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, data.getIconPath()));
|
setImage(ImageUtil.getResourceStreamFromClass(WorldMapPlugin.class, data.getIconPath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ import net.runelite.client.util.ImageUtil;
|
|||||||
public class WorldMapPlugin extends Plugin
|
public class WorldMapPlugin extends Plugin
|
||||||
{
|
{
|
||||||
static final BufferedImage BLANK_ICON;
|
static final BufferedImage BLANK_ICON;
|
||||||
static final BufferedImage FAIRY_TRAVEL_ICON;
|
private static final BufferedImage FAIRY_TRAVEL_ICON;
|
||||||
static final BufferedImage NOPE_ICON;
|
private static final BufferedImage NOPE_ICON;
|
||||||
|
|
||||||
static final String CONFIG_KEY = "worldmap";
|
static final String CONFIG_KEY = "worldmap";
|
||||||
static final String CONFIG_KEY_FAIRY_RING_TOOLTIPS = "fairyRingTooltips";
|
static final String CONFIG_KEY_FAIRY_RING_TOOLTIPS = "fairyRingTooltips";
|
||||||
@@ -100,120 +100,11 @@ public class WorldMapPlugin extends Plugin
|
|||||||
return configManager.getConfig(WorldMapConfig.class);
|
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
|
@Override
|
||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
FairyRingLocation.setIcon(config.fairyRingIcon() ? FAIRY_TRAVEL_ICON : BLANK_ICON);
|
agilityLevel = client.getRealSkillLevel(Skill.AGILITY);
|
||||||
|
updateShownIcons();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -224,6 +115,18 @@ public class WorldMapPlugin extends Plugin
|
|||||||
worldMapPointManager.removeIf(QuestStartPoint.class::isInstance);
|
worldMapPointManager.removeIf(QuestStartPoint.class::isInstance);
|
||||||
worldMapPointManager.removeIf(TeleportPoint.class::isInstance);
|
worldMapPointManager.removeIf(TeleportPoint.class::isInstance);
|
||||||
worldMapPointManager.removeIf(MinigamePoint.class::isInstance);
|
worldMapPointManager.removeIf(MinigamePoint.class::isInstance);
|
||||||
|
agilityLevel = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onConfigChanged(ConfigChanged event)
|
||||||
|
{
|
||||||
|
if (!event.getGroup().equals(CONFIG_KEY))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateShownIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -232,20 +135,59 @@ public class WorldMapPlugin extends Plugin
|
|||||||
if (event.getSkill() == Skill.AGILITY)
|
if (event.getSkill() == Skill.AGILITY)
|
||||||
{
|
{
|
||||||
int newAgilityLevel = Experience.getLevelForXp(client.getSkillExperience(Skill.AGILITY));
|
int newAgilityLevel = Experience.getLevelForXp(client.getSkillExperience(Skill.AGILITY));
|
||||||
if (config.agilityShortcutLevelIcon() && newAgilityLevel != agilityLevel)
|
if (newAgilityLevel != agilityLevel)
|
||||||
{
|
{
|
||||||
agilityLevel = newAgilityLevel;
|
agilityLevel = newAgilityLevel;
|
||||||
|
updateAgilityIcons();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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())
|
Arrays.stream(TeleportLocationData.values())
|
||||||
.filter(data ->
|
.filter(data ->
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user