use of net.runelite.api.ClanMemberRank in project runelite by runelite.
the class PlayerIndicatorsPlugin method onMenuEntryAdd.
@Subscribe
public void onMenuEntryAdd(MenuEntryAdded menuEntryAdded) {
int type = menuEntryAdded.getType();
int identifier = menuEntryAdded.getIdentifier();
if (type == FOLLOW.getId() || type == TRADE.getId() || type == SPELL_CAST_ON_PLAYER.getId() || type == ITEM_USE_ON_PLAYER.getId() || type == PLAYER_FIRST_OPTION.getId() || type == PLAYER_SECOND_OPTION.getId() || type == PLAYER_THIRD_OPTION.getId() || type == PLAYER_FOURTH_OPTION.getId() || type == PLAYER_FIFTH_OPTION.getId() || type == PLAYER_SIXTH_OPTION.getId() || type == PLAYER_SEVENTH_OPTION.getId() || type == PLAYER_EIGTH_OPTION.getId()) {
final Player localPlayer = client.getLocalPlayer();
Player[] players = client.getCachedPlayers();
Player player = null;
if (identifier >= 0 && identifier < players.length) {
player = players[identifier];
}
if (player == null) {
return;
}
int image = -1;
Color color = null;
if (config.drawFriendNames() && player.isFriend()) {
color = config.getFriendNameColor();
} else if (config.drawClanMemberNames() && player.isClanMember()) {
color = config.getClanMemberColor();
ClanMemberRank rank = clanManager.getRank(player.getName());
if (rank != UNRANKED) {
image = clanManager.getIconNumber(rank);
}
} else if (config.drawTeamMemberNames() && player.getTeam() > 0 && localPlayer.getTeam() == player.getTeam()) {
color = config.getTeamMemberColor();
} else if (config.drawNonClanMemberNames() && !player.isClanMember()) {
color = config.getNonClanMemberColor();
}
if (image != -1 || color != null) {
MenuEntry[] menuEntries = client.getMenuEntries();
MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
if (color != null) {
// strip out existing <col...
String target = lastEntry.getTarget();
int idx = target.indexOf('>');
if (idx != -1) {
target = target.substring(idx + 1);
}
lastEntry.setTarget("<col=" + Integer.toHexString(color.getRGB() & 0xFFFFFF) + ">" + target);
}
if (image != -1) {
lastEntry.setTarget("<img=" + image + ">" + lastEntry.getTarget());
}
client.setMenuEntries(menuEntries);
}
}
}
use of net.runelite.api.ClanMemberRank in project runelite by runelite.
the class PlayerIndicatorsOverlay method renderPlayerOverlay.
private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) {
if (config.drawTiles()) {
Polygon poly = actor.getCanvasTilePoly();
if (poly != null) {
OverlayUtil.renderPolygon(graphics, poly, color);
}
}
String name = actor.getName().replace('\u00A0', ' ');
int offset = actor.getLogicalHeight() + 40;
Point textLocation = actor.getCanvasTextLocation(graphics, name, offset);
if (textLocation != null) {
if (actor.isClanMember()) {
ClanMemberRank rank = clanManager.getRank(name);
if (rank != ClanMemberRank.UNRANKED) {
BufferedImage clanchatImage = clanManager.getClanImage(rank);
if (clanchatImage != null) {
int width = clanchatImage.getWidth();
Point imageLocation = new Point(textLocation.getX() - width / 2, textLocation.getY() - clanchatImage.getHeight());
OverlayUtil.renderImageLocation(graphics, imageLocation, clanchatImage);
// move text
textLocation = new Point(textLocation.getX() + width / 2, textLocation.getY());
}
}
}
OverlayUtil.renderTextLocation(graphics, textLocation, name, color);
}
}
use of net.runelite.api.ClanMemberRank in project runelite by runelite.
the class ClanChatPlugin method insertClanRankIcon.
private void insertClanRankIcon(final SetMessage message) {
final ClanMemberRank rank = clanManager.getRank(message.getName());
if (rank != null && rank != ClanMemberRank.UNRANKED) {
int iconNumber = clanManager.getIconNumber(rank);
message.getMessageNode().setSender(message.getMessageNode().getSender() + " <img=" + iconNumber + ">");
client.refreshChat();
}
}
Aggregations