player indicators: add clans
This commit is contained in:
@@ -95,7 +95,7 @@ public interface PlayerIndicatorsConfig extends Config
|
|||||||
description = "Configures if friends chat members should be highlighted",
|
description = "Configures if friends chat members should be highlighted",
|
||||||
section = highlightSection
|
section = highlightSection
|
||||||
)
|
)
|
||||||
default boolean drawFriendsChatMemberNames()
|
default boolean highlightFriendsChat()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -138,6 +138,30 @@ public interface PlayerIndicatorsConfig extends Config
|
|||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 8,
|
position = 8,
|
||||||
|
keyName = "drawClanChatMemberNames",
|
||||||
|
name = "Highlight clan members",
|
||||||
|
description = "Configures whether or not clan members should be highlighted",
|
||||||
|
section = highlightSection
|
||||||
|
)
|
||||||
|
default boolean highlightClanMembers()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 9,
|
||||||
|
keyName = "clanChatMemberColor",
|
||||||
|
name = "Clan member",
|
||||||
|
description = "Color of clan members",
|
||||||
|
section = highlightSection
|
||||||
|
)
|
||||||
|
default Color getClanMemberColor()
|
||||||
|
{
|
||||||
|
return new Color(36, 15, 171);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 10,
|
||||||
keyName = "drawNonClanMemberNames",
|
keyName = "drawNonClanMemberNames",
|
||||||
name = "Highlight others",
|
name = "Highlight others",
|
||||||
description = "Configures whether or not other players should be highlighted",
|
description = "Configures whether or not other players should be highlighted",
|
||||||
@@ -149,7 +173,7 @@ public interface PlayerIndicatorsConfig extends Config
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
position = 9,
|
position = 11,
|
||||||
keyName = "nonClanMemberColor",
|
keyName = "nonClanMemberColor",
|
||||||
name = "Others",
|
name = "Others",
|
||||||
description = "Color of other players names",
|
description = "Color of other players names",
|
||||||
@@ -214,4 +238,15 @@ public interface PlayerIndicatorsConfig extends Config
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 15,
|
||||||
|
keyName = "clanchatMenuIcons",
|
||||||
|
name = "Show clan chat ranks",
|
||||||
|
description = "Add clan chat rank to right click menu and next to player names"
|
||||||
|
)
|
||||||
|
default boolean showClanChatRanks()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import javax.inject.Singleton;
|
|||||||
import net.runelite.api.FriendsChatRank;
|
import net.runelite.api.FriendsChatRank;
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
|
import net.runelite.api.clan.ClanTitle;
|
||||||
import net.runelite.client.game.ChatIconManager;
|
import net.runelite.client.game.ChatIconManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
@@ -108,40 +109,49 @@ public class PlayerIndicatorsOverlay extends Overlay
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actor.isFriendsChatMember() && config.showFriendsChatRanks())
|
BufferedImage rankImage = null;
|
||||||
|
if (actor.isFriendsChatMember() && config.highlightFriendsChat() && config.showFriendsChatRanks())
|
||||||
{
|
{
|
||||||
final FriendsChatRank rank = playerIndicatorsService.getFriendsChatRank(actor);
|
final FriendsChatRank rank = playerIndicatorsService.getFriendsChatRank(actor);
|
||||||
|
|
||||||
if (rank != FriendsChatRank.UNRANKED)
|
if (rank != FriendsChatRank.UNRANKED)
|
||||||
{
|
{
|
||||||
final BufferedImage rankImage = chatIconManager.getRankImage(rank);
|
rankImage = chatIconManager.getRankImage(rank);
|
||||||
|
|
||||||
if (rankImage != null)
|
|
||||||
{
|
|
||||||
final int imageWidth = rankImage.getWidth();
|
|
||||||
final int imageTextMargin;
|
|
||||||
final int imageNegativeMargin;
|
|
||||||
|
|
||||||
if (drawPlayerNamesConfig == PlayerNameLocation.MODEL_RIGHT)
|
|
||||||
{
|
|
||||||
imageTextMargin = imageWidth;
|
|
||||||
imageNegativeMargin = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
imageTextMargin = imageWidth / 2;
|
|
||||||
imageNegativeMargin = imageWidth / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int textHeight = graphics.getFontMetrics().getHeight() - graphics.getFontMetrics().getMaxDescent();
|
|
||||||
final Point imageLocation = new Point(textLocation.getX() - imageNegativeMargin - 1, textLocation.getY() - textHeight / 2 - rankImage.getHeight() / 2);
|
|
||||||
OverlayUtil.renderImageLocation(graphics, imageLocation, rankImage);
|
|
||||||
|
|
||||||
// move text
|
|
||||||
textLocation = new Point(textLocation.getX() + imageTextMargin, textLocation.getY());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (actor.isClanMember() && config.highlightClanMembers() && config.showClanChatRanks())
|
||||||
|
{
|
||||||
|
ClanTitle clanTitle = playerIndicatorsService.getClanTitle(actor);
|
||||||
|
if (clanTitle != null)
|
||||||
|
{
|
||||||
|
rankImage = chatIconManager.getRankImage(clanTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rankImage != null)
|
||||||
|
{
|
||||||
|
final int imageWidth = rankImage.getWidth();
|
||||||
|
final int imageTextMargin;
|
||||||
|
final int imageNegativeMargin;
|
||||||
|
|
||||||
|
if (drawPlayerNamesConfig == PlayerNameLocation.MODEL_RIGHT)
|
||||||
|
{
|
||||||
|
imageTextMargin = imageWidth;
|
||||||
|
imageNegativeMargin = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imageTextMargin = imageWidth / 2;
|
||||||
|
imageNegativeMargin = imageWidth / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int textHeight = graphics.getFontMetrics().getHeight() - graphics.getFontMetrics().getMaxDescent();
|
||||||
|
final Point imageLocation = new Point(textLocation.getX() - imageNegativeMargin - 1, textLocation.getY() - textHeight / 2 - rankImage.getHeight() / 2);
|
||||||
|
OverlayUtil.renderImageLocation(graphics, imageLocation, rankImage);
|
||||||
|
|
||||||
|
// move text
|
||||||
|
textLocation = new Point(textLocation.getX() + imageTextMargin, textLocation.getY());
|
||||||
|
}
|
||||||
|
|
||||||
OverlayUtil.renderTextLocation(graphics, textLocation, name, color);
|
OverlayUtil.renderTextLocation(graphics, textLocation, name, color);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import static net.runelite.api.MenuAction.SPELL_CAST_ON_PLAYER;
|
|||||||
import static net.runelite.api.MenuAction.WALK;
|
import static net.runelite.api.MenuAction.WALK;
|
||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
|
import net.runelite.api.clan.ClanTitle;
|
||||||
import net.runelite.api.events.ClientTick;
|
import net.runelite.api.events.ClientTick;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
@@ -189,11 +190,11 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
int image = -1;
|
int image = -1;
|
||||||
Color color = null;
|
Color color = null;
|
||||||
|
|
||||||
if (config.highlightFriends() && player.isFriend())
|
if (player.isFriend() && config.highlightFriends())
|
||||||
{
|
{
|
||||||
color = config.getFriendColor();
|
color = config.getFriendColor();
|
||||||
}
|
}
|
||||||
else if (config.drawFriendsChatMemberNames() && player.isFriendsChatMember())
|
else if (player.isFriendsChatMember() && config.highlightFriendsChat())
|
||||||
{
|
{
|
||||||
color = config.getFriendsChatMemberColor();
|
color = config.getFriendsChatMemberColor();
|
||||||
|
|
||||||
@@ -206,12 +207,24 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (config.highlightTeamMembers()
|
else if (player.getTeam() > 0 && client.getLocalPlayer().getTeam() == player.getTeam() && config.highlightTeamMembers())
|
||||||
&& player.getTeam() > 0 && client.getLocalPlayer().getTeam() == player.getTeam())
|
|
||||||
{
|
{
|
||||||
color = config.getTeamMemberColor();
|
color = config.getTeamMemberColor();
|
||||||
}
|
}
|
||||||
else if (config.highlightOthers() && !player.isFriendsChatMember())
|
else if (player.isClanMember() && config.highlightClanMembers())
|
||||||
|
{
|
||||||
|
color = config.getClanMemberColor();
|
||||||
|
|
||||||
|
if (config.showClanChatRanks())
|
||||||
|
{
|
||||||
|
ClanTitle clanTitle = playerIndicatorsService.getClanTitle(player);
|
||||||
|
if (clanTitle != null)
|
||||||
|
{
|
||||||
|
image = chatIconManager.getIconNumber(clanTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!player.isFriendsChatMember() && !player.isClanMember() && config.highlightOthers())
|
||||||
{
|
{
|
||||||
color = config.getOthersColor();
|
color = config.getOthersColor();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ import net.runelite.api.FriendsChatManager;
|
|||||||
import net.runelite.api.FriendsChatMember;
|
import net.runelite.api.FriendsChatMember;
|
||||||
import net.runelite.api.FriendsChatRank;
|
import net.runelite.api.FriendsChatRank;
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
|
import net.runelite.api.clan.ClanChannel;
|
||||||
|
import net.runelite.api.clan.ClanChannelMember;
|
||||||
|
import net.runelite.api.clan.ClanRank;
|
||||||
|
import net.runelite.api.clan.ClanSettings;
|
||||||
|
import net.runelite.api.clan.ClanTitle;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class PlayerIndicatorsService
|
public class PlayerIndicatorsService
|
||||||
@@ -49,8 +54,9 @@ public class PlayerIndicatorsService
|
|||||||
|
|
||||||
public void forEachPlayer(final BiConsumer<Player, Color> consumer)
|
public void forEachPlayer(final BiConsumer<Player, Color> consumer)
|
||||||
{
|
{
|
||||||
if (!config.highlightOwnPlayer() && !config.drawFriendsChatMemberNames()
|
if (!config.highlightOwnPlayer() && !config.highlightFriendsChat()
|
||||||
&& !config.highlightFriends() && !config.highlightOthers())
|
&& !config.highlightFriends() && !config.highlightOthers()
|
||||||
|
&& !config.highlightClanMembers())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -65,6 +71,7 @@ public class PlayerIndicatorsService
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean isFriendsChatMember = player.isFriendsChatMember();
|
boolean isFriendsChatMember = player.isFriendsChatMember();
|
||||||
|
boolean isClanMember = player.isClanMember();
|
||||||
|
|
||||||
if (player == localPlayer)
|
if (player == localPlayer)
|
||||||
{
|
{
|
||||||
@@ -77,7 +84,7 @@ public class PlayerIndicatorsService
|
|||||||
{
|
{
|
||||||
consumer.accept(player, config.getFriendColor());
|
consumer.accept(player, config.getFriendColor());
|
||||||
}
|
}
|
||||||
else if (config.drawFriendsChatMemberNames() && isFriendsChatMember)
|
else if (config.highlightFriendsChat() && isFriendsChatMember)
|
||||||
{
|
{
|
||||||
consumer.accept(player, config.getFriendsChatMemberColor());
|
consumer.accept(player, config.getFriendsChatMemberColor());
|
||||||
}
|
}
|
||||||
@@ -85,13 +92,36 @@ public class PlayerIndicatorsService
|
|||||||
{
|
{
|
||||||
consumer.accept(player, config.getTeamMemberColor());
|
consumer.accept(player, config.getTeamMemberColor());
|
||||||
}
|
}
|
||||||
else if (config.highlightOthers() && !isFriendsChatMember)
|
else if (config.highlightClanMembers() && isClanMember)
|
||||||
|
{
|
||||||
|
consumer.accept(player, config.getClanMemberColor());
|
||||||
|
}
|
||||||
|
else if (config.highlightOthers() && !isFriendsChatMember && !isClanMember)
|
||||||
{
|
{
|
||||||
consumer.accept(player, config.getOthersColor());
|
consumer.accept(player, config.getOthersColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClanTitle getClanTitle(Player player)
|
||||||
|
{
|
||||||
|
ClanChannel clanChannel = client.getClanChannel();
|
||||||
|
ClanSettings clanSettings = client.getClanSettings();
|
||||||
|
if (clanChannel == null || clanSettings == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClanChannelMember member = clanChannel.findMember(player.getName());
|
||||||
|
if (member == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClanRank rank = member.getRank();
|
||||||
|
return clanSettings.titleForRank(rank);
|
||||||
|
}
|
||||||
|
|
||||||
FriendsChatRank getFriendsChatRank(Player player)
|
FriendsChatRank getFriendsChatRank(Player player)
|
||||||
{
|
{
|
||||||
final FriendsChatManager friendsChatManager = client.getFriendsChatManager();
|
final FriendsChatManager friendsChatManager = client.getFriendsChatManager();
|
||||||
|
|||||||
Reference in New Issue
Block a user