Agility shortcut showlevel (#142)

* Added agility level to agility shortcuts

With this commit, the agility plugin now shows the agility level required to pass shortcuts on hover/right-click/tooltip, with red/green coloring dependent on the players agility level.

* Adjusted code based on feedback

-Useless comments removed

-Now adds colortags using java.awt.color and colorutil

-Adjusted code layout to match style guidelines by moving curly brackets onto newlines and changing one-line if/else's to use brackets

-Removed getLevel function as it's already autogenerated (Whoops!)

-Changed start of plugin to a guard clause and added some other guard clauses for common menu-items

* Update runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java

Removed a newline

Co-Authored-By: PeterMcteague <07mcteaguepet@googlemail.com>

* Updated agility level on tooltip based on feedback

-Swapped * import for specific import (Whoops!)

-Swapped guarad for one that guards against any type that isnt the shortcut type (First option)

* Various changes to agility level plugin based on feedback

-Adjusted phrasing of config to something that was suggested that is far less awkward

-Fixed incorrect position variable (Incremented every one after it, as the position of it next to the other agility shortcut one seems appropriate)

-Removed unnecesary target == null check as suggested

-Modified main function logic to reduce nesting, complexity and number of for loops

* Change to agility level plugin based on feedback

Removed the "level-" already added check because it'd never happen.
This commit is contained in:
James
2019-04-28 12:47:48 -07:00
committed by Tyler Bochard
parent d9a475f309
commit 1bbb2c843b
2 changed files with 54 additions and 4 deletions

View File

@@ -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()
{

View File

@@ -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;
}
}
}
}