Java Code Examples for net.runelite.api.Player#getTeam()

The following examples show how to use net.runelite.api.Player#getTeam() . 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: TeamCapesPlugin.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Schedule(
	period = 1800,
	unit = ChronoUnit.MILLIS
)
public void update()
{
	if (client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}
	List<Player> players = client.getPlayers();
	teams.clear();
	for (Player player : players)
	{
		int team = player.getTeam();
		if (team > 0)
		{
			if (teams.containsKey(team))
			{
				teams.put(team, teams.get(team) + 1);
			}
			else
			{
				teams.put(team, 1);
			}
		}
	}

	// Sort teams by value in descending order and then by key in ascending order, limited to 5 entries
	teams = teams.entrySet().stream()
		.sorted(
			Comparator.comparing(Map.Entry<Integer, Integer>::getValue, Comparator.reverseOrder())
				.thenComparingInt(Map.Entry::getKey)
		)
		.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
}
 
Example 2
Source File: PlayerIndicatorsPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Decorations getDecorations(Player player)
{
	int image = -1;
	Color color = null;

	if (config.highlightFriends() && player.isFriend())
	{
		color = config.getFriendColor();
	}
	else if (config.drawFriendsChatMemberNames() && player.isFriendsChatMember())
	{
		color = config.getFriendsChatMemberColor();

		FriendsChatRank rank = friendChatManager.getRank(player.getName());
		if (rank != UNRANKED)
		{
			image = friendChatManager.getIconNumber(rank);
		}
	}
	else if (config.highlightTeamMembers()
		&& player.getTeam() > 0 && client.getLocalPlayer().getTeam() == player.getTeam())
	{
		color = config.getTeamMemberColor();
	}
	else if (config.highlightOthers() && !player.isFriendsChatMember())
	{
		color = config.getOthersColor();
	}

	if (image == -1 && color == null)
	{
		return null;
	}

	return new Decorations(image, color);
}
 
Example 3
Source File: TeamCapesPlugin.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Schedule(
	period = 1800,
	unit = ChronoUnit.MILLIS
)
public void update()
{
	if (client.getGameState() != GameState.LOGGED_IN)
	{
		return;
	}
	List<Player> players = client.getPlayers();
	teams.clear();
	for (Player player : players)
	{
		int team = player.getTeam();
		if (team > 0)
		{
			if (teams.containsKey(team))
			{
				teams.put(team, teams.get(team) + 1);
			}
			else
			{
				teams.put(team, 1);
			}
		}
	}

	// Sort teams by value in descending order and then by key in ascending order, limited to 5 entries
	teams = teams.entrySet().stream()
				.sorted(
					Comparator.comparing(Map.Entry<Integer, Integer>::getValue, Comparator.reverseOrder())
							.thenComparingInt(Map.Entry::getKey)
				)
				.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
}
 
Example 4
Source File: PlayerIndicatorsService.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void forEachPlayer(final BiConsumer<Player, Color> consumer)
{
	if (!config.highlightOwnPlayer() && !config.drawFriendsChatMemberNames()
		&& !config.highlightFriends() && !config.highlightOthers())
	{
		return;
	}

	final Player localPlayer = client.getLocalPlayer();

	for (Player player : client.getPlayers())
	{
		if (player == null || player.getName() == null)
		{
			continue;
		}

		boolean isFriendsChatMember = player.isFriendsChatMember();

		if (player == localPlayer)
		{
			if (config.highlightOwnPlayer())
			{
				consumer.accept(player, config.getOwnPlayerColor());
			}
		}
		else if (config.highlightFriends() && player.isFriend())
		{
			consumer.accept(player, config.getFriendColor());
		}
		else if (config.drawFriendsChatMemberNames() && isFriendsChatMember)
		{
			consumer.accept(player, config.getFriendsChatMemberColor());
		}
		else if (config.highlightTeamMembers() && localPlayer.getTeam() > 0 && localPlayer.getTeam() == player.getTeam())
		{
			consumer.accept(player, config.getTeamMemberColor());
		}
		else if (config.highlightOthers() && !isFriendsChatMember)
		{
			consumer.accept(player, config.getOthersColor());
		}
	}
}