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
This commit is contained in:
Michael Goodwin
2018-09-02 12:43:27 -07:00
committed by Tomas Slusny
parent e6df8d27b7
commit 549150a749

View File

@@ -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<Integer, ItemStack> itemSpawns = ArrayListMultimap.create();
private final Map<LocalPoint, Boolean> 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));
}