diff --git a/runelite-api/src/main/java/net/runelite/api/MenuAction.java b/runelite-api/src/main/java/net/runelite/api/MenuAction.java index 450989d9c3..44bf09aa53 100644 --- a/runelite-api/src/main/java/net/runelite/api/MenuAction.java +++ b/runelite-api/src/main/java/net/runelite/api/MenuAction.java @@ -273,9 +273,6 @@ public enum MenuAction */ RUNELITE_OVERLAY_CONFIG(1502), - FOLLOW(2046), - TRADE(2047), - /** * Menu action triggered when the id is not defined in this class. */ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java index e545f92dff..ffbccb4710 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java @@ -27,13 +27,14 @@ package net.runelite.client.plugins.playerindicators; import com.google.inject.Provides; import java.awt.Color; import javax.inject.Inject; +import lombok.Value; import net.runelite.api.ClanMemberRank; import static net.runelite.api.ClanMemberRank.UNRANKED; import net.runelite.api.Client; import static net.runelite.api.MenuAction.*; import net.runelite.api.MenuEntry; import net.runelite.api.Player; -import net.runelite.api.events.MenuEntryAdded; +import net.runelite.api.events.ClientTick; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.game.ClanManager; @@ -93,93 +94,141 @@ public class PlayerIndicatorsPlugin extends Plugin } @Subscribe - public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) + public void onClientTick(ClientTick clientTick) { - int type = menuEntryAdded.getType(); + MenuEntry[] menuEntries = client.getMenuEntries(); + boolean modified = false; - if (type >= 2000) + for (MenuEntry entry : menuEntries) { - type -= 2000; + int type = entry.getType(); + + if (type >= MENU_ACTION_DEPRIORITIZE_OFFSET) + { + type -= MENU_ACTION_DEPRIORITIZE_OFFSET; + } + + if (type == WALK.getId() + || type == SPELL_CAST_ON_PLAYER.getId() + || type == ITEM_USE_ON_PLAYER.getId() + || type == PLAYER_FIRST_OPTION.getId() + || type == PLAYER_SECOND_OPTION.getId() + || type == PLAYER_THIRD_OPTION.getId() + || type == PLAYER_FOURTH_OPTION.getId() + || type == PLAYER_FIFTH_OPTION.getId() + || type == PLAYER_SIXTH_OPTION.getId() + || type == PLAYER_SEVENTH_OPTION.getId() + || type == PLAYER_EIGTH_OPTION.getId() + || type == RUNELITE.getId()) + { + Player[] players = client.getCachedPlayers(); + Player player = null; + + int identifier = entry.getIdentifier(); + + // 'Walk here' identifiers are offset by 1 because the default + // identifier for this option is 0, which is also a player index. + if (type == WALK.getId()) + { + identifier--; + } + + if (identifier >= 0 && identifier < players.length) + { + player = players[identifier]; + } + + if (player == null) + { + continue; + } + + Decorations decorations = getDecorations(player); + + if (decorations == null) + { + continue; + } + + String oldTarget = entry.getTarget(); + String newTarget = decorateTarget(oldTarget, decorations); + + entry.setTarget(newTarget); + modified = true; + } } - int identifier = menuEntryAdded.getIdentifier(); - if (type == FOLLOW.getId() || type == TRADE.getId() - || type == SPELL_CAST_ON_PLAYER.getId() || type == ITEM_USE_ON_PLAYER.getId() - || type == PLAYER_FIRST_OPTION.getId() - || type == PLAYER_SECOND_OPTION.getId() - || type == PLAYER_THIRD_OPTION.getId() - || type == PLAYER_FOURTH_OPTION.getId() - || type == PLAYER_FIFTH_OPTION.getId() - || type == PLAYER_SIXTH_OPTION.getId() - || type == PLAYER_SEVENTH_OPTION.getId() - || type == PLAYER_EIGTH_OPTION.getId() - || type == RUNELITE.getId()) + if (modified) { - final Player localPlayer = client.getLocalPlayer(); - Player[] players = client.getCachedPlayers(); - Player player = null; - - if (identifier >= 0 && identifier < players.length) - { - player = players[identifier]; - } - - if (player == null) - { - return; - } - - int image = -1; - Color color = null; - - if (config.highlightFriends() && player.isFriend()) - { - color = config.getFriendColor(); - } - else if (config.drawClanMemberNames() && player.isClanMember()) - { - color = config.getClanMemberColor(); - - ClanMemberRank rank = clanManager.getRank(player.getName()); - if (rank != UNRANKED) - { - image = clanManager.getIconNumber(rank); - } - } - else if (config.highlightTeamMembers() && player.getTeam() > 0 && localPlayer.getTeam() == player.getTeam()) - { - color = config.getTeamMemberColor(); - } - else if (config.highlightNonClanMembers() && !player.isClanMember()) - { - color = config.getNonClanMemberColor(); - } - - if (image != -1 || color != null) - { - MenuEntry[] menuEntries = client.getMenuEntries(); - MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; - - if (color != null && config.colorPlayerMenu()) - { - // strip out existing