From 549150a74930146296fd793aaa17270a2163653b Mon Sep 17 00:00:00 2001 From: Michael Goodwin <29030969+TheStonedTurtle@users.noreply.github.com> Date: Sun, 2 Sep 2018 12:43:27 -0700 Subject: [PATCH] Make same-tick same-tile loot event fire once Make kills done in same tick on same tile count only once to prevent duplicated entries in loot tracker. Closes #4839 --- .../main/java/net/runelite/client/game/LootManager.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/game/LootManager.java b/runelite-client/src/main/java/net/runelite/client/game/LootManager.java index 41aae4e43b..0c2dd55628 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/LootManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/LootManager.java @@ -31,6 +31,7 @@ import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; @@ -66,6 +67,7 @@ public class LootManager private final EventBus eventBus; private final Client client; private final ListMultimap itemSpawns = ArrayListMultimap.create(); + private final Map killMap = new HashMap<>(); private WorldPoint playerLocationLastTick; private WorldPoint krakenPlayerLocation; @@ -124,7 +126,7 @@ public class LootManager { final Player player = playerDespawned.getPlayer(); final LocalPoint location = LocalPoint.fromWorld(client, player.getWorldLocation()); - if (location == null) + if (location == null || killMap.get(location)) { return; } @@ -139,6 +141,7 @@ public class LootManager return; } + killMap.put(location, true); eventBus.post(new PlayerLootReceived(player, items)); } @@ -205,12 +208,13 @@ public class LootManager { playerLocationLastTick = client.getLocalPlayer().getWorldLocation(); itemSpawns.clear(); + killMap.clear(); } private void processNpcLoot(NPC npc) { final LocalPoint location = LocalPoint.fromWorld(client, getDropLocation(npc, npc.getWorldLocation())); - if (location == null) + if (location == null || killMap.get(location)) { return; } @@ -236,6 +240,7 @@ public class LootManager return; } + killMap.put(location, true); eventBus.post(new NpcLootReceived(npc, allItems)); }