opponent info: add show opponents in menu
This commit is contained in:
@@ -63,4 +63,15 @@ public interface OpponentInfoConfig extends Config
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showOpponentsInMenu",
|
||||
name = "Show opponents in menu",
|
||||
description = "Marks opponents names in the menu which you are attacking or are attacking you (NPC only)",
|
||||
position = 3
|
||||
)
|
||||
default boolean showOpponentsInMenu()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,14 @@ import lombok.Getter;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.WorldType;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.InteractingChanged;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
@@ -159,4 +163,29 @@ public class OpponentInfoPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded)
|
||||
{
|
||||
if (menuEntryAdded.getType() != MenuAction.NPC_SECOND_OPTION.getId()
|
||||
|| !menuEntryAdded.getOption().equals("Attack")
|
||||
|| !config.showOpponentsInMenu())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int npcIndex = menuEntryAdded.getIdentifier();
|
||||
NPC npc = client.getCachedNPCs()[npcIndex];
|
||||
if (npc == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (npc.getInteracting() == client.getLocalPlayer() || lastOpponent == npc)
|
||||
{
|
||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
||||
menuEntries[menuEntries.length - 1].setTarget("*" + menuEntryAdded.getTarget());
|
||||
client.setMenuEntries(menuEntries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user