fixes #696 and adds the intended functionality
some slight cleanup as well
This commit is contained in:
@@ -35,10 +35,10 @@ import net.runelite.client.config.Stub;
|
||||
public interface PileIndicatorsConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
keyName = "playerPilesStub",
|
||||
name = "Player Piles",
|
||||
description = "",
|
||||
position = 0
|
||||
keyName = "playerPilesStub",
|
||||
name = "Player Piles",
|
||||
description = "",
|
||||
position = 0
|
||||
)
|
||||
default Stub playerPilesStub()
|
||||
{
|
||||
@@ -46,11 +46,11 @@ public interface PileIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
keyName = "enablePlayers",
|
||||
name = "Enable Player Piling",
|
||||
description = "Enable the option to highlight players when they pile.",
|
||||
parent = "playerPilesStub"
|
||||
position = 1,
|
||||
keyName = "enablePlayers",
|
||||
name = "Enable Player Piling",
|
||||
description = "Enable the option to highlight players when they pile.",
|
||||
parent = "playerPilesStub"
|
||||
)
|
||||
default boolean enablePlayers()
|
||||
{
|
||||
@@ -58,11 +58,11 @@ public interface PileIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "wildyOnlyPlayer",
|
||||
name = "Wilderness Only",
|
||||
description = "Show player piling only when in the Wilderness.",
|
||||
parent = "playerPilesStub"
|
||||
position = 2,
|
||||
keyName = "wildyOnlyPlayer",
|
||||
name = "Wilderness Only",
|
||||
description = "Show player piling only when in the Wilderness.",
|
||||
parent = "playerPilesStub"
|
||||
)
|
||||
default boolean wildyOnlyPlayer()
|
||||
{
|
||||
@@ -70,22 +70,22 @@ public interface PileIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
keyName = "playerPileColor",
|
||||
name = "Player Pile Color",
|
||||
description = "Color used for player piles.",
|
||||
parent = "playerPilesStub"
|
||||
position = 3,
|
||||
keyName = "playerPileColor",
|
||||
name = "Player Pile Color",
|
||||
description = "Color used for player piles.",
|
||||
parent = "playerPilesStub"
|
||||
)
|
||||
default Color playerPileColor()
|
||||
{
|
||||
return Color.RED;
|
||||
}
|
||||
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "npcPilesStub",
|
||||
name = "NPC Piles",
|
||||
description = "",
|
||||
position = 4
|
||||
keyName = "npcPilesStub",
|
||||
name = "NPC Piles",
|
||||
description = "",
|
||||
position = 4
|
||||
)
|
||||
default Stub npcPilesStub()
|
||||
{
|
||||
@@ -93,11 +93,11 @@ public interface PileIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
keyName = "enableNPCS",
|
||||
name = "Enable NPC Piling",
|
||||
description = "Enable the option to highlight NPCs when they pile.",
|
||||
parent = "npcPilesStub"
|
||||
position = 5,
|
||||
keyName = "enableNPCS",
|
||||
name = "Enable NPC Piling",
|
||||
description = "Enable the option to highlight NPCs when they pile.",
|
||||
parent = "npcPilesStub"
|
||||
)
|
||||
default boolean enableNPCS()
|
||||
{
|
||||
@@ -105,11 +105,11 @@ public interface PileIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 6,
|
||||
keyName = "npcPileColor",
|
||||
name = "NPC Pile Color",
|
||||
description = "Color used for NPC piles.",
|
||||
parent = "npcPilesStub"
|
||||
position = 6,
|
||||
keyName = "npcPileColor",
|
||||
name = "NPC Pile Color",
|
||||
description = "Color used for NPC piles.",
|
||||
parent = "npcPilesStub"
|
||||
)
|
||||
default Color npcPileColor()
|
||||
{
|
||||
@@ -117,10 +117,10 @@ public interface PileIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "mixedPilesStub",
|
||||
name = "Mixed Piles",
|
||||
description = "",
|
||||
position = 7
|
||||
keyName = "mixedPilesStub",
|
||||
name = "Mixed Piles",
|
||||
description = "",
|
||||
position = 7
|
||||
)
|
||||
default Stub mixedPilesStub()
|
||||
{
|
||||
@@ -128,11 +128,11 @@ public interface PileIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 8,
|
||||
keyName = "mixedPileColor",
|
||||
name = "Mixed Pile Color",
|
||||
description = "Color used for mixed piles.",
|
||||
parent = "mixedPilesStub"
|
||||
position = 8,
|
||||
keyName = "mixedPileColor",
|
||||
name = "Mixed Pile Color",
|
||||
description = "Color used for mixed piles.",
|
||||
parent = "mixedPilesStub"
|
||||
)
|
||||
default Color mixedPileColor()
|
||||
{
|
||||
@@ -140,10 +140,10 @@ public interface PileIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "pilesSizeStub",
|
||||
name = "Pile size",
|
||||
description = "",
|
||||
position = 9
|
||||
keyName = "pilesSizeStub",
|
||||
name = "Pile size",
|
||||
description = "",
|
||||
position = 9
|
||||
)
|
||||
default Stub pilesSizeStub()
|
||||
{
|
||||
@@ -151,14 +151,14 @@ public interface PileIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@Range(
|
||||
min = 2
|
||||
min = 2
|
||||
)
|
||||
@ConfigItem(
|
||||
position = 10,
|
||||
keyName = "minimumPileSize",
|
||||
name = "Minimum Pile Size",
|
||||
description = "Any pile under this size will not show up. (Minimum: 2)",
|
||||
parent = "pilesSizeStub"
|
||||
position = 10,
|
||||
keyName = "minimumPileSize",
|
||||
name = "Minimum Pile Size",
|
||||
description = "Any pile under this size will not show up. (Minimum: 2)",
|
||||
parent = "pilesSizeStub"
|
||||
)
|
||||
default int minimumPileSize()
|
||||
{
|
||||
@@ -166,10 +166,10 @@ public interface PileIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "miscellaneousStub",
|
||||
name = "Miscellaneous",
|
||||
description = "",
|
||||
position = 11
|
||||
keyName = "miscellaneousStub",
|
||||
name = "Miscellaneous",
|
||||
description = "",
|
||||
position = 11
|
||||
)
|
||||
default Stub miscellaneousStub()
|
||||
{
|
||||
@@ -177,11 +177,11 @@ public interface PileIndicatorsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 12,
|
||||
keyName = "numberOnly",
|
||||
name = "Display Number Only",
|
||||
description = "Shorten \"PILE SIZE: 1\" to \"1\"",
|
||||
parent = "miscellaneousStub"
|
||||
position = 12,
|
||||
keyName = "numberOnly",
|
||||
name = "Display Number Only",
|
||||
description = "Shorten \"PILE SIZE: 1\" to \"1\"",
|
||||
parent = "miscellaneousStub"
|
||||
)
|
||||
default boolean numberOnly()
|
||||
{
|
||||
@@ -190,24 +190,26 @@ public interface PileIndicatorsConfig extends Config
|
||||
|
||||
@ConfigItem(
|
||||
position = 13,
|
||||
keyName = "drawPileTile",
|
||||
name = "Draw Pile Tile",
|
||||
description = "Draws the tile of the pile for best visibility.",
|
||||
parent = "miscellaneousStub"
|
||||
)
|
||||
default boolean drawPileTile()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 14,
|
||||
keyName = "drawPileHull",
|
||||
name = "Draws the hull of the pile.",
|
||||
description = "Draws the hull of the pile for best visibility."
|
||||
name = "Draw Pile Convex Hull",
|
||||
description = "Draws the hull of the pile for best visibility.",
|
||||
parent = "miscellaneousStub"
|
||||
)
|
||||
default boolean drawPileHull()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 14,
|
||||
keyName = "highlightPile",
|
||||
name = "Highlight Pile",
|
||||
description = "Highlights Pile Onscreen"
|
||||
)
|
||||
default boolean highlightPile()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,12 +26,15 @@ package net.runelite.client.plugins.pileindicators;
|
||||
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.client.plugins.playerindicators.PlayerIndicatorsService;
|
||||
import net.runelite.client.ui.overlay.*;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
import net.runelite.client.ui.overlay.OverlayUtil;
|
||||
|
||||
public class PileIndicatorsOverlay extends Overlay
|
||||
{
|
||||
@@ -39,16 +42,14 @@ public class PileIndicatorsOverlay extends Overlay
|
||||
private final Client client;
|
||||
private final PileIndicatorsPlugin plugin;
|
||||
private final PileIndicatorsConfig config;
|
||||
private final PlayerIndicatorsService playerIndicatorsService;
|
||||
|
||||
@Inject
|
||||
PileIndicatorsOverlay(final Client client, final PileIndicatorsPlugin plugin, final PileIndicatorsConfig config, PlayerIndicatorsService playerIndicatorsService)
|
||||
PileIndicatorsOverlay(final Client client, final PileIndicatorsPlugin plugin, final PileIndicatorsConfig config)
|
||||
{
|
||||
super(plugin);
|
||||
this.client = client;
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.playerIndicatorsService = playerIndicatorsService;
|
||||
|
||||
setLayer(OverlayLayer.ABOVE_SCENE);
|
||||
setPosition(OverlayPosition.DYNAMIC);
|
||||
@@ -60,18 +61,7 @@ public class PileIndicatorsOverlay extends Overlay
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
ArrayList<ArrayList<Actor>> stackList = plugin.getStacks();
|
||||
if (config.drawPileHull())
|
||||
{
|
||||
playerIndicatorsService.forEachPlayer((player, color) ->
|
||||
{
|
||||
if (plugin.isPile(player))
|
||||
{
|
||||
Polygon objectClickbox = player.getConvexHull();
|
||||
|
||||
renderPoly(graphics, config.playerPileColor(), objectClickbox);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (stackList != null)
|
||||
{
|
||||
for (ArrayList<Actor> actorArrayList : stackList)
|
||||
@@ -79,22 +69,21 @@ public class PileIndicatorsOverlay extends Overlay
|
||||
PileType pileType = plugin.getPileType(actorArrayList);
|
||||
Color pileColor = plugin.getColorByPileType(pileType);
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
Actor actorToRender = actorArrayList.get(0); //guaranteed to have at least two players
|
||||
final String text;
|
||||
if (config.numberOnly())
|
||||
final String pileTypeStr = pileType == PileType.PLAYER_PILE ? "PLAYER" : pileType == PileType.NPC_PILE ? "NPC" : pileType == PileType.MIXED_PILE ? "MIXED" : "";
|
||||
final String text = config.numberOnly() ? "" + actorArrayList.size() : (pileTypeStr + " PILE SIZE: " + actorArrayList.size());
|
||||
if (config.drawPileTile())
|
||||
{
|
||||
text = "" + actorArrayList.size();
|
||||
OverlayUtil.renderPolygon(graphics, actorToRender.getCanvasTilePoly(), pileColor);
|
||||
}
|
||||
else
|
||||
if (config.drawPileHull())
|
||||
{
|
||||
text = "PILE SIZE: " + actorArrayList.size();
|
||||
OverlayUtil.renderPolygon(graphics, actorToRender.getConvexHull(), pileColor);
|
||||
}
|
||||
|
||||
OverlayUtil.renderPolygon(graphics, actorToRender.getCanvasTilePoly(), pileColor);
|
||||
OverlayUtil.renderTextLocation(graphics, actorToRender.getCanvasTextLocation(graphics, text, 40), text, pileColor);
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
@@ -104,16 +93,4 @@ public class PileIndicatorsOverlay extends Overlay
|
||||
return null;
|
||||
}
|
||||
|
||||
private void renderPoly(Graphics2D graphics, Color color, Polygon polygon)
|
||||
{
|
||||
if (polygon != null)
|
||||
{
|
||||
graphics.setColor(color);
|
||||
graphics.setStroke(new BasicStroke(2));
|
||||
graphics.draw(polygon);
|
||||
graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20));
|
||||
graphics.fill(polygon);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,10 +27,12 @@ package net.runelite.client.plugins.pileindicators;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Provides;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
@@ -40,15 +42,13 @@ import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Pile Indicators",
|
||||
description = "Highlight and count how many npcs/players are stacked on each other.",
|
||||
tags = {"overlay", "pile", "stack", "pvp", "pvm", "pve"},
|
||||
type = PluginType.UTILITY,
|
||||
enabledByDefault = false
|
||||
name = "Pile Indicators",
|
||||
description = "Highlight and count how many npcs/players are stacked on each other.",
|
||||
tags = {"overlay", "pile", "stack", "pvp", "pvm", "pve"},
|
||||
type = PluginType.UTILITY,
|
||||
enabledByDefault = false
|
||||
)
|
||||
|
||||
@Singleton
|
||||
@@ -68,9 +68,6 @@ public class PileIndicatorsPlugin extends Plugin
|
||||
@Inject
|
||||
private PileIndicatorsOverlay overlay;
|
||||
|
||||
private List<String> pileList;
|
||||
private ArrayList<String> callers = new ArrayList<>();
|
||||
|
||||
@Provides
|
||||
PileIndicatorsConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
@@ -94,35 +91,6 @@ public class PileIndicatorsPlugin extends Plugin
|
||||
overlayManager.remove(overlay);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick gameTick)
|
||||
{
|
||||
if (config.highlightPile() && callers != null)
|
||||
{
|
||||
for (Player p : client.getPlayers())
|
||||
{
|
||||
for (String name : callers)
|
||||
{
|
||||
Actor pile;
|
||||
String finalName = name.toLowerCase().replace("_", " ");
|
||||
if (p.getName().toLowerCase().replace("_", " ").equals(finalName))
|
||||
{
|
||||
pile = p.getInteracting();
|
||||
if (pile != null)
|
||||
{
|
||||
pileList.set(callers.indexOf(name), pile.getName());
|
||||
//pileList.add(pile.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
pileList.set(callers.indexOf(name), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ArrayList<ArrayList<Actor>> getStacks()
|
||||
{
|
||||
ArrayList<ArrayList<Actor>> outerArrayList = new ArrayList<>();
|
||||
@@ -195,15 +163,6 @@ public class PileIndicatorsPlugin extends Plugin
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean isPile(Player player)
|
||||
{
|
||||
if (Objects.nonNull(pileList) && pileList.size() > 0)
|
||||
{
|
||||
return pileList.contains(player.getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected PileType getPileType(ArrayList<Actor> pile)
|
||||
{
|
||||
PileType pileType = null;
|
||||
|
||||
Reference in New Issue
Block a user