WIP: re-adds clan member ranks to indicators, fixes misc player indicator bugs
Signed-off-by: PKLite <stonewall@pklite.xyz> (cherry picked from commit a158bd7c06cc038b69e5033b421faee305241c6d)
This commit is contained in:
@@ -32,6 +32,7 @@ import java.awt.Polygon;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -42,6 +43,7 @@ import net.runelite.api.Point;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.WorldType;
|
||||
import net.runelite.api.kit.KitType;
|
||||
import net.runelite.client.game.ClanManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
@@ -65,6 +67,8 @@ public class PlayerIndicatorsOverlay extends Overlay
|
||||
private PlayerIndicatorsService playerIndicatorsService;
|
||||
@Inject
|
||||
private Client client;
|
||||
@Inject
|
||||
private ClanManager clanManager;
|
||||
|
||||
@Inject
|
||||
public PlayerIndicatorsOverlay(PlayerIndicatorsPlugin plugin, PlayerIndicatorsService playerIndicatorsService)
|
||||
@@ -114,14 +118,24 @@ public class PlayerIndicatorsOverlay extends Overlay
|
||||
}
|
||||
|
||||
final String builtString = nameSb.toString();
|
||||
|
||||
final int x = graphics.getFontMetrics().stringWidth(builtString);
|
||||
final int y = graphics.getFontMetrics().getHeight();
|
||||
if (skulls && actor.getSkullIcon() != null)
|
||||
{
|
||||
final int x = graphics.getFontMetrics().stringWidth(builtString);
|
||||
final int y = graphics.getFontMetrics().getHeight();
|
||||
|
||||
OverlayUtil.renderActorTextAndImage(graphics, actor, builtString, color,
|
||||
ImageUtil.resizeImage(skullIcon, y, y), 0, x);
|
||||
}
|
||||
if (plugin.isHighlightClan() && actor.isClanMember() && plugin.isShowClanRanks() && relation == PlayerRelation.CLAN)
|
||||
{
|
||||
if (clanManager.getRank(actor.getName()) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
OverlayUtil.renderActorTextAndImage(graphics, actor, builtString, color,
|
||||
ImageUtil.resizeImage(Objects.requireNonNull(clanManager.getClanImage(clanManager.getRank(actor.getName()))), y, y)
|
||||
,x + ACTOR_HORIZONTAL_TEXT_MARGIN, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayUtil.renderActorTextOverlay(graphics, actor, builtString, color);
|
||||
|
||||
@@ -33,6 +33,7 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Friend;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.client.util.PvPUtil;
|
||||
|
||||
@@ -58,29 +59,19 @@ public class PlayerIndicatorsService
|
||||
this.client = client;
|
||||
this.plugin = plugin;
|
||||
|
||||
self = (player) -> Objects.equals(client.getLocalPlayer(), player);
|
||||
self = (player) -> client.getLocalPlayer().equals(player);
|
||||
friend = (player) -> (!player.equals(client.getLocalPlayer()) && client.isFriended(player.getName(), false));
|
||||
clan = (player) -> (player.isClanMember() && !client.isFriended(player.getName(), false));
|
||||
team = (player) -> (Objects.requireNonNull(client.getLocalPlayer()).getTeam() != 0 &&
|
||||
team = (player) -> (Objects.requireNonNull(client.getLocalPlayer()).getTeam() != 0 && !player.isClanMember()
|
||||
&& !client.isFriended(player.getName(), false) &&
|
||||
client.getLocalPlayer().getTeam() == player.getTeam());
|
||||
target = (player ->
|
||||
{
|
||||
if (nonFriendly(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return plugin.isHighlightTargets() && PvPUtil.isAttackable(client, player);
|
||||
});
|
||||
target = (player) -> (!team.test(player) && !clan.test(player)
|
||||
&& !friend.test(player) && PvPUtil.isAttackable(client, player) && !self.test(player));
|
||||
caller = plugin::isCaller;
|
||||
callerTarget = piles::contains;
|
||||
other = (player ->
|
||||
{
|
||||
if (nonFriendly(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
other = (player) ->
|
||||
(!PvPUtil.isAttackable(client, player) && !team.test(player) && !clan.test(player) && !friend.test(player));
|
||||
|
||||
}
|
||||
|
||||
public void forEachPlayer(final BiConsumer<Player, PlayerRelation> consumer)
|
||||
@@ -93,48 +84,56 @@ public class PlayerIndicatorsService
|
||||
piles.clear();
|
||||
|
||||
final List<Player> players = client.getPlayers();
|
||||
for (Player p : players)
|
||||
{
|
||||
if (self.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.SELF))
|
||||
{
|
||||
consumer.accept(p, PlayerRelation.SELF);
|
||||
continue;
|
||||
}
|
||||
if (friend.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.FRIEND))
|
||||
{
|
||||
consumer.accept(p, PlayerRelation.FRIEND);
|
||||
continue;
|
||||
|
||||
if (plugin.isHighlightOwnPlayer())
|
||||
{
|
||||
players.stream().filter(self).forEach(p -> consumer.accept(p, PlayerRelation.SELF));
|
||||
}
|
||||
if (plugin.isHighlightFriends())
|
||||
{
|
||||
players.stream().filter(friend.and(self.negate())).forEach(p -> consumer.accept(p, PlayerRelation.FRIEND));
|
||||
}
|
||||
if (plugin.isHighlightClan())
|
||||
{
|
||||
players.stream().filter(clan.and(self.negate())).forEach(p -> consumer.accept(p, PlayerRelation.CLAN));
|
||||
}
|
||||
if (plugin.isHighlightTeam())
|
||||
{
|
||||
players.stream().filter(team.and(self.negate())).forEach(p -> consumer.accept(p, PlayerRelation.TEAM));
|
||||
}
|
||||
if (plugin.isHighlightTargets())
|
||||
{
|
||||
players.stream().filter(target.and(self.negate())).forEach(p -> consumer.accept(p, PlayerRelation.TARGET));
|
||||
}
|
||||
if (plugin.isHighlightOther())
|
||||
{
|
||||
players.stream().filter(other.and(self.negate())).forEach(p -> consumer.accept(p, PlayerRelation.OTHER));
|
||||
}
|
||||
if (plugin.isHighlightCallers())
|
||||
{
|
||||
players.stream().filter(caller).forEach(p ->
|
||||
}
|
||||
if (clan.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.CLAN))
|
||||
{
|
||||
consumer.accept(p, PlayerRelation.CLAN);
|
||||
continue;
|
||||
|
||||
}
|
||||
if (team.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.TEAM))
|
||||
{
|
||||
consumer.accept(p, PlayerRelation.TEAM);
|
||||
continue;
|
||||
|
||||
}
|
||||
if (target.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.TARGET))
|
||||
{
|
||||
consumer.accept(p, PlayerRelation.TARGET);
|
||||
continue;
|
||||
|
||||
}
|
||||
if (caller.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.CALLER))
|
||||
{
|
||||
consumer.accept(p, PlayerRelation.CALLER);
|
||||
if (p.getInteracting() != null)
|
||||
{
|
||||
piles.add(p.getInteracting());
|
||||
}
|
||||
});
|
||||
continue;
|
||||
|
||||
}
|
||||
if (callerTarget.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.CALLER_TARGET))
|
||||
{
|
||||
consumer.accept(p, PlayerRelation.CALLER_TARGET);
|
||||
continue;
|
||||
|
||||
}
|
||||
if (other.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.OTHER))
|
||||
{
|
||||
consumer.accept(p, PlayerRelation.OTHER);
|
||||
|
||||
}
|
||||
}
|
||||
if (plugin.isHighlightCallerTargets())
|
||||
{
|
||||
players.stream().filter(callerTarget).forEach(p ->
|
||||
consumer.accept(p, PlayerRelation.CALLER_TARGET));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean highlight()
|
||||
{
|
||||
@@ -142,15 +141,4 @@ public class PlayerIndicatorsService
|
||||
|| plugin.isHighlightFriends() || plugin.isHighlightOther() || plugin.isHighlightTargets()
|
||||
|| plugin.isHighlightCallers() || plugin.isHighlightTeam() || plugin.isHighlightCallerTargets();
|
||||
}
|
||||
|
||||
private boolean nonFriendly(Player player)
|
||||
{
|
||||
return player == null
|
||||
|| (plugin.isHighlightClan() && player.isClanMember())
|
||||
|| (plugin.isHighlightFriends() && client.isFriended(player.getName(), false))
|
||||
|| (plugin.isHighlightCallers() && plugin.isCaller(player))
|
||||
|| (plugin.isHighlightCallerTargets() && piles.contains(player))
|
||||
|| (plugin.isHighlightTeam() && Objects.requireNonNull(client.getLocalPlayer()).getTeam() != 0
|
||||
&& client.getLocalPlayer().getTeam() == player.getTeam());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user