From 0bc0d571d64d1df79f77c53c53badd05c011848c Mon Sep 17 00:00:00 2001 From: ST0NEWALL <46624825+pklite@users.noreply.github.com> Date: Fri, 6 Sep 2019 22:43:07 -0400 Subject: [PATCH 01/10] WIP: re-adds clan member ranks to indicators, fixes misc player indicator bugs Signed-off-by: PKLite (cherry picked from commit a158bd7c06cc038b69e5033b421faee305241c6d) --- .../PlayerIndicatorsOverlay.java | 20 ++- .../PlayerIndicatorsService.java | 122 ++++++++---------- 2 files changed, 72 insertions(+), 70 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 96899bbb76..0888b2cfbe 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -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); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java index e4f52fa121..e3c0386ef9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java @@ -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 consumer) @@ -93,48 +84,56 @@ public class PlayerIndicatorsService piles.clear(); final List 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()); - } } \ No newline at end of file From e5f6c777bec89caba483c5060911048e94eb4dec Mon Sep 17 00:00:00 2001 From: PKLite Date: Sun, 8 Sep 2019 00:48:10 -0400 Subject: [PATCH 02/10] Add rank icons back to menu entries Signed-off-by: PKLite (cherry picked from commit f42fbd5624f14169309541f520e00dbe747395a2) --- .../PlayerIndicatorsOverlay.java | 2 +- .../PlayerIndicatorsPlugin.java | 129 +++++++++--------- .../PlayerIndicatorsService.java | 8 -- 3 files changed, 68 insertions(+), 71 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 0888b2cfbe..2bdeebed41 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -134,7 +134,7 @@ public class PlayerIndicatorsOverlay extends Overlay } OverlayUtil.renderActorTextAndImage(graphics, actor, builtString, color, ImageUtil.resizeImage(Objects.requireNonNull(clanManager.getClanImage(clanManager.getRank(actor.getName()))), y, y) - ,x + ACTOR_HORIZONTAL_TEXT_MARGIN, 0); + ,0,ACTOR_HORIZONTAL_TEXT_MARGIN); } else { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java index 46e835316e..9111ada105 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java @@ -63,6 +63,7 @@ import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginType; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ColorUtil; +import net.runelite.client.util.ImageUtil; import net.runelite.client.util.PvPUtil; import net.runelite.http.api.hiscore.HiscoreClient; import net.runelite.http.api.hiscore.HiscoreResult; @@ -307,74 +308,78 @@ public class PlayerIndicatorsPlugin extends Plugin { image = clanManager.getIconNumber(rank); } - } - else if (this.highlightTeam && player.getTeam() > 0 && (localPlayer != null ? localPlayer.getTeam() : -1) == player.getTeam()) - { - if (Arrays.asList(this.locationHashMap.get(PlayerRelation.TEAM)).contains(PlayerIndicationLocation.MENU)) + else if (this.highlightTeam && player.getTeam() > 0 && (localPlayer != null ? localPlayer.getTeam() : -1) == player.getTeam()) { - color = relationColorHashMap.get(PlayerRelation.TEAM); - } - } - else if (this.highlightOther && !player.isClanMember() && !player.isFriend() && !PvPUtil.isAttackable(client, player)) - { - if (Arrays.asList(this.locationHashMap.get(PlayerRelation.OTHER)).contains(PlayerIndicationLocation.MENU)) - { - color = relationColorHashMap.get(PlayerRelation.OTHER); - } - } - else if (this.highlightTargets && !player.isClanMember() && !client.isFriended(player.getName(), - false) && PvPUtil.isAttackable(client, player)) - { - if (Arrays.asList(this.locationHashMap.get(PlayerRelation.TARGET)).contains(PlayerIndicationLocation.MENU)) - { - color = relationColorHashMap.get(PlayerRelation.TARGET); - } - } - else if (this.highlightCallers && isCaller(player)) - { - if (Arrays.asList(this.locationHashMap.get(PlayerRelation.CALLER)).contains(PlayerIndicationLocation.MENU)) - { - color = relationColorHashMap.get(PlayerRelation.CALLER); - } - } - else if (this.highlightCallerTargets && isPile(player)) - { - if (Arrays.asList(this.locationHashMap.get(PlayerRelation.CALLER_TARGET)).contains(PlayerIndicationLocation.MENU)) - { - color = relationColorHashMap.get(PlayerRelation.CALLER_TARGET); - } - } - - if (this.playerSkull && !player.isClanMember() && player.getSkullIcon() != null) - { - image2 = 35; - } - - if (image != -1 || color != null) - { - final MenuEntry[] menuEntries = client.getMenuEntries(); - final MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; - - - if (color != null) - { - // strip out existing '); - if (idx != -1) + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.TEAM)).contains(PlayerIndicationLocation.MENU)) { - target = target.substring(idx + 1); + color = relationColorHashMap.get(PlayerRelation.TEAM); + } + } + else if (this.highlightOther && !player.isClanMember() && !player.isFriend() && !PvPUtil.isAttackable(client, player)) + { + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.OTHER)).contains(PlayerIndicationLocation.MENU)) + { + color = relationColorHashMap.get(PlayerRelation.OTHER); + } + } + else if (this.highlightTargets && !player.isClanMember() && !client.isFriended(player.getName(), + false) && PvPUtil.isAttackable(client, player)) + { + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.TARGET)).contains(PlayerIndicationLocation.MENU)) + { + color = relationColorHashMap.get(PlayerRelation.TARGET); + } + } + else if (this.highlightCallers && isCaller(player)) + { + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.CALLER)).contains(PlayerIndicationLocation.MENU)) + { + color = relationColorHashMap.get(PlayerRelation.CALLER); + } + } + else if (this.highlightCallerTargets && isPile(player)) + { + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.CALLER_TARGET)).contains(PlayerIndicationLocation.MENU)) + { + color = relationColorHashMap.get(PlayerRelation.CALLER_TARGET); + } + } + + if (this.playerSkull && !player.isClanMember() && player.getSkullIcon() != null) + { + image2 = 35; + } + + if (image != -1 || color != null) + { + final MenuEntry[] menuEntries = client.getMenuEntries(); + final MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; + + + if (color != null) + { + // strip out existing '); + if (idx != -1) + { + target = target.substring(idx + 1); + } + + lastEntry.setTarget(ColorUtil.prependColorTag(target, color)); + } + if (image != -1) + { + lastEntry.setTarget("" + lastEntry.getTarget()); } - lastEntry.setTarget(ColorUtil.prependColorTag(target, color)); - } + if (image2 != -1 && this.playerSkull) + { + lastEntry.setTarget("" + lastEntry.getTarget()); + } - if (image2 != -1 && this.playerSkull) - { - lastEntry.setTarget("" + lastEntry.getTarget()); + client.setMenuEntries(menuEntries); } - - client.setMenuEntries(menuEntries); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java index e3c0386ef9..df0e33c9f4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java @@ -33,7 +33,6 @@ 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; @@ -95,42 +94,35 @@ public class PlayerIndicatorsService { consumer.accept(p, PlayerRelation.FRIEND); continue; - } 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); 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); - } } } From 98de4692d3ecd7bbc741e7d82f7662a4ae09e494 Mon Sep 17 00:00:00 2001 From: PKLite Date: Sun, 8 Sep 2019 01:04:09 -0400 Subject: [PATCH 03/10] Remove Hull from default value Signed-off-by: PKLite (cherry picked from commit 5290f2e2630fe357180a756546acac088c985165) --- .../PlayerIndicatorsConfig.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java index 88f1ff5a64..caddcd871a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsConfig.java @@ -35,6 +35,8 @@ import net.runelite.client.config.Stub; @ConfigGroup("playerindicators") public interface PlayerIndicatorsConfig extends Config { + EnumSet defaultPlayerIndicatorMode = EnumSet.complementOf(EnumSet.of(PlayerIndicationLocation.HULL)); + @ConfigItem( position = 0, keyName = "drawOwnName", @@ -69,7 +71,7 @@ public interface PlayerIndicatorsConfig extends Config ) default EnumSet selfIndicatorModes() { - return EnumSet.allOf(PlayerIndicationLocation.class); + return defaultPlayerIndicatorMode; } @ConfigItem( @@ -107,7 +109,7 @@ public interface PlayerIndicatorsConfig extends Config ) default EnumSet friendIndicatorMode() { - return EnumSet.allOf(PlayerIndicationLocation.class); + return defaultPlayerIndicatorMode; } @ConfigItem( @@ -145,7 +147,7 @@ public interface PlayerIndicatorsConfig extends Config ) default EnumSet clanIndicatorModes() { - return EnumSet.allOf(PlayerIndicationLocation.class); + return defaultPlayerIndicatorMode; } @ConfigItem( @@ -195,7 +197,7 @@ public interface PlayerIndicatorsConfig extends Config ) default EnumSet teamIndicatorModes() { - return EnumSet.allOf(PlayerIndicationLocation.class); + return defaultPlayerIndicatorMode; } @ConfigItem( @@ -233,7 +235,7 @@ public interface PlayerIndicatorsConfig extends Config ) default EnumSet targetsIndicatorModes() { - return EnumSet.allOf(PlayerIndicationLocation.class); + return defaultPlayerIndicatorMode; } @ConfigItem( @@ -367,7 +369,7 @@ public interface PlayerIndicatorsConfig extends Config ) default EnumSet otherIndicatorModes() { - return EnumSet.allOf(PlayerIndicationLocation.class); + return defaultPlayerIndicatorMode; } @@ -484,7 +486,7 @@ public interface PlayerIndicatorsConfig extends Config ) default EnumSet callerHighlightOptions() { - return EnumSet.allOf(PlayerIndicationLocation.class); + return defaultPlayerIndicatorMode; } @ConfigItem( @@ -536,7 +538,7 @@ public interface PlayerIndicatorsConfig extends Config ) default EnumSet callerTargetHighlightOptions() { - return EnumSet.allOf(PlayerIndicationLocation.class); + return defaultPlayerIndicatorMode; } From 275013f8e82ea7ecb4329cbbbf5cd10e86973e6a Mon Sep 17 00:00:00 2001 From: PKLite Date: Sun, 8 Sep 2019 01:05:27 -0400 Subject: [PATCH 04/10] Checkstyle fixes Signed-off-by: PKLite (cherry picked from commit 473c651bb13abd414755ea9ba4389ae39b72e9b1) --- .../plugins/playerindicators/PlayerIndicatorsOverlay.java | 2 +- .../client/plugins/playerindicators/PlayerIndicatorsPlugin.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 2bdeebed41..709befd3ff 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -134,7 +134,7 @@ public class PlayerIndicatorsOverlay extends Overlay } OverlayUtil.renderActorTextAndImage(graphics, actor, builtString, color, ImageUtil.resizeImage(Objects.requireNonNull(clanManager.getClanImage(clanManager.getRank(actor.getName()))), y, y) - ,0,ACTOR_HORIZONTAL_TEXT_MARGIN); + ,0 ,ACTOR_HORIZONTAL_TEXT_MARGIN); } else { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java index 9111ada105..554db3a185 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java @@ -63,7 +63,6 @@ import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginType; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ColorUtil; -import net.runelite.client.util.ImageUtil; import net.runelite.client.util.PvPUtil; import net.runelite.http.api.hiscore.HiscoreClient; import net.runelite.http.api.hiscore.HiscoreResult; From 06b87dbd30e8f85a85a7c554081a8f3434f281a9 Mon Sep 17 00:00:00 2001 From: PKLite Date: Sun, 8 Sep 2019 01:16:23 -0400 Subject: [PATCH 05/10] , Signed-off-by: PKLite (cherry picked from commit 5e2d1b1e41e8f1d2075cb1aa428405d2f8a8a511) --- .../plugins/playerindicators/PlayerIndicatorsOverlay.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 709befd3ff..cbca8cd5a6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -133,8 +133,8 @@ public class PlayerIndicatorsOverlay extends Overlay return; } OverlayUtil.renderActorTextAndImage(graphics, actor, builtString, color, - ImageUtil.resizeImage(Objects.requireNonNull(clanManager.getClanImage(clanManager.getRank(actor.getName()))), y, y) - ,0 ,ACTOR_HORIZONTAL_TEXT_MARGIN); + ImageUtil.resizeImage(Objects.requireNonNull(clanManager + .getClanImage(clanManager.getRank(actor.getName()))), y, y),0, ACTOR_HORIZONTAL_TEXT_MARGIN); } else { From 8a43f10599a2cc26d8b2a61f7429080887066e74 Mon Sep 17 00:00:00 2001 From: PKLite Date: Sun, 8 Sep 2019 21:32:50 -0400 Subject: [PATCH 06/10] add config checks to trivia, improve readability Signed-off-by: PKLite (cherry picked from commit 0c672cffaa0f5b98bf7efa48a58b3666d8e47fcc) --- .../PlayerIndicatorsOverlay.java | 2 +- .../PlayerIndicatorsPlugin.java | 2 +- .../PlayerIndicatorsService.java | 53 +++++++++++-------- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index cbca8cd5a6..664b1f69d7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -134,7 +134,7 @@ public class PlayerIndicatorsOverlay extends Overlay } OverlayUtil.renderActorTextAndImage(graphics, actor, builtString, color, ImageUtil.resizeImage(Objects.requireNonNull(clanManager - .getClanImage(clanManager.getRank(actor.getName()))), y, y),0, ACTOR_HORIZONTAL_TEXT_MARGIN); + .getClanImage(clanManager.getRank(actor.getName()))), y, y), 0, ACTOR_HORIZONTAL_TEXT_MARGIN); } else { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java index 554db3a185..759c6b6c71 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java @@ -449,7 +449,7 @@ public class PlayerIndicatorsPlugin extends Plugin * @param actor The player to check * @return true if they are a target, false otherwise */ - private boolean isPile(Actor actor) + public boolean isPile(Actor actor) { if (!(actor instanceof Player)) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java index df0e33c9f4..c9bbb08dbb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java @@ -24,14 +24,12 @@ */ package net.runelite.client.plugins.playerindicators; -import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.function.BiConsumer; import java.util.function.Predicate; import javax.inject.Inject; import javax.inject.Singleton; -import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.Player; import net.runelite.client.util.PvPUtil; @@ -50,7 +48,6 @@ public class PlayerIndicatorsService private final Predicate other; private final Predicate caller; private final Predicate callerTarget; - private final List piles = new ArrayList<>(); @Inject private PlayerIndicatorsService(final Client client, final PlayerIndicatorsPlugin plugin) @@ -58,18 +55,32 @@ public class PlayerIndicatorsService this.client = client; this.plugin = plugin; - 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)); + self = (player) -> (client.getLocalPlayer().equals(player) + && plugin.getLocationHashMap().containsKey(PlayerRelation.SELF)); + + friend = (player) -> (!player.equals(client.getLocalPlayer()) + && client.isFriended(player.getName(), false) + && plugin.getLocationHashMap().containsKey(PlayerRelation.FRIEND)); + + clan = (player) -> (player.isClanMember() && !client.isFriended(player.getName(), false) + && plugin.getLocationHashMap().containsKey(PlayerRelation.CLAN)); + team = (player) -> (Objects.requireNonNull(client.getLocalPlayer()).getTeam() != 0 && !player.isClanMember() - && !client.isFriended(player.getName(), false) && - client.getLocalPlayer().getTeam() == player.getTeam()); + && !client.isFriended(player.getName(), false) + && client.getLocalPlayer().getTeam() == player.getTeam() + && plugin.getLocationHashMap().containsKey(PlayerRelation.TEAM)); + target = (player) -> (!team.test(player) && !clan.test(player) - && !friend.test(player) && PvPUtil.isAttackable(client, player) && !self.test(player)); - caller = plugin::isCaller; - callerTarget = piles::contains; + && !friend.test(player) && PvPUtil.isAttackable(client, player) + && !self.test(player) && plugin.getLocationHashMap().containsKey(PlayerRelation.TARGET)); + + caller = (player) -> (plugin.isCaller(player) && plugin.getLocationHashMap().containsKey(PlayerRelation.CALLER)); + + callerTarget = (player) -> (plugin.isPile(player) && plugin.getLocationHashMap().containsKey(PlayerRelation.CALLER_TARGET)); + other = (player) -> - (!PvPUtil.isAttackable(client, player) && !team.test(player) && !clan.test(player) && !friend.test(player)); + (!PvPUtil.isAttackable(client, player) && !team.test(player) && !clan.test(player) && !friend.test(player) + && plugin.getLocationHashMap().containsKey(PlayerRelation.OTHER)); } @@ -80,47 +91,45 @@ public class PlayerIndicatorsService return; } - piles.clear(); - final List players = client.getPlayers(); for (Player p : players) { - if (self.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.SELF)) + if (self.test(p)) { consumer.accept(p, PlayerRelation.SELF); continue; } - if (friend.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.FRIEND)) + if (friend.test(p)) { consumer.accept(p, PlayerRelation.FRIEND); continue; } - if (clan.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.CLAN)) + if (clan.test(p)) { consumer.accept(p, PlayerRelation.CLAN); continue; } - if (team.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.TEAM)) + if (team.test(p)) { consumer.accept(p, PlayerRelation.TEAM); continue; } - if (target.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.TARGET)) + if (target.test(p)) { consumer.accept(p, PlayerRelation.TARGET); continue; } - if (caller.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.CALLER)) + if (caller.test(p)) { consumer.accept(p, PlayerRelation.CALLER); continue; } - if (callerTarget.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.CALLER_TARGET)) + if (callerTarget.test(p) ) { consumer.accept(p, PlayerRelation.CALLER_TARGET); continue; } - if (other.test(p) && plugin.getLocationHashMap().containsKey(PlayerRelation.OTHER)) + if (other.test(p)) { consumer.accept(p, PlayerRelation.OTHER); } From 98bb51dc09d085bf62f8945462800d3052f0112c Mon Sep 17 00:00:00 2001 From: PKLite Date: Mon, 9 Sep 2019 08:27:18 -0400 Subject: [PATCH 07/10] fix double rendering and a priority issue Signed-off-by: PKLite (cherry picked from commit 1724ad8a468af5bb678030ed77d1485996d72ebb) --- .../plugins/playerindicators/PlayerIndicatorsOverlay.java | 3 ++- .../plugins/playerindicators/PlayerIndicatorsService.java | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 664b1f69d7..8f53af7282 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -124,7 +124,8 @@ public class PlayerIndicatorsOverlay extends Overlay { OverlayUtil.renderActorTextAndImage(graphics, actor, builtString, color, - ImageUtil.resizeImage(skullIcon, y, y), 0, x); + ImageUtil.resizeImage(skullIcon, y, y), ACTOR_OVERHEAD_TEXT_MARGIN, ACTOR_HORIZONTAL_TEXT_MARGIN); + return; } if (plugin.isHighlightClan() && actor.isClanMember() && plugin.isShowClanRanks() && relation == PlayerRelation.CLAN) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java index c9bbb08dbb..cf79ddc9e2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java @@ -71,15 +71,16 @@ public class PlayerIndicatorsService && plugin.getLocationHashMap().containsKey(PlayerRelation.TEAM)); target = (player) -> (!team.test(player) && !clan.test(player) - && !friend.test(player) && PvPUtil.isAttackable(client, player) - && !self.test(player) && plugin.getLocationHashMap().containsKey(PlayerRelation.TARGET)); + && !client.isFriended(player.getName(), false) && PvPUtil.isAttackable(client, player) + && !client.getLocalPlayer().equals(player) && plugin.getLocationHashMap().containsKey(PlayerRelation.TARGET)); caller = (player) -> (plugin.isCaller(player) && plugin.getLocationHashMap().containsKey(PlayerRelation.CALLER)); callerTarget = (player) -> (plugin.isPile(player) && plugin.getLocationHashMap().containsKey(PlayerRelation.CALLER_TARGET)); other = (player) -> - (!PvPUtil.isAttackable(client, player) && !team.test(player) && !clan.test(player) && !friend.test(player) + (!PvPUtil.isAttackable(client, player) && !client.getLocalPlayer().equals(player) + && !team.test(player) && !player.isClanMember() && !client.isFriended(player.getName(), false) && plugin.getLocationHashMap().containsKey(PlayerRelation.OTHER)); } From f779434444564ebe7be3f69e88c89fe0e55330aa Mon Sep 17 00:00:00 2001 From: PKLite Date: Wed, 11 Sep 2019 02:48:10 -0400 Subject: [PATCH 08/10] implement changes Signed-off-by: PKLite (cherry picked from commit 7c0bd47ded9bb7d2cf86f2c96b9656404d2dfc4c) --- .../client/plugins/config/ConfigPanel.java | 5 +- .../PlayerIndicatorsOverlay.java | 149 +++++++++--------- .../PlayerIndicatorsPlugin.java | 127 ++++++++------- 3 files changed, 137 insertions(+), 144 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java index 8d51106ee5..0ac770731c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPanel.java @@ -1283,9 +1283,8 @@ public class ConfigPanel extends PluginPanel Class enumType = cid.getItem().enumClass(); EnumSet enumSet = configManager.getConfiguration(cd.getGroup().value(), - cid.getItem().keyName(), EnumSet.class) != null ? configManager.getConfiguration(cd.getGroup().value(), - cid.getItem().keyName(), EnumSet.class) : EnumSet.noneOf(enumType); - if (enumSet == null || enumSet.contains(null)) + cid.getItem().keyName(), EnumSet.class); + if (enumSet == null) { enumSet = EnumSet.noneOf(enumType); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 8f53af7282..540ad4b14b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -120,107 +120,102 @@ 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) + + if (plugin.isHighlightClan() && actor.isClanMember() && plugin.isShowClanRanks() && relation == PlayerRelation.CLAN) + { + if (clanManager.getRank(actor.getName()) != null) + { + OverlayUtil.renderActorTextAndImage(graphics, actor, builtString, color, + ImageUtil.resizeImage(Objects.requireNonNull(clanManager + .getClanImage(clanManager.getRank(actor.getName()))), y, y), 0, ACTOR_HORIZONTAL_TEXT_MARGIN); + } + } + + if (skulls && actor.getSkullIcon() != null && relation.equals(PlayerRelation.TARGET)) { OverlayUtil.renderActorTextAndImage(graphics, actor, builtString, color, ImageUtil.resizeImage(skullIcon, y, y), ACTOR_OVERHEAD_TEXT_MARGIN, ACTOR_HORIZONTAL_TEXT_MARGIN); - return; - } - 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), 0, ACTOR_HORIZONTAL_TEXT_MARGIN); } + else { OverlayUtil.renderActorTextOverlay(graphics, actor, builtString, color); } } - if (Arrays.asList(plugin.getLocationHashMap() - .getOrDefault(relation, NULL_OBJ)) - .contains(PlayerIndicationLocation.HULL)) + if (actor.getConvexHull() != null && indicationLocations.contains(PlayerIndicationLocation.HULL)) { - if (actor.getConvexHull() == null) - { - return; - } OverlayUtil.renderPolygon(graphics, actor.getConvexHull(), color); } - if (Arrays.asList(plugin.getLocationHashMap() - .getOrDefault(relation, NULL_OBJ)) - .contains(PlayerIndicationLocation.TILE)) + if (indicationLocations.contains(PlayerIndicationLocation.TILE)) { - final Polygon poly = actor.getCanvasTilePoly(); - if (poly != null) + if (actor.getCanvasTilePoly() != null) { - OverlayUtil.renderPolygon(graphics, poly, color); + OverlayUtil.renderPolygon(graphics, actor.getCanvasTilePoly(), color); } } - if (plugin.isShowAgilityLevel() && checkWildy() && plugin.getResultCache().containsKey(actor.getName())) + if (relation.equals(PlayerRelation.TARGET)) { - if (textLocation == null) + if (plugin.isShowAgilityLevel() && checkWildy() && plugin.getResultCache().containsKey(actor.getName())) { - return; - } - - final int level = plugin.getResultCache().get(actor.getName()).getAgility().getLevel(); - - if (plugin.getAgilityFormat() == PlayerIndicatorsPlugin.AgilityFormats.ICONS) - { - - final int width = plugin.isShowCombatLevel() ? graphics.getFontMetrics().stringWidth(name) - + ACTOR_HORIZONTAL_TEXT_MARGIN : graphics.getFontMetrics().stringWidth(name); - - final int height = graphics.getFontMetrics().getHeight(); - if (level >= plugin.getAgilityFirstThreshold()) + if (textLocation == null) { - OverlayUtil.renderImageLocation(graphics, - new Point(textLocation.getX() + 5 + width, - textLocation.getY() - height), - ImageUtil.resizeImage(agilityIcon, height, height)); - } - if (level >= plugin.getAgilitySecondThreshold()) - { - OverlayUtil.renderImageLocation(graphics, - new Point(textLocation.getX() + agilityIcon.getWidth() + width, - textLocation.getY() - height), - ImageUtil.resizeImage(agilityIcon, height, height)); - } - if (level < plugin.getAgilityFirstThreshold()) - { - OverlayUtil.renderImageLocation(graphics, - new Point(textLocation.getX() + 5 + width, - textLocation.getY() - height), - ImageUtil.resizeImage(noAgilityIcon, height, height)); - } - } - else - { - Color agiColor = Color.WHITE; - - if (level >= plugin.getAgilityFirstThreshold()) - { - agiColor = Color.CYAN; - } - else if (level >= plugin.getAgilitySecondThreshold()) - { - agiColor = Color.GREEN; - } - else if (level < plugin.getAgilityFirstThreshold()) - { - agiColor = Color.RED; + return; } - final String n = level + " " + "Agility"; - OverlayUtil.renderActorTextOverlay(graphics, actor, n, agiColor, 60); + final int level = plugin.getResultCache().get(actor.getName()).getAgility().getLevel(); + + if (plugin.getAgilityFormat() == PlayerIndicatorsPlugin.AgilityFormats.ICONS) + { + + final int width = plugin.isShowCombatLevel() ? graphics.getFontMetrics().stringWidth(name) + + ACTOR_HORIZONTAL_TEXT_MARGIN : graphics.getFontMetrics().stringWidth(name); + + final int height = graphics.getFontMetrics().getHeight(); + if (level >= plugin.getAgilityFirstThreshold()) + { + OverlayUtil.renderImageLocation(graphics, + new Point(textLocation.getX() + 5 + width, + textLocation.getY() - height), + ImageUtil.resizeImage(agilityIcon, height, height)); + } + else if (level >= plugin.getAgilitySecondThreshold()) + { + OverlayUtil.renderImageLocation(graphics, + new Point(textLocation.getX() + agilityIcon.getWidth() + width, + textLocation.getY() - height), + ImageUtil.resizeImage(agilityIcon, height, height)); + } + else if (level < plugin.getAgilityFirstThreshold()) + { + OverlayUtil.renderImageLocation(graphics, + new Point(textLocation.getX() + 5 + width, + textLocation.getY() - height), + ImageUtil.resizeImage(noAgilityIcon, height, height)); + } + } + else + { + Color agiColor = Color.WHITE; + + if (level >= plugin.getAgilityFirstThreshold()) + { + agiColor = Color.CYAN; + } + else if (level >= plugin.getAgilitySecondThreshold()) + { + agiColor = Color.GREEN; + } + else if (level < plugin.getAgilityFirstThreshold()) + { + agiColor = Color.RED; + } + + final String n = level + " " + "Agility"; + OverlayUtil.renderActorTextOverlay(graphics, actor, n, agiColor, 60); + } } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java index 759c6b6c71..e19d5e745d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsPlugin.java @@ -78,7 +78,14 @@ import net.runelite.http.api.hiscore.HiscoreResult; public class PlayerIndicatorsPlugin extends Plugin { private static final HiscoreClient HISCORE_CLIENT = new HiscoreClient(); - + private final List callers = new ArrayList<>(); + private final Map colorizedMenus = new ConcurrentHashMap<>(); + private final Map relationColorHashMap = new ConcurrentHashMap<>(); + private final Map locationHashMap = new ConcurrentHashMap<>(); + private final Map callerPiles = new ConcurrentHashMap<>(); + @Getter(AccessLevel.PACKAGE) + private final Map resultCache = new HashMap<>(); + private final ExecutorService executorService = Executors.newFixedThreadPool(100); @Inject @Getter(AccessLevel.NONE) private OverlayManager overlayManager; @@ -100,16 +107,7 @@ public class PlayerIndicatorsPlugin extends Plugin @Inject @Getter(AccessLevel.NONE) private EventBus eventBus; - private ClanMemberRank callerRank; - private final List callers = new ArrayList<>(); - private final Map colorizedMenus = new ConcurrentHashMap<>(); - private final Map relationColorHashMap = new ConcurrentHashMap<>(); - private final Map locationHashMap = new ConcurrentHashMap<>(); - private final Map callerPiles = new ConcurrentHashMap<>(); - @Getter(AccessLevel.PACKAGE) - private final Map resultCache = new HashMap<>(); - private final ExecutorService executorService = Executors.newFixedThreadPool(100); private PlayerIndicatorsPlugin.AgilityFormats agilityFormat; private PlayerIndicatorsPlugin.MinimapSkullLocations skullLocation; private String configCallers; @@ -307,82 +305,83 @@ public class PlayerIndicatorsPlugin extends Plugin { image = clanManager.getIconNumber(rank); } - else if (this.highlightTeam && player.getTeam() > 0 && (localPlayer != null ? localPlayer.getTeam() : -1) == player.getTeam()) + } + else if (this.highlightTeam && player.getTeam() > 0 && (localPlayer != null ? localPlayer.getTeam() : -1) == player.getTeam()) + { + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.TEAM)).contains(PlayerIndicationLocation.MENU)) { - if (Arrays.asList(this.locationHashMap.get(PlayerRelation.TEAM)).contains(PlayerIndicationLocation.MENU)) - { - color = relationColorHashMap.get(PlayerRelation.TEAM); - } + color = relationColorHashMap.get(PlayerRelation.TEAM); } - else if (this.highlightOther && !player.isClanMember() && !player.isFriend() && !PvPUtil.isAttackable(client, player)) + } + else if (this.highlightOther && !player.isClanMember() && !player.isFriend() && !PvPUtil.isAttackable(client, player)) + { + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.OTHER)).contains(PlayerIndicationLocation.MENU)) { - if (Arrays.asList(this.locationHashMap.get(PlayerRelation.OTHER)).contains(PlayerIndicationLocation.MENU)) - { - color = relationColorHashMap.get(PlayerRelation.OTHER); - } + color = relationColorHashMap.get(PlayerRelation.OTHER); } - else if (this.highlightTargets && !player.isClanMember() && !client.isFriended(player.getName(), - false) && PvPUtil.isAttackable(client, player)) + } + else if (this.highlightTargets && !player.isClanMember() && !client.isFriended(player.getName(), + false) && PvPUtil.isAttackable(client, player)) + { + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.TARGET)).contains(PlayerIndicationLocation.MENU)) { - if (Arrays.asList(this.locationHashMap.get(PlayerRelation.TARGET)).contains(PlayerIndicationLocation.MENU)) - { - color = relationColorHashMap.get(PlayerRelation.TARGET); - } + color = relationColorHashMap.get(PlayerRelation.TARGET); } - else if (this.highlightCallers && isCaller(player)) + } + else if (this.highlightCallers && isCaller(player)) + { + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.CALLER)).contains(PlayerIndicationLocation.MENU)) { - if (Arrays.asList(this.locationHashMap.get(PlayerRelation.CALLER)).contains(PlayerIndicationLocation.MENU)) - { - color = relationColorHashMap.get(PlayerRelation.CALLER); - } + color = relationColorHashMap.get(PlayerRelation.CALLER); } - else if (this.highlightCallerTargets && isPile(player)) + } + else if (this.highlightCallerTargets && isPile(player)) + { + if (Arrays.asList(this.locationHashMap.get(PlayerRelation.CALLER_TARGET)).contains(PlayerIndicationLocation.MENU)) { - if (Arrays.asList(this.locationHashMap.get(PlayerRelation.CALLER_TARGET)).contains(PlayerIndicationLocation.MENU)) - { - color = relationColorHashMap.get(PlayerRelation.CALLER_TARGET); - } + color = relationColorHashMap.get(PlayerRelation.CALLER_TARGET); } + } - if (this.playerSkull && !player.isClanMember() && player.getSkullIcon() != null) - { - image2 = 35; - } + if (this.playerSkull && !player.isClanMember() && player.getSkullIcon() != null) + { + image2 = 35; + } - if (image != -1 || color != null) - { - final MenuEntry[] menuEntries = client.getMenuEntries(); - final MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; + if (image != -1 || color != null) + { + final MenuEntry[] menuEntries = client.getMenuEntries(); + final MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; - if (color != null) + if (color != null) + { + // strip out existing '); + if (idx != -1) { - // strip out existing '); - if (idx != -1) - { - target = target.substring(idx + 1); - } - - lastEntry.setTarget(ColorUtil.prependColorTag(target, color)); - } - if (image != -1) - { - lastEntry.setTarget("" + lastEntry.getTarget()); + target = target.substring(idx + 1); } - if (image2 != -1 && this.playerSkull) - { - lastEntry.setTarget("" + lastEntry.getTarget()); - } - - client.setMenuEntries(menuEntries); + lastEntry.setTarget(ColorUtil.prependColorTag(target, color)); } + if (image != -1) + { + lastEntry.setTarget("" + lastEntry.getTarget()); + } + + if (image2 != -1 && this.playerSkull) + { + lastEntry.setTarget("" + lastEntry.getTarget()); + } + + client.setMenuEntries(menuEntries); } } } + private void getCallerList() { if (!this.highlightCallers) From 08b7d75e5c6e030453ece4a3c19c5e905b05bb10 Mon Sep 17 00:00:00 2001 From: PKLite Date: Thu, 12 Sep 2019 03:56:17 -0400 Subject: [PATCH 09/10] fix checkstyle and npe Signed-off-by: PKLite (cherry picked from commit 4596af4a2ca227cf734edfb7b6388466ee1fe8ff) --- .../plugins/playerindicators/PlayerIndicatorsOverlay.java | 1 - .../plugins/playerindicators/PlayerIndicatorsService.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 540ad4b14b..040e37b14f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -28,7 +28,6 @@ package net.runelite.client.plugins.playerindicators; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; -import java.awt.Polygon; import java.awt.image.BufferedImage; import java.util.Arrays; import java.util.List; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java index cf79ddc9e2..4e1e6a866f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsService.java @@ -62,7 +62,7 @@ public class PlayerIndicatorsService && client.isFriended(player.getName(), false) && plugin.getLocationHashMap().containsKey(PlayerRelation.FRIEND)); - clan = (player) -> (player.isClanMember() && !client.isFriended(player.getName(), false) + clan = (player) -> (player.isClanMember() && !client.getLocalPlayer().equals(player) && !client.isFriended(player.getName(), false) && plugin.getLocationHashMap().containsKey(PlayerRelation.CLAN)); team = (player) -> (Objects.requireNonNull(client.getLocalPlayer()).getTeam() != 0 && !player.isClanMember() From 4423c421c7bc47c3f87be1503b1fed5e479de990 Mon Sep 17 00:00:00 2001 From: PKLite Date: Thu, 12 Sep 2019 09:16:41 -0400 Subject: [PATCH 10/10] fix checkstyle and npe Signed-off-by: PKLite --- .../playerindicators/PlayerIndicatorsOverlay.java | 1 + .../runelite/client/ui/overlay/OverlayUtil.java | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java index 040e37b14f..4e96aa08b8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsOverlay.java @@ -127,6 +127,7 @@ public class PlayerIndicatorsOverlay extends Overlay OverlayUtil.renderActorTextAndImage(graphics, actor, builtString, color, ImageUtil.resizeImage(Objects.requireNonNull(clanManager .getClanImage(clanManager.getRank(actor.getName()))), y, y), 0, ACTOR_HORIZONTAL_TEXT_MARGIN); + return; } } diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java index e95f9bc45f..8917b89114 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayUtil.java @@ -286,14 +286,14 @@ public class OverlayUtil public static void renderActorTextAndImage(Graphics2D graphics, Actor actor, String text, Color color, BufferedImage image, int yOffset, int xOffset) { - Point textLocation = new Point(actor.getConvexHull().getBounds().x + xOffset, - actor.getConvexHull().getBounds().y + yOffset); + Point textLocation = actor.getCanvasTextLocation(graphics, text, actor.getLogicalHeight() + yOffset); - renderImageLocation(graphics, textLocation, image); - xOffset = image.getWidth() + 1; - yOffset = (image.getHeight() - (int) graphics.getFontMetrics().getStringBounds(text, graphics).getHeight()); - textLocation = new Point(textLocation.getX() + xOffset, textLocation.getY() + image.getHeight() - yOffset); - renderTextLocation(graphics, textLocation, text, color); + if (textLocation != null) + { + renderImageLocation(graphics, textLocation, image); + textLocation = new Point(textLocation.getX() + xOffset , textLocation.getY()); + renderTextLocation(graphics, textLocation, text, color); + } } public static void renderTextLocation(Graphics2D graphics, String txtString, int fontSize, int fontStyle, Color fontColor, Point canvasPoint, boolean shadows, int yOffset)