From 5f113e0c77b91c68cbb8948382037261687268d3 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 4 Dec 2018 18:20:09 -0500 Subject: [PATCH] grounditems: add option to only show loot --- .../plugins/grounditems/GroundItem.java | 1 + .../grounditems/GroundItemsConfig.java | 11 ++++++ .../grounditems/GroundItemsOverlay.java | 5 ++- .../grounditems/GroundItemsPlugin.java | 34 +++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItem.java index 67cf9b5192..2d81060bcd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItem.java @@ -43,6 +43,7 @@ class GroundItem private int gePrice; private int offset; private boolean tradeable; + private boolean isMine; int getHaPrice() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java index 1a7f3dea5f..479f36fabe 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsConfig.java @@ -313,4 +313,15 @@ public interface GroundItemsConfig extends Config { return 10000000; } + + @ConfigItem( + keyName = "onlyShowLoot", + name = "Only show loot", + description = "Only shows drops from NPCs and players", + position = 24 + ) + default boolean onlyShowLoot() + { + return false; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java index b3006eeaf6..8d44c2e3ff 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsOverlay.java @@ -162,11 +162,14 @@ public class GroundItemsOverlay extends Overlay plugin.setHiddenBoxBounds(null); plugin.setHighlightBoxBounds(null); + final boolean onlyShowLoot = config.onlyShowLoot(); + for (GroundItem item : groundItemList) { final LocalPoint groundPoint = LocalPoint.fromWorld(client, item.getLocation()); - if (groundPoint == null || localLocation.distanceTo(groundPoint) > MAX_DISTANCE) + if (groundPoint == null || localLocation.distanceTo(groundPoint) > MAX_DISTANCE + || (onlyShowLoot && !item.isMine())) { continue; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java index 160111fd3f..a5a5cb4680 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java @@ -33,6 +33,7 @@ import com.google.inject.Provides; import java.awt.Color; import java.awt.Rectangle; import static java.lang.Boolean.TRUE; +import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -56,6 +57,7 @@ import net.runelite.api.Node; import net.runelite.api.Player; import net.runelite.api.Scene; import net.runelite.api.Tile; +import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.FocusChanged; import net.runelite.api.events.GameStateChanged; @@ -66,7 +68,10 @@ import net.runelite.api.events.MenuEntryAdded; import net.runelite.client.Notifier; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.NpcLootReceived; +import net.runelite.client.events.PlayerLootReceived; import net.runelite.client.game.ItemManager; +import net.runelite.client.game.ItemStack; import net.runelite.client.input.KeyManager; import net.runelite.client.input.MouseManager; import net.runelite.client.plugins.Plugin; @@ -261,6 +266,35 @@ public class GroundItemsPlugin extends Plugin } } + @Subscribe + public void onNpcLootReceived(NpcLootReceived npcLootReceived) + { + Collection items = npcLootReceived.getItems(); + WorldPoint location = npcLootReceived.getNpc().getWorldLocation(); + lootReceived(items, location); + } + + @Subscribe + public void onPlayerLootReceived(PlayerLootReceived playerLootReceived) + { + Collection items = playerLootReceived.getItems(); + WorldPoint location = playerLootReceived.getPlayer().getWorldLocation(); + lootReceived(items, location); + } + + private void lootReceived(Collection items, WorldPoint location) + { + for (ItemStack itemStack : items) + { + GroundItem.GroundItemKey groundItemKey = new GroundItem.GroundItemKey(itemStack.getId(), location); + GroundItem groundItem = collectedGroundItems.get(groundItemKey); + if (groundItem != null) + { + groundItem.setMine(true); + } + } + } + private GroundItem buildGroundItem(final Tile tile, final Item item) { // Collect the data for the item