playerindicators: code conventions

This commit is contained in:
Ganom
2019-08-28 21:01:27 -04:00
parent 201e86a0e0
commit 9bae5a89d8
4 changed files with 69 additions and 103 deletions

View File

@@ -67,6 +67,7 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay
{
return;
}
final List indicationLocations = Arrays.asList(plugin.getLocationHashMap().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)
{
int width = graphics.getFontMetrics().stringWidth(name);
int height = graphics.getFontMetrics().getHeight();
final int width = graphics.getFontMetrics().stringWidth(name);
final int height = graphics.getFontMetrics().getHeight();
if (plugin.getSkullLocation().equals(PlayerIndicatorsPlugin.MinimapSkullLocations.AFTER_NAME))
{
OverlayUtil.renderImageLocation(graphics, new Point(minimapLocation.getX()
@@ -105,8 +106,7 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay
OverlayUtil.renderImageLocation(graphics, new Point(minimapLocation.getX(),
minimapLocation.getY() - height),
ImageUtil.resizeImage(skullIcon, height, height));
minimapLocation = new Point(minimapLocation.getX() + skullIcon.getWidth(),
minimapLocation.getY());
minimapLocation = new Point(minimapLocation.getX() + skullIcon.getWidth(), minimapLocation.getY());
}
}
OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color);

View File

@@ -95,11 +95,13 @@ public class PlayerIndicatorsOverlay extends Overlay
String name = actor.getName();
final boolean skulls = plugin.isPlayerSkull();
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())
{
name = name + " (" + actor.getCombatLevel() + ")";
}
if (plugin.isUnchargedGlory())
{
if (actor.getPlayerAppearance().getEquipmentId(KitType.AMULET) == ItemID.AMULET_OF_GLORY)
@@ -107,6 +109,7 @@ public class PlayerIndicatorsOverlay extends Overlay
name += " (glory)";
}
}
if (plugin.isPlayerSkull() && actor.getSkullIcon() != null)
{
int x = graphics.getFontMetrics().stringWidth(name);

View File

@@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -64,82 +65,57 @@ import net.runelite.client.util.PvPUtil;
tags = {"highlight", "minimap", "overlay", "players", "pklite"}
)
@Singleton
@Getter(AccessLevel.PACKAGE)
public class PlayerIndicatorsPlugin extends Plugin
{
@Inject
@Getter(AccessLevel.NONE)
private OverlayManager overlayManager;
@Inject
@Getter(AccessLevel.NONE)
private PlayerIndicatorsConfig config;
@Inject
@Getter(AccessLevel.NONE)
private PlayerIndicatorsOverlay playerIndicatorsOverlay;
@Inject
@Getter(AccessLevel.NONE)
private PlayerIndicatorsMinimapOverlay playerIndicatorsMinimapOverlay;
@Inject
@Getter(AccessLevel.NONE)
private Client client;
@Inject
@Getter(AccessLevel.NONE)
private ClanManager clanManager;
@Inject
@Getter(AccessLevel.NONE)
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;
@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 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
PlayerIndicatorsConfig provideConfig(ConfigManager configManager)
@@ -150,12 +126,12 @@ public class PlayerIndicatorsPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
updateConfig();
addSubscriptions();
overlayManager.add(playerIndicatorsOverlay);
overlayManager.add(playerIndicatorsMinimapOverlay);
getCallerList();
}
@@ -179,15 +155,7 @@ public class PlayerIndicatorsPlugin extends Plugin
private void onInteractingChanged(InteractingChanged event)
{
if (!this.highlightCallerTargets || event.getSource() == null)
{
return;
}
if (callers.isEmpty())
{
return;
}
if (!isCaller(event.getSource()))
if (!this.highlightCallerTargets || event.getSource() == null || callers.isEmpty() || !isCaller(event.getSource()))
{
return;
}
@@ -199,17 +167,14 @@ public class PlayerIndicatorsPlugin extends Plugin
if (event.getTarget() == null)
{
callerPiles.remove(caller.getName());
return;
}
else
{
callerPiles.replace(caller.getName(), event.getTarget());
}
}
else
{
callerPiles.put(caller.getName(), event.getTarget());
callerPiles.replace(caller.getName(), event.getTarget());
return;
}
callerPiles.put(caller.getName(), event.getTarget());
}
private void onConfigChanged(ConfigChanged event)
@@ -255,7 +220,7 @@ public class PlayerIndicatorsPlugin extends Plugin
|| type == RUNELITE.getId())
{
final Player localPlayer = client.getLocalPlayer();
Player[] players = client.getCachedPlayers();
final Player[] players = client.getCachedPlayers();
Player player = null;
if (identifier >= 0 && identifier < players.length)
@@ -336,15 +301,15 @@ public class PlayerIndicatorsPlugin extends Plugin
if (image != -1 || color != null)
{
MenuEntry[] menuEntries = client.getMenuEntries();
MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
final MenuEntry[] menuEntries = client.getMenuEntries();
final MenuEntry lastEntry = menuEntries[menuEntries.length - 1];
if (color != null)
{
// strip out existing <col...
String target = lastEntry.getTarget();
int idx = target.indexOf('>');
final int idx = target.indexOf('>');
if (idx != -1)
{
target = target.substring(idx + 1);
@@ -352,11 +317,7 @@ public class PlayerIndicatorsPlugin extends Plugin
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)
{
lastEntry.setTarget("<img=" + image2 + ">" + lastEntry.getTarget());
@@ -373,7 +334,9 @@ public class PlayerIndicatorsPlugin extends Plugin
{
return;
}
callers.clear();
if (this.useClanchatRanks && client.getClanMembers() != null)
{
for (ClanMember clanMember : client.getClanMembers())
@@ -384,30 +347,32 @@ public class PlayerIndicatorsPlugin extends Plugin
}
}
}
if (this.configCallers.contains(","))
{
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
*
* @param player The player to check
* @return true if they are, false otherwise
*/
public boolean isCaller(Actor player)
boolean isCaller(Actor player)
{
if (player == null || player.getName() == null)
{
return false;
}
if (callers.size() > 0)
{
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
*
* @param actor The player to check
* @return true if they are a target, false otherwise
*/
public boolean isPile(Actor actor)
private boolean isPile(Actor actor)
{
if (!(actor instanceof Player))
{
return false;
}
if (callerPiles.containsValue(actor))
{
return true;
}
return false;
return callerPiles.containsValue(actor);
}
@@ -530,6 +493,4 @@ public class PlayerIndicatorsPlugin extends Plugin
TEXT,
ICONS
}
}

View File

@@ -79,9 +79,11 @@ public class PlayerIndicatorsService
{
return;
}
piles.clear();
final List<Player> players = client.getPlayers();
if (plugin.isHighlightOwnPlayer())
{
players.stream().filter(self).forEach(p -> consumer.accept(p, PlayerRelation.SELF));