Search in sources :

Example 1 with ClanMemberRank

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);
        }
    }
}
Also used : Player(net.runelite.api.Player) MenuEntry(net.runelite.api.MenuEntry) Color(java.awt.Color) ClanMemberRank(net.runelite.api.ClanMemberRank) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with ClanMemberRank

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);
    }
}
Also used : Point(net.runelite.api.Point) ClanMemberRank(net.runelite.api.ClanMemberRank) Polygon(java.awt.Polygon) Point(net.runelite.api.Point) BufferedImage(java.awt.image.BufferedImage)

Example 3 with ClanMemberRank

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();
    }
}
Also used : ClanMemberRank(net.runelite.api.ClanMemberRank)

Aggregations

ClanMemberRank (net.runelite.api.ClanMemberRank)3 Subscribe (com.google.common.eventbus.Subscribe)1 Color (java.awt.Color)1 Polygon (java.awt.Polygon)1 BufferedImage (java.awt.image.BufferedImage)1 MenuEntry (net.runelite.api.MenuEntry)1 Player (net.runelite.api.Player)1 Point (net.runelite.api.Point)1