loot manager: limit to one kill per location per tick
This commit is contained in:
@@ -31,8 +31,10 @@ import com.google.common.eventbus.EventBus;
|
|||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -66,6 +68,7 @@ public class LootManager
|
|||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
private final Client client;
|
private final Client client;
|
||||||
private final ListMultimap<Integer, ItemStack> itemSpawns = ArrayListMultimap.create();
|
private final ListMultimap<Integer, ItemStack> itemSpawns = ArrayListMultimap.create();
|
||||||
|
private final Set<LocalPoint> killPoints = new HashSet<>();
|
||||||
private WorldPoint playerLocationLastTick;
|
private WorldPoint playerLocationLastTick;
|
||||||
private WorldPoint krakenPlayerLocation;
|
private WorldPoint krakenPlayerLocation;
|
||||||
|
|
||||||
@@ -130,7 +133,7 @@ public class LootManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
final LocalPoint location = LocalPoint.fromWorld(client, player.getWorldLocation());
|
final LocalPoint location = LocalPoint.fromWorld(client, player.getWorldLocation());
|
||||||
if (location == null)
|
if (location == null || killPoints.contains(location))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -145,6 +148,7 @@ public class LootManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
killPoints.add(location);
|
||||||
eventBus.post(new PlayerLootReceived(player, items));
|
eventBus.post(new PlayerLootReceived(player, items));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,12 +215,13 @@ public class LootManager
|
|||||||
{
|
{
|
||||||
playerLocationLastTick = client.getLocalPlayer().getWorldLocation();
|
playerLocationLastTick = client.getLocalPlayer().getWorldLocation();
|
||||||
itemSpawns.clear();
|
itemSpawns.clear();
|
||||||
|
killPoints.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processNpcLoot(NPC npc)
|
private void processNpcLoot(NPC npc)
|
||||||
{
|
{
|
||||||
final LocalPoint location = LocalPoint.fromWorld(client, getDropLocation(npc, npc.getWorldLocation()));
|
final LocalPoint location = LocalPoint.fromWorld(client, getDropLocation(npc, npc.getWorldLocation()));
|
||||||
if (location == null)
|
if (location == null || killPoints.contains(location))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -242,6 +247,7 @@ public class LootManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
killPoints.add(location);
|
||||||
eventBus.post(new NpcLootReceived(npc, allItems));
|
eventBus.post(new NpcLootReceived(npc, allItems));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user