loot tracker: fix tracking grubby chest
Co-authored-by: Jonathan Lee <cookmeplox@weirdgloop.org>
This commit is contained in:
@@ -147,7 +147,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
private static final Pattern LARRAN_LOOTED_PATTERN = Pattern.compile("You have opened Larran's (big|small) chest .*");
|
||||
private static final String STONE_CHEST_LOOTED_MESSAGE = "You steal some loot from the chest.";
|
||||
private static final String DORGESH_KAAN_CHEST_LOOTED_MESSAGE = "You find treasure inside!";
|
||||
private static final String GRUBBY_CHEST_LOOTED_MESSAGE = "You unlock the chest with your key.";
|
||||
private static final String GRUBBY_CHEST_LOOTED_MESSAGE = "You have opened the Grubby Chest";
|
||||
private static final Pattern HAM_CHEST_LOOTED_PATTERN = Pattern.compile("Your (?<key>[a-z]+) key breaks in the lock.*");
|
||||
private static final int HAM_STOREROOM_REGION = 10321;
|
||||
private static final Map<Integer, String> CHEST_EVENT_TYPES = new ImmutableMap.Builder<Integer, String>().
|
||||
@@ -618,7 +618,7 @@ public class LootTrackerPlugin extends Plugin
|
||||
final String message = event.getMessage();
|
||||
|
||||
if (message.equals(CHEST_LOOTED_MESSAGE) || message.equals(STONE_CHEST_LOOTED_MESSAGE)
|
||||
|| message.equals(DORGESH_KAAN_CHEST_LOOTED_MESSAGE) || message.equals(GRUBBY_CHEST_LOOTED_MESSAGE)
|
||||
|| message.equals(DORGESH_KAAN_CHEST_LOOTED_MESSAGE) || message.startsWith(GRUBBY_CHEST_LOOTED_MESSAGE)
|
||||
|| LARRAN_LOOTED_PATTERN.matcher(message).matches())
|
||||
{
|
||||
final int regionID = client.getLocalPlayer().getWorldLocation().getRegionID();
|
||||
|
||||
@@ -49,6 +49,7 @@ import net.runelite.api.Skill;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import net.runelite.client.account.SessionManager;
|
||||
@@ -314,4 +315,43 @@ public class LootTrackerPluginTest
|
||||
assertEquals("Regular Bird House", lootTrackerPlugin.eventType);
|
||||
assertEquals(LootRecordType.EVENT, lootTrackerPlugin.lootRecordType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGrubbyChest()
|
||||
{
|
||||
Player player = mock(Player.class);
|
||||
when(player.getWorldLocation()).thenReturn(new WorldPoint(7323 >> 2, (7323 & 0xff) << 6, 0));
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
LootTrackerPlugin lootTrackerPluginSpy = spy(this.lootTrackerPlugin);
|
||||
doNothing().when(lootTrackerPluginSpy).addLoot(any(), anyInt(), any(), any(), any(Collection.class));
|
||||
|
||||
ItemContainer itemContainer = mock(ItemContainer.class);
|
||||
when(itemContainer.getItems()).thenReturn(new Item[]{
|
||||
new Item(ItemID.TWISTED_BOW, 1),
|
||||
new Item(ItemID.GRUBBY_KEY, 1)
|
||||
});
|
||||
when(client.getItemContainer(InventoryID.INVENTORY)).thenReturn(itemContainer);
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "You unlock the chest with your key.", "", 0);
|
||||
lootTrackerPluginSpy.onChatMessage(chatMessage);
|
||||
|
||||
when(itemContainer.getItems()).thenReturn(new Item[]{
|
||||
new Item(ItemID.TWISTED_BOW, 1)
|
||||
});
|
||||
lootTrackerPluginSpy.onItemContainerChanged(new ItemContainerChanged(InventoryID.INVENTORY.getId(), itemContainer));
|
||||
|
||||
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", "You have opened the Grubby Chest 2 times.", "", 0);
|
||||
lootTrackerPluginSpy.onChatMessage(chatMessage);
|
||||
|
||||
when(itemContainer.getItems()).thenReturn(new Item[]{
|
||||
new Item(ItemID.TWISTED_BOW, 1),
|
||||
new Item(ItemID.SHARK, 42)
|
||||
});
|
||||
lootTrackerPluginSpy.onItemContainerChanged(new ItemContainerChanged(InventoryID.INVENTORY.getId(), itemContainer));
|
||||
|
||||
verify(lootTrackerPluginSpy).addLoot("Grubby Chest", -1, LootRecordType.EVENT, null, Arrays.asList(
|
||||
new ItemStack(ItemID.SHARK, 42, null)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user