Add Hop-To option in chat

This commit is contained in:
Retoxified
2018-08-25 15:21:04 +02:00
parent e2d6b13b47
commit 7d89544290

View File

@@ -102,6 +102,8 @@ public class WorldHopperPlugin extends Plugin
private static final ImmutableList<String> BEFORE_OPTIONS = ImmutableList.of("Add friend", "Remove friend", KICK_OPTION);
private static final ImmutableList<String> AFTER_OPTIONS = ImmutableList.of("Message");
private static final ImmutableList<String> BEFORE_OPTIONS_CHAT = ImmutableList.of("Report");
@Inject
private Client client;
@@ -326,6 +328,30 @@ public class WorldHopperPlugin extends Plugin
insertMenuEntry(hopTo, client.getMenuEntries(), after);
}
else if (groupId == WidgetInfo.CHATBOX.getGroupId())
{
if (!BEFORE_OPTIONS_CHAT.contains(option))
{
return;
}
// Don't add entry if user is offline
ChatPlayer player = getChatPlayerFromName(event.getTarget());
if (player == null || player.getWorld() == 0 || player.getWorld() == client.getWorld())
{
return;
}
final MenuEntry hopTo = new MenuEntry();
hopTo.setOption(HOP_TO);
hopTo.setTarget(event.getTarget());
hopTo.setType(MenuAction.RUNELITE.getId());
hopTo.setParam0(event.getActionParam0());
hopTo.setParam1(event.getActionParam1());
insertMenuEntry(hopTo, client.getMenuEntries(), false);
}
}
private void insertMenuEntry(MenuEntry newEntry, MenuEntry[] entries, boolean after)