player-indicators: don't decorate non-player custom menu options

Splits the RUNELITE menu action into two actions:

RUNELITE -  general menu items.

RUNELITE_PLAYER - menu items which target a player and have its identifier set to a player index.

Then the player indicators plugin is changed to only decorate RUNELITE_PLAYER menu items.
This commit is contained in:
Lotto
2020-05-28 00:11:07 +02:00
committed by Adam
parent 654966c5b3
commit 6518a6a51d
4 changed files with 12 additions and 6 deletions

View File

@@ -272,6 +272,11 @@ public enum MenuAction
* Menu action for configuring runelite overlays.
*/
RUNELITE_OVERLAY_CONFIG(1502),
/**
* Menu action injected by runelite for menu items which target
* a player and have its identifier set to a player index.
*/
RUNELITE_PLAYER(1503),
/**
* Menu action triggered when the id is not defined in this class.

View File

@@ -253,9 +253,10 @@ public class MenuManager
@Subscribe
public void onMenuOptionClicked(MenuOptionClicked event)
{
if (event.getMenuAction() != MenuAction.RUNELITE)
if (event.getMenuAction() != MenuAction.RUNELITE
&& event.getMenuAction() != MenuAction.RUNELITE_PLAYER)
{
return; // not a player menu
return; // not a managed widget option or custom player option
}
int widgetId = event.getWidgetId();
@@ -294,7 +295,7 @@ public class MenuManager
{
client.getPlayerOptions()[playerOptionIndex] = menuText;
client.getPlayerOptionsPriorities()[playerOptionIndex] = true;
client.getPlayerMenuTypes()[playerOptionIndex] = MenuAction.RUNELITE.getId();
client.getPlayerMenuTypes()[playerOptionIndex] = MenuAction.RUNELITE_PLAYER.getId();
playerMenuIndexMap.put(playerOptionIndex, menuText);
}

View File

@@ -124,7 +124,7 @@ public class PlayerIndicatorsPlugin extends Plugin
|| type == PLAYER_SIXTH_OPTION.getId()
|| type == PLAYER_SEVENTH_OPTION.getId()
|| type == PLAYER_EIGTH_OPTION.getId()
|| type == RUNELITE.getId())
|| type == RUNELITE_PLAYER.getId())
{
Player[] players = client.getCachedPlayers();
Player player = null;

View File

@@ -67,7 +67,7 @@ public class MenuManagerTest
public void testPlayerMenuOptionClicked()
{
MenuOptionClicked event = new MenuOptionClicked();
event.setMenuAction(MenuAction.RUNELITE);
event.setMenuAction(MenuAction.RUNELITE_PLAYER);
event.setMenuTarget("username<col=40ff00> (level-42)");
menuManager.onMenuOptionClicked(event);
@@ -82,7 +82,7 @@ public class MenuManagerTest
public void testPlayerMenuOptionWithBountyHunterEmblemClicked()
{
MenuOptionClicked event = new MenuOptionClicked();
event.setMenuAction(MenuAction.RUNELITE);
event.setMenuAction(MenuAction.RUNELITE_PLAYER);
event.setMenuTarget("username<img=20>5<col=40ff00> (level-42)");
menuManager.onMenuOptionClicked(event);