loot tracker: support opening multiple imp jars in 1 tick
This tracks the number of removed jars to determine how many were opened. This only works when opening multiple of the same type of jar. Co-authored-by: Shawn Shadrix <shshadri@ncsu.edu>
This commit is contained in:
@@ -41,4 +41,5 @@ public class LootReceived
|
|||||||
private int combatLevel;
|
private int combatLevel;
|
||||||
private LootRecordType type;
|
private LootRecordType type;
|
||||||
private Collection<ItemStack> items;
|
private Collection<ItemStack> items;
|
||||||
|
private int amount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
* Creates a subtitle, adds a new entry and then passes off to the render methods, that will decide
|
* Creates a subtitle, adds a new entry and then passes off to the render methods, that will decide
|
||||||
* how to display this new data.
|
* how to display this new data.
|
||||||
*/
|
*/
|
||||||
void add(final String eventName, final LootRecordType type, final int actorLevel, LootTrackerItem[] items)
|
void add(final String eventName, final LootRecordType type, final int actorLevel, LootTrackerItem[] items, int kills)
|
||||||
{
|
{
|
||||||
final String subTitle;
|
final String subTitle;
|
||||||
if (type == LootRecordType.PICKPOCKET)
|
if (type == LootRecordType.PICKPOCKET)
|
||||||
@@ -411,7 +411,7 @@ class LootTrackerPanel extends PluginPanel
|
|||||||
{
|
{
|
||||||
subTitle = actorLevel > -1 ? "(lvl-" + actorLevel + ")" : "";
|
subTitle = actorLevel > -1 ? "(lvl-" + actorLevel + ")" : "";
|
||||||
}
|
}
|
||||||
final LootTrackerRecord record = new LootTrackerRecord(eventName, subTitle, type, items, 1);
|
final LootTrackerRecord record = new LootTrackerRecord(eventName, subTitle, type, items, kills);
|
||||||
sessionRecords.add(record);
|
sessionRecords.add(record);
|
||||||
|
|
||||||
if (hideIgnoredItems && plugin.isEventIgnored(eventName))
|
if (hideIgnoredItems && plugin.isEventIgnored(eventName))
|
||||||
|
|||||||
@@ -571,9 +571,14 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addLoot(@NonNull String name, int combatLevel, LootRecordType type, Object metadata, Collection<ItemStack> items)
|
void addLoot(@NonNull String name, int combatLevel, LootRecordType type, Object metadata, Collection<ItemStack> items)
|
||||||
|
{
|
||||||
|
addLoot(name, combatLevel, type, metadata, items, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void addLoot(@NonNull String name, int combatLevel, LootRecordType type, Object metadata, Collection<ItemStack> items, int amount)
|
||||||
{
|
{
|
||||||
final LootTrackerItem[] entries = buildEntries(stack(items));
|
final LootTrackerItem[] entries = buildEntries(stack(items));
|
||||||
SwingUtilities.invokeLater(() -> panel.add(name, type, combatLevel, entries));
|
SwingUtilities.invokeLater(() -> panel.add(name, type, combatLevel, entries, amount));
|
||||||
|
|
||||||
LootRecord lootRecord = new LootRecord(name, type, metadata, toGameItems(items), Instant.now(), getLootWorldId());
|
LootRecord lootRecord = new LootRecord(name, type, metadata, toGameItems(items), Instant.now(), getLootWorldId());
|
||||||
synchronized (queuedLoots)
|
synchronized (queuedLoots)
|
||||||
@@ -581,7 +586,7 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
queuedLoots.add(lootRecord);
|
queuedLoots.add(lootRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
eventBus.post(new LootReceived(name, combatLevel, type, items));
|
eventBus.post(new LootReceived(name, combatLevel, type, items, amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer getLootWorldId()
|
private Integer getLootWorldId()
|
||||||
@@ -885,6 +890,7 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
final Collection<ItemStack> groundItems = lootManager.getItemSpawns(playerLocation);
|
final Collection<ItemStack> groundItems = lootManager.getItemSpawns(playerLocation);
|
||||||
|
|
||||||
final Multiset<Integer> diff = Multisets.difference(currentInventory, inventorySnapshot);
|
final Multiset<Integer> diff = Multisets.difference(currentInventory, inventorySnapshot);
|
||||||
|
final Multiset<Integer> diffr = Multisets.difference(inventorySnapshot, currentInventory);
|
||||||
|
|
||||||
final List<ItemStack> items = diff.entrySet().stream()
|
final List<ItemStack> items = diff.entrySet().stream()
|
||||||
.map(e -> new ItemStack(e.getElement(), e.getCount(), client.getLocalPlayer().getLocalLocation()))
|
.map(e -> new ItemStack(e.getElement(), e.getCount(), client.getLocalPlayer().getLocalLocation()))
|
||||||
@@ -894,7 +900,7 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
|
|
||||||
if (inventorySnapshotCb != null)
|
if (inventorySnapshotCb != null)
|
||||||
{
|
{
|
||||||
inventorySnapshotCb.accept(items, groundItems);
|
inventorySnapshotCb.accept(items, groundItems, diffr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inventoryId = null;
|
inventoryId = null;
|
||||||
@@ -957,8 +963,15 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
else if (event.getMenuOption().equals("Loot") && IMPLING_JARS.contains(event.getId()))
|
else if (event.getMenuOption().equals("Loot") && IMPLING_JARS.contains(event.getId()))
|
||||||
{
|
{
|
||||||
String name = itemManager.getItemComposition(event.getId()).getName();
|
onInvChange(((invItems, groundItems, removedItems) ->
|
||||||
onInvChange(collectInvItems(LootRecordType.EVENT, name));
|
{
|
||||||
|
int cnt = removedItems.count(event.getId());
|
||||||
|
if (cnt > 0)
|
||||||
|
{
|
||||||
|
String name = itemManager.getItemComposition(event.getId()).getName();
|
||||||
|
addLoot(name, -1, LootRecordType.EVENT, null, invItems, cnt);
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1064,7 +1077,7 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
interface InvChangeCallback
|
interface InvChangeCallback
|
||||||
{
|
{
|
||||||
void accept(Collection<ItemStack> invItems, Collection<ItemStack> groundItems);
|
void accept(Collection<ItemStack> invItems, Collection<ItemStack> groundItems, Multiset<Integer> removedItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
private InvChangeCallback collectInvItems(LootRecordType type, String event)
|
private InvChangeCallback collectInvItems(LootRecordType type, String event)
|
||||||
@@ -1074,7 +1087,7 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
|
|
||||||
private InvChangeCallback collectInvItems(LootRecordType type, String event, Object metadata)
|
private InvChangeCallback collectInvItems(LootRecordType type, String event, Object metadata)
|
||||||
{
|
{
|
||||||
return (invItems, groundItems) ->
|
return (invItems, groundItems, removedItems) ->
|
||||||
addLoot(event, -1, type, metadata, invItems);
|
addLoot(event, -1, type, metadata, invItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1085,7 +1098,7 @@ public class LootTrackerPlugin extends Plugin
|
|||||||
|
|
||||||
private InvChangeCallback collectInvAndGroundItems(LootRecordType type, String event, Object metadata)
|
private InvChangeCallback collectInvAndGroundItems(LootRecordType type, String event, Object metadata)
|
||||||
{
|
{
|
||||||
return (invItems, groundItems) ->
|
return (invItems, groundItems, removedItems) ->
|
||||||
{
|
{
|
||||||
List<ItemStack> combined = new ArrayList<>();
|
List<ItemStack> combined = new ArrayList<>();
|
||||||
combined.addAll(invItems);
|
combined.addAll(invItems);
|
||||||
|
|||||||
Reference in New Issue
Block a user