Merge pull request #8360 from AdamBallinger/crystal-chest-fix

Fix crystal chest in loot tracker
This commit is contained in:
Adam
2019-03-31 13:54:15 -04:00
committed by GitHub

View File

@@ -26,6 +26,7 @@
package net.runelite.client.plugins.loottracker; package net.runelite.client.plugins.loottracker;
import com.google.common.collect.HashMultiset; import com.google.common.collect.HashMultiset;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multiset; import com.google.common.collect.Multiset;
import com.google.common.collect.Multisets; import com.google.common.collect.Multisets;
import com.google.inject.Provides; import com.google.inject.Provides;
@@ -37,6 +38,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@@ -97,9 +99,12 @@ public class LootTrackerPlugin extends Plugin
private static final Pattern CLUE_SCROLL_PATTERN = Pattern.compile("You have completed [0-9]+ ([a-z]+) Treasure Trails."); private static final Pattern CLUE_SCROLL_PATTERN = Pattern.compile("You have completed [0-9]+ ([a-z]+) Treasure Trails.");
private static final int THEATRE_OF_BLOOD_REGION = 12867; private static final int THEATRE_OF_BLOOD_REGION = 12867;
// Brimstone loot handling // Chest loot handling
private static final String BRIMSTONE_CHEST_MESSAGE = "You find some treasure in the chest!"; private static final String CHEST_LOOTED_MESSAGE = "You find some treasure in the chest!";
private static final String BRIMSTONE_CHEST_EVENT_TYPE = "Brimstone Chest"; private static final Map<Integer, String> CHEST_EVENT_TYPES = ImmutableMap.of(
5179, "Brimstone Chest",
11573, "Crystal Chest"
);
@Inject @Inject
private ClientToolbar clientToolbar; private ClientToolbar clientToolbar;
@@ -375,9 +380,15 @@ public class LootTrackerPlugin extends Plugin
final String message = event.getMessage(); final String message = event.getMessage();
if (message.equals(BRIMSTONE_CHEST_MESSAGE)) if (message.equals(CHEST_LOOTED_MESSAGE))
{ {
eventType = BRIMSTONE_CHEST_EVENT_TYPE; final int regionID = client.getLocalPlayer().getWorldLocation().getRegionID();
if (!CHEST_EVENT_TYPES.containsKey(regionID))
{
return;
}
eventType = CHEST_EVENT_TYPES.get(regionID);
final ItemContainer itemContainer = client.getItemContainer(InventoryID.INVENTORY); final ItemContainer itemContainer = client.getItemContainer(InventoryID.INVENTORY);
if (itemContainer != null) if (itemContainer != null)
@@ -419,21 +430,19 @@ public class LootTrackerPlugin extends Plugin
@Subscribe @Subscribe
public void onItemContainerChanged(ItemContainerChanged event) public void onItemContainerChanged(ItemContainerChanged event)
{ {
if (eventType == null || !eventType.equals(BRIMSTONE_CHEST_EVENT_TYPE)) if (eventType != null && CHEST_EVENT_TYPES.containsValue(eventType))
{ {
return; if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY))
} {
return;
}
if (event.getItemContainer() != client.getItemContainer(InventoryID.INVENTORY)) processChestLoot(eventType, event.getItemContainer());
{ eventType = null;
return;
} }
processBrimstoneChestLoot(event.getItemContainer());
eventType = null;
} }
private void processBrimstoneChestLoot(ItemContainer inventoryContainer) private void processChestLoot(String chestType, ItemContainer inventoryContainer)
{ {
if (inventorySnapshot != null) if (inventorySnapshot != null)
{ {
@@ -448,11 +457,11 @@ public class LootTrackerPlugin extends Plugin
.collect(Collectors.toList()); .collect(Collectors.toList());
final LootTrackerItem[] entries = buildEntries(stack(items)); final LootTrackerItem[] entries = buildEntries(stack(items));
SwingUtilities.invokeLater(() -> panel.add(BRIMSTONE_CHEST_EVENT_TYPE, -1, entries)); SwingUtilities.invokeLater(() -> panel.add(chestType, -1, entries));
if (lootTrackerClient != null && config.saveLoot()) if (lootTrackerClient != null && config.saveLoot())
{ {
LootRecord lootRecord = new LootRecord(BRIMSTONE_CHEST_EVENT_TYPE, LootRecordType.EVENT, toGameItems(items), Instant.now()); LootRecord lootRecord = new LootRecord(chestType, LootRecordType.EVENT, toGameItems(items), Instant.now());
lootTrackerClient.submit(lootRecord); lootTrackerClient.submit(lootRecord);
} }