Merge pull request #6816 from Adam-/master+grounditemsloot

grounditems: add option to only show loot
This commit is contained in:
Adam
2018-12-05 17:07:24 -05:00
committed by GitHub
4 changed files with 50 additions and 1 deletions

View File

@@ -43,6 +43,7 @@ class GroundItem
private int gePrice;
private int offset;
private boolean tradeable;
private boolean isMine;
int getHaPrice()
{

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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<ItemStack> items = npcLootReceived.getItems();
WorldPoint location = npcLootReceived.getNpc().getWorldLocation();
lootReceived(items, location);
}
@Subscribe
public void onPlayerLootReceived(PlayerLootReceived playerLootReceived)
{
Collection<ItemStack> items = playerLootReceived.getItems();
WorldPoint location = playerLootReceived.getPlayer().getWorldLocation();
lootReceived(items, location);
}
private void lootReceived(Collection<ItemStack> 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