Java Code Examples for net.runelite.api.events.MenuEntryAdded#getOption()

The following examples show how to use net.runelite.api.events.MenuEntryAdded#getOption() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HiscorePlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
private void onMenuEntryAdded(MenuEntryAdded event)
{
	if (!config.menuOption())
	{
		return;
	}

	int groupId = WidgetInfo.TO_GROUP(event.getParam1());
	String option = event.getOption();

	if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.FRIENDS_CHAT.getGroupId() ||
		groupId == WidgetInfo.CHATBOX.getGroupId() && !KICK_OPTION.equals(option) || //prevent from adding for Kick option (interferes with the raiding party one)
		groupId == WidgetInfo.RAIDING_PARTY.getGroupId() || groupId == WidgetInfo.PRIVATE_CHAT_MESSAGE.getGroupId() ||
		groupId == WidgetInfo.IGNORE_LIST.getGroupId())
	{
		if (!AFTER_OPTIONS.contains(option) || (option.equals("Delete") && groupId != WidgetInfo.IGNORE_LIST.getGroupId()))
		{
			return;
		}

		final MenuEntry lookup = new MenuEntry();
		lookup.setOption(LOOKUP);
		lookup.setTarget(event.getTarget());
		lookup.setOpcode(MenuOpcode.RUNELITE.getId());
		lookup.setParam0(event.getParam0());
		lookup.setParam1(event.getParam1());
		lookup.setIdentifier(event.getIdentifier());

		if (client != null)
		{
			insertMenuEntry(lookup, client.getMenuEntries());
		}
	}
}
 
Example 2
Source File: HiscorePlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
	if (!config.menuOption())
	{
		return;
	}

	int groupId = WidgetInfo.TO_GROUP(event.getActionParam1());
	String option = event.getOption();

	if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.FRIENDS_CHAT.getGroupId() ||
			groupId == WidgetInfo.CHATBOX.getGroupId() && !KICK_OPTION.equals(option) || //prevent from adding for Kick option (interferes with the raiding party one)
			groupId == WidgetInfo.RAIDING_PARTY.getGroupId() || groupId == WidgetInfo.PRIVATE_CHAT_MESSAGE.getGroupId() ||
			groupId == WidgetInfo.IGNORE_LIST.getGroupId())
	{
		if (!AFTER_OPTIONS.contains(option) || (option.equals("Delete") && groupId != WidgetInfo.IGNORE_LIST.getGroupId()))
		{
			return;
		}

		final MenuEntry lookup = new MenuEntry();
		lookup.setOption(LOOKUP);
		lookup.setTarget(event.getTarget());
		lookup.setType(MenuAction.RUNELITE.getId());
		lookup.setParam0(event.getActionParam0());
		lookup.setParam1(event.getActionParam1());
		lookup.setIdentifier(event.getIdentifier());

		insertMenuEntry(lookup, client.getMenuEntries());
	}
}
 
Example 3
Source File: WorldHopperPlugin.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
private void onMenuEntryAdded(MenuEntryAdded event)
{
	if (!config.menuOption())
	{
		return;
	}

	int groupId = WidgetInfo.TO_GROUP(event.getParam1());
	String option = event.getOption();

	if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.FRIENDS_CHAT.getGroupId())
	{
		boolean after;

		if (AFTER_OPTIONS.contains(option))
		{
			after = true;
		}
		else if (BEFORE_OPTIONS.contains(option))
		{
			after = false;
		}
		else
		{
			return;
		}

		// Don't add entry if user is offline
		ChatPlayer player = getChatPlayerFromName(event.getTarget());
		WorldResult worldResult = worldService.getWorlds();

		if (player == null || player.getWorld() == 0 || player.getWorld() == client.getWorld()
			|| worldResult == null)
		{
			return;
		}

		World currentWorld = worldResult.findWorld(client.getWorld());
		World targetWorld = worldResult.findWorld(player.getWorld());
		if ((targetWorld == null || currentWorld == null)
			|| (config.removePVPWorld() && !currentWorld.getTypes().contains(WorldType.PVP) && targetWorld.getTypes().contains(WorldType.PVP))
			|| (config.removeBHWorld() && !currentWorld.getTypes().contains(WorldType.BOUNTY) && targetWorld.getTypes().contains(WorldType.BOUNTY)))
		{
			// Disable Hop-to a PVP world & BH world from a regular world
			return;
		}


		final MenuEntry hopTo = new MenuEntry();
		hopTo.setOption(HOP_TO);
		hopTo.setTarget(event.getTarget());
		hopTo.setOpcode(MenuOpcode.RUNELITE.getId());
		hopTo.setParam0(event.getParam0());
		hopTo.setParam1(event.getParam1());

		insertMenuEntry(hopTo, client.getMenuEntries(), after);
	}
}
 
Example 4
Source File: WorldHopperPlugin.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
	if (!config.menuOption())
	{
		return;
	}

	int groupId = WidgetInfo.TO_GROUP(event.getActionParam1());
	String option = event.getOption();

	if (groupId == WidgetInfo.FRIENDS_LIST.getGroupId() || groupId == WidgetInfo.FRIENDS_CHAT.getGroupId())
	{
		boolean after;

		if (AFTER_OPTIONS.contains(option))
		{
			after = true;
		}
		else if (BEFORE_OPTIONS.contains(option))
		{
			after = false;
		}
		else
		{
			return;
		}

		// Don't add entry if user is offline
		ChatPlayer player = getChatPlayerFromName(event.getTarget());
		WorldResult worldResult = worldService.getWorlds();

		if (player == null || player.getWorld() == 0 || player.getWorld() == client.getWorld()
			|| worldResult == null)
		{
			return;
		}

		World currentWorld = worldResult.findWorld(client.getWorld());
		World targetWorld = worldResult.findWorld(player.getWorld());
		if (targetWorld == null || currentWorld == null
			|| (!currentWorld.getTypes().contains(WorldType.PVP) && targetWorld.getTypes().contains(WorldType.PVP)))
		{
			// Disable Hop-to a PVP world from a regular world
			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(), after);
	}
}