playerindicators: code conventions
This commit is contained in:
@@ -67,6 +67,7 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List indicationLocations = Arrays.asList(plugin.getLocationHashMap().get(relation));
|
final List indicationLocations = Arrays.asList(plugin.getLocationHashMap().get(relation));
|
||||||
final Color color = plugin.getRelationColorHashMap().get(relation);
|
final Color color = plugin.getRelationColorHashMap().get(relation);
|
||||||
|
|
||||||
@@ -92,8 +93,8 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay
|
|||||||
}
|
}
|
||||||
if (actor.getSkullIcon() != null && plugin.isPlayerSkull() && actor.getSkullIcon() == SkullIcon.SKULL)
|
if (actor.getSkullIcon() != null && plugin.isPlayerSkull() && actor.getSkullIcon() == SkullIcon.SKULL)
|
||||||
{
|
{
|
||||||
int width = graphics.getFontMetrics().stringWidth(name);
|
final int width = graphics.getFontMetrics().stringWidth(name);
|
||||||
int height = graphics.getFontMetrics().getHeight();
|
final int height = graphics.getFontMetrics().getHeight();
|
||||||
if (plugin.getSkullLocation().equals(PlayerIndicatorsPlugin.MinimapSkullLocations.AFTER_NAME))
|
if (plugin.getSkullLocation().equals(PlayerIndicatorsPlugin.MinimapSkullLocations.AFTER_NAME))
|
||||||
{
|
{
|
||||||
OverlayUtil.renderImageLocation(graphics, new Point(minimapLocation.getX()
|
OverlayUtil.renderImageLocation(graphics, new Point(minimapLocation.getX()
|
||||||
@@ -105,8 +106,7 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay
|
|||||||
OverlayUtil.renderImageLocation(graphics, new Point(minimapLocation.getX(),
|
OverlayUtil.renderImageLocation(graphics, new Point(minimapLocation.getX(),
|
||||||
minimapLocation.getY() - height),
|
minimapLocation.getY() - height),
|
||||||
ImageUtil.resizeImage(skullIcon, height, height));
|
ImageUtil.resizeImage(skullIcon, height, height));
|
||||||
minimapLocation = new Point(minimapLocation.getX() + skullIcon.getWidth(),
|
minimapLocation = new Point(minimapLocation.getX() + skullIcon.getWidth(), minimapLocation.getY());
|
||||||
minimapLocation.getY());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color);
|
OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color);
|
||||||
|
|||||||
@@ -95,11 +95,13 @@ public class PlayerIndicatorsOverlay extends Overlay
|
|||||||
String name = actor.getName();
|
String name = actor.getName();
|
||||||
final boolean skulls = plugin.isPlayerSkull();
|
final boolean skulls = plugin.isPlayerSkull();
|
||||||
final int zOffset = actor.getLogicalHeight() + ACTOR_OVERHEAD_TEXT_MARGIN;
|
final int zOffset = actor.getLogicalHeight() + ACTOR_OVERHEAD_TEXT_MARGIN;
|
||||||
Point textLocation = actor.getCanvasTextLocation(graphics, name, zOffset);
|
final Point textLocation = actor.getCanvasTextLocation(graphics, name, zOffset);
|
||||||
|
|
||||||
if (plugin.isShowCombatLevel())
|
if (plugin.isShowCombatLevel())
|
||||||
{
|
{
|
||||||
name = name + " (" + actor.getCombatLevel() + ")";
|
name = name + " (" + actor.getCombatLevel() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.isUnchargedGlory())
|
if (plugin.isUnchargedGlory())
|
||||||
{
|
{
|
||||||
if (actor.getPlayerAppearance().getEquipmentId(KitType.AMULET) == ItemID.AMULET_OF_GLORY)
|
if (actor.getPlayerAppearance().getEquipmentId(KitType.AMULET) == ItemID.AMULET_OF_GLORY)
|
||||||
@@ -107,6 +109,7 @@ public class PlayerIndicatorsOverlay extends Overlay
|
|||||||
name += " (glory)";
|
name += " (glory)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.isPlayerSkull() && actor.getSkullIcon() != null)
|
if (plugin.isPlayerSkull() && actor.getSkullIcon() != null)
|
||||||
{
|
{
|
||||||
int x = graphics.getFontMetrics().stringWidth(name);
|
int x = graphics.getFontMetrics().stringWidth(name);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
@@ -64,82 +65,57 @@ import net.runelite.client.util.PvPUtil;
|
|||||||
tags = {"highlight", "minimap", "overlay", "players", "pklite"}
|
tags = {"highlight", "minimap", "overlay", "players", "pklite"}
|
||||||
)
|
)
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@Getter(AccessLevel.PACKAGE)
|
||||||
public class PlayerIndicatorsPlugin extends Plugin
|
public class PlayerIndicatorsPlugin extends Plugin
|
||||||
{
|
{
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
private PlayerIndicatorsConfig config;
|
private PlayerIndicatorsConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
private PlayerIndicatorsOverlay playerIndicatorsOverlay;
|
private PlayerIndicatorsOverlay playerIndicatorsOverlay;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
private PlayerIndicatorsMinimapOverlay playerIndicatorsMinimapOverlay;
|
private PlayerIndicatorsMinimapOverlay playerIndicatorsMinimapOverlay;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
private ClanManager clanManager;
|
private ClanManager clanManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean highlightOwnPlayer;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean highlightFriends;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean highlightClan;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean highlightTeam;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean highlightOther;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean showClanRanks;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean highlightTargets;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean showAgilityLevel;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private int agilityFirstThreshold;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private int agilitySecondThreshold;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private PlayerIndicatorsPlugin.AgilityFormats agilityFormat;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean showCombatLevel;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean playerSkull;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private PlayerIndicatorsPlugin.MinimapSkullLocations skullLocation;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean targetRisk;
|
|
||||||
private boolean useClanchatRanks;
|
|
||||||
private ClanMemberRank callerRank;
|
private ClanMemberRank callerRank;
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private String configCallers;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean highlightCallers;
|
|
||||||
@Getter
|
|
||||||
private boolean highlightCallerTargets;
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean unchargedGlory;
|
|
||||||
@Getter
|
|
||||||
private ConcurrentHashMap<String, Actor> callerPiles = new ConcurrentHashMap<>();
|
|
||||||
@Getter
|
|
||||||
private ConcurrentHashMap<PlayerRelation, Color> relationColorHashMap = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private ConcurrentHashMap<PlayerRelation, Object[]> locationHashMap = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private ConcurrentHashMap<Player, PlayerRelation> colorizedMenus = new ConcurrentHashMap<>();
|
|
||||||
@Getter
|
|
||||||
private List<String> callers = new ArrayList<>();
|
private List<String> callers = new ArrayList<>();
|
||||||
|
private Map<Player, PlayerRelation> colorizedMenus = new ConcurrentHashMap<>();
|
||||||
|
private Map<PlayerRelation, Color> relationColorHashMap = new ConcurrentHashMap<>();
|
||||||
|
private Map<PlayerRelation, Object[]> locationHashMap = new ConcurrentHashMap<>();
|
||||||
|
private Map<String, Actor> callerPiles = new ConcurrentHashMap<>();
|
||||||
|
private PlayerIndicatorsPlugin.AgilityFormats agilityFormat;
|
||||||
|
private PlayerIndicatorsPlugin.MinimapSkullLocations skullLocation;
|
||||||
|
private String configCallers;
|
||||||
|
private boolean highlightCallerTargets;
|
||||||
|
private boolean highlightCallers;
|
||||||
|
private boolean highlightClan;
|
||||||
|
private boolean highlightFriends;
|
||||||
|
private boolean highlightOther;
|
||||||
|
private boolean highlightOwnPlayer;
|
||||||
|
private boolean highlightTargets;
|
||||||
|
private boolean highlightTeam;
|
||||||
|
private boolean playerSkull;
|
||||||
|
private boolean showAgilityLevel;
|
||||||
|
private boolean showClanRanks;
|
||||||
|
private boolean showCombatLevel;
|
||||||
|
private boolean targetRisk;
|
||||||
|
private boolean unchargedGlory;
|
||||||
|
private boolean useClanchatRanks;
|
||||||
|
private int agilityFirstThreshold;
|
||||||
|
private int agilitySecondThreshold;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
PlayerIndicatorsConfig provideConfig(ConfigManager configManager)
|
PlayerIndicatorsConfig provideConfig(ConfigManager configManager)
|
||||||
@@ -150,12 +126,12 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
@Override
|
@Override
|
||||||
protected void startUp() throws Exception
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
updateConfig();
|
updateConfig();
|
||||||
addSubscriptions();
|
addSubscriptions();
|
||||||
|
|
||||||
overlayManager.add(playerIndicatorsOverlay);
|
overlayManager.add(playerIndicatorsOverlay);
|
||||||
overlayManager.add(playerIndicatorsMinimapOverlay);
|
overlayManager.add(playerIndicatorsMinimapOverlay);
|
||||||
|
|
||||||
getCallerList();
|
getCallerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,15 +155,7 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
|
|
||||||
private void onInteractingChanged(InteractingChanged event)
|
private void onInteractingChanged(InteractingChanged event)
|
||||||
{
|
{
|
||||||
if (!this.highlightCallerTargets || event.getSource() == null)
|
if (!this.highlightCallerTargets || event.getSource() == null || callers.isEmpty() || !isCaller(event.getSource()))
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (callers.isEmpty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!isCaller(event.getSource()))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -199,17 +167,14 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
if (event.getTarget() == null)
|
if (event.getTarget() == null)
|
||||||
{
|
{
|
||||||
callerPiles.remove(caller.getName());
|
callerPiles.remove(caller.getName());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
callerPiles.replace(caller.getName(), event.getTarget());
|
||||||
callerPiles.replace(caller.getName(), event.getTarget());
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
callerPiles.put(caller.getName(), event.getTarget());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
callerPiles.put(caller.getName(), event.getTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onConfigChanged(ConfigChanged event)
|
private void onConfigChanged(ConfigChanged event)
|
||||||
@@ -255,7 +220,7 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
|| type == RUNELITE.getId())
|
|| type == RUNELITE.getId())
|
||||||
{
|
{
|
||||||
final Player localPlayer = client.getLocalPlayer();
|
final Player localPlayer = client.getLocalPlayer();
|
||||||
Player[] players = client.getCachedPlayers();
|
final Player[] players = client.getCachedPlayers();
|
||||||
Player player = null;
|
Player player = null;
|
||||||
|
|
||||||
if (identifier >= 0 && identifier < players.length)
|
if (identifier >= 0 && identifier < players.length)
|
||||||
@@ -336,15 +301,15 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
|
|
||||||
if (image != -1 || color != null)
|
if (image != -1 || color != null)
|
||||||
{
|
{
|
||||||
MenuEntry[] menuEntries = client.getMenuEntries();
|
final MenuEntry[] menuEntries = client.getMenuEntries();
|
||||||
MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
|
final MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
|
||||||
|
|
||||||
|
|
||||||
if (color != null)
|
if (color != null)
|
||||||
{
|
{
|
||||||
// strip out existing <col...
|
// strip out existing <col...
|
||||||
String target = lastEntry.getTarget();
|
String target = lastEntry.getTarget();
|
||||||
int idx = target.indexOf('>');
|
final int idx = target.indexOf('>');
|
||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
{
|
{
|
||||||
target = target.substring(idx + 1);
|
target = target.substring(idx + 1);
|
||||||
@@ -352,11 +317,7 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
|
|
||||||
lastEntry.setTarget(ColorUtil.prependColorTag(target, color));
|
lastEntry.setTarget(ColorUtil.prependColorTag(target, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if (image != -1 && config.showClanRanks() || image != -1 && config.rightClickOverhead())
|
|
||||||
{
|
|
||||||
lastEntry.setTarget(lastEntry.getTarget() + "<img=" + image + ">");
|
|
||||||
}*/
|
|
||||||
if (image2 != -1 && this.playerSkull)
|
if (image2 != -1 && this.playerSkull)
|
||||||
{
|
{
|
||||||
lastEntry.setTarget("<img=" + image2 + ">" + lastEntry.getTarget());
|
lastEntry.setTarget("<img=" + image2 + ">" + lastEntry.getTarget());
|
||||||
@@ -373,7 +334,9 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callers.clear();
|
callers.clear();
|
||||||
|
|
||||||
if (this.useClanchatRanks && client.getClanMembers() != null)
|
if (this.useClanchatRanks && client.getClanMembers() != null)
|
||||||
{
|
{
|
||||||
for (ClanMember clanMember : client.getClanMembers())
|
for (ClanMember clanMember : client.getClanMembers())
|
||||||
@@ -384,30 +347,32 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.configCallers.contains(","))
|
if (this.configCallers.contains(","))
|
||||||
{
|
{
|
||||||
callers.addAll(Arrays.asList(this.configCallers.split(",")));
|
callers.addAll(Arrays.asList(this.configCallers.split(",")));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (!this.configCallers.equals(""))
|
||||||
{
|
{
|
||||||
if (!this.configCallers.equals(""))
|
callers.add(this.configCallers);
|
||||||
{
|
|
||||||
callers.add(this.configCallers);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a player is a caller
|
* Checks if a player is a caller
|
||||||
|
*
|
||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
* @return true if they are, false otherwise
|
* @return true if they are, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isCaller(Actor player)
|
boolean isCaller(Actor player)
|
||||||
{
|
{
|
||||||
if (player == null || player.getName() == null)
|
if (player == null || player.getName() == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callers.size() > 0)
|
if (callers.size() > 0)
|
||||||
{
|
{
|
||||||
for (String name : callers)
|
for (String name : callers)
|
||||||
@@ -425,20 +390,18 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a player is currently a target of any of the current callers
|
* Checks if a player is currently a target of any of the current callers
|
||||||
|
*
|
||||||
* @param actor The player to check
|
* @param actor The player to check
|
||||||
* @return true if they are a target, false otherwise
|
* @return true if they are a target, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isPile(Actor actor)
|
private boolean isPile(Actor actor)
|
||||||
{
|
{
|
||||||
if (!(actor instanceof Player))
|
if (!(actor instanceof Player))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (callerPiles.containsValue(actor))
|
|
||||||
{
|
return callerPiles.containsValue(actor);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -530,6 +493,4 @@ public class PlayerIndicatorsPlugin extends Plugin
|
|||||||
TEXT,
|
TEXT,
|
||||||
ICONS
|
ICONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,9 +79,11 @@ public class PlayerIndicatorsService
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
piles.clear();
|
piles.clear();
|
||||||
|
|
||||||
final List<Player> players = client.getPlayers();
|
final List<Player> players = client.getPlayers();
|
||||||
|
|
||||||
if (plugin.isHighlightOwnPlayer())
|
if (plugin.isHighlightOwnPlayer())
|
||||||
{
|
{
|
||||||
players.stream().filter(self).forEach(p -> consumer.accept(p, PlayerRelation.SELF));
|
players.stream().filter(self).forEach(p -> consumer.accept(p, PlayerRelation.SELF));
|
||||||
|
|||||||
Reference in New Issue
Block a user