diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java index 655d0245a8..dca84c32a0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityConfig.java @@ -98,11 +98,22 @@ public interface AgilityConfig extends Config return true; } + @ConfigItem( + keyName = "addLevelsToShortcutOptions", + name = "Show shortcut agility req. in options", + description = "Enable/disable showing shortcut agility level requirements in right-click options", + position = 7 + ) + default boolean showShortcutLevel() + { + return true; + } + @ConfigItem( keyName = "trapOverlay", name = "Show Trap Overlay", description = "Enable/disable the highlighting of traps on Agility courses", - position = 7 + position = 8 ) default boolean showTrapOverlay() { @@ -113,7 +124,7 @@ public interface AgilityConfig extends Config keyName = "trapHighlight", name = "Trap Overlay Color", description = "Color of Agility trap overlay", - position = 8 + position = 9 ) default Color getTrapColor() { @@ -124,7 +135,7 @@ public interface AgilityConfig extends Config keyName = "agilityArenaNotifier", name = "Agility Arena notifier", description = "Notify on ticket location change in Agility Arena", - position = 9 + position = 10 ) default boolean notifyAgilityArena() { @@ -135,7 +146,7 @@ public interface AgilityConfig extends Config keyName = "agilityArenaTimer", name = "Agility Arena timer", description = "Configures whether Agility Arena timer is displayed", - position = 10 + position = 11 ) default boolean showAgilityArenaTimer() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java index c895a07980..f67b19925a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java @@ -59,6 +59,7 @@ import net.runelite.api.events.GroundObjectDespawned; import net.runelite.api.events.GroundObjectSpawned; import net.runelite.api.events.ItemDespawned; import net.runelite.api.events.ItemSpawned; +import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.WallObjectChanged; import net.runelite.api.events.WallObjectDespawned; import net.runelite.api.events.WallObjectSpawned; @@ -71,6 +72,10 @@ import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.ui.overlay.infobox.InfoBoxManager; +import net.runelite.api.MenuEntry; +import net.runelite.client.util.ColorUtil; +import net.runelite.api.MenuAction; +import java.awt.Color; @PluginDescriptor( name = "Agility", @@ -421,4 +426,38 @@ public class AgilityPlugin extends Plugin } } } + + @Subscribe + public void onMenuEntryAdded(MenuEntryAdded event) + { + if (!config.showShortcutLevel()) + { + return; + } + + //Guarding against non-first option because agility shortcuts are always that type of event. + if (event.getType() != MenuAction.GAME_OBJECT_FIRST_OPTION.getId()) + { + return; + } + + final int entryId = event.getIdentifier(); + MenuEntry[] menuEntries = client.getMenuEntries(); + + for (Obstacle nearbyObstacle : getObstacles().values()) + { + AgilityShortcut shortcut = nearbyObstacle.getShortcut(); + if (Arrays.stream(shortcut.getObstacleIds()).anyMatch(i -> i == entryId)) + { + MenuEntry entry = menuEntries[menuEntries.length - 1]; + int level = shortcut.getLevel(); + Color color = level <= getAgilityLevel() ? Color.GREEN : Color.RED; + String requirementText = " (level-" + level + ")"; + + entry.setTarget(event.getTarget() + ColorUtil.prependColorTag(requirementText, color)); + client.setMenuEntries(menuEntries); + return; + } + } + } }