@Subscribe
	public void onWidgetLoaded(WidgetLoaded widgetLoaded)
	{
		String event;
		Object metadata = null;
		final ItemContainer container;

		switch (widgetLoaded.getGroupId())
		{
			case InterfaceID.BARROWS_REWARD:
				event = "Barrows";
				container = client.getItemContainer(InventoryID.BARROWS_REWARD);
				break;
			case InterfaceID.CHAMBERS_OF_XERIC_REWARD:
				if (chestLooted)
				{
					return;
				}
				event = CHAMBERS_OF_XERIC;
				container = client.getItemContainer(InventoryID.CHAMBERS_OF_XERIC_CHEST);
				chestLooted = true;
				break;
			case InterfaceID.TOB_REWARD:
				if (chestLooted || !inTobChestRegion())
				{
					return;
				}
				event = THEATRE_OF_BLOOD;
				container = client.getItemContainer(InventoryID.THEATRE_OF_BLOOD_CHEST);
				chestLooted = true;
				break;
			case InterfaceID.TOA_REWARD:
				if (chestLooted)
				{
					return;
				}

				int raidLevel = client.getVarbitValue(Varbits.TOA_RAID_LEVEL);
				int teamSize =
					Math.min(client.getVarbitValue(Varbits.TOA_MEMBER_0_HEALTH), 1) +
					Math.min(client.getVarbitValue(Varbits.TOA_MEMBER_1_HEALTH), 1) +
					Math.min(client.getVarbitValue(Varbits.TOA_MEMBER_2_HEALTH), 1) +
					Math.min(client.getVarbitValue(Varbits.TOA_MEMBER_3_HEALTH), 1) +
					Math.min(client.getVarbitValue(Varbits.TOA_MEMBER_4_HEALTH), 1) +
					Math.min(client.getVarbitValue(Varbits.TOA_MEMBER_5_HEALTH), 1) +
					Math.min(client.getVarbitValue(Varbits.TOA_MEMBER_6_HEALTH), 1) +
					Math.min(client.getVarbitValue(Varbits.TOA_MEMBER_7_HEALTH), 1);
				int raidDamage = client.getVarbitValue(Varbits.TOA_RAID_DAMAGE);
				event = TOMBS_OF_AMASCUT;
				container = client.getItemContainer(InventoryID.TOA_REWARD_CHEST);
				metadata = new int[]{ raidLevel, teamSize, raidDamage };
				chestLooted = true;
				break;
			case InterfaceID.KINGDOM:
				event = "Kingdom of Miscellania";
				container = client.getItemContainer(InventoryID.KINGDOM_OF_MISCELLANIA);
				break;
			case InterfaceID.TRAWLER_REWARD:
				event = "Fishing Trawler";
				metadata = client.getBoostedSkillLevel(Skill.FISHING);
				container = client.getItemContainer(InventoryID.FISHING_TRAWLER_REWARD);
				break;
			case InterfaceID.DRIFT_NET_FISHING_REWARD:
				event = "Drift Net";
				metadata = client.getBoostedSkillLevel(Skill.FISHING);
				container = client.getItemContainer(InventoryID.DRIFT_NET_FISHING_REWARD);
				break;
			case InterfaceID.WILDERNESS_LOOT_CHEST:
				if (chestLooted)
				{
					return;
				}
				event = "Loot Chest";
				container = client.getItemContainer(InventoryID.WILDERNESS_LOOT_CHEST);
				chestLooted = true;
				break;
			case InterfaceID.LUNAR_CHEST:
				event = "Lunar Chest";
				container = client.getItemContainer(InventoryID.LUNAR_CHEST);
				break;
			case InterfaceID.FORTIS_COLOSSEUM_REWARD:
				if (chestLooted)
				{
					return;
				}
				event = "Fortis Colosseum";
				container = client.getItemContainer(InventoryID.FORTIS_COLOSSEUM_REWARD_CHEST);
				chestLooted = true;
				break;
			default:
				return;
		}

		if (container == null)
		{
			return;
		}

		// Convert container items to array of ItemStack
		final Collection<ItemStack> items = Arrays.stream(container.getItems())
			.filter(item -> item.getId() > 0)
			.map(item -> new ItemStack(item.getId(), item.getQuantity()))
			.collect(Collectors.toList());

		if (config.showRaidsLootValue() && (event.equals(THEATRE_OF_BLOOD) || event.equals(CHAMBERS_OF_XERIC) || event.equals(TOMBS_OF_AMASCUT)))
		{
			long totalValue = items.stream()
				.filter(item -> item.getId() > -1)
				.mapToLong(item -> config.priceType() == LootTrackerPriceType.GRAND_EXCHANGE ?
					(long) itemManager.getItemPrice(item.getId()) * item.getQuantity() :
					(long) itemManager.getItemComposition(item.getId()).getHaPrice() * item.getQuantity())
				.sum();

			String chatMessage = new ChatMessageBuilder()
				.append(ChatColorType.NORMAL)
				.append("Your loot is worth around ")
				.append(ChatColorType.HIGHLIGHT)
				.append(QuantityFormatter.formatNumber(totalValue))
				.append(ChatColorType.NORMAL)
				.append(" coins.")
				.build();

			chatMessageManager.queue(QueuedMessage.builder()
				.type(ChatMessageType.FRIENDSCHATNOTIFICATION)
				.runeLiteFormattedMessage(chatMessage)
				.build());
		}

		if (items.isEmpty())
		{
			log.debug("No items to find for Event: {} | Container: {}", event, container);
			return;
		}

		addLoot(event, -1, LootRecordType.EVENT, metadata, items);
	}
@Test
	public void testCoXRaidsLootValue()
	{
		when(lootTrackerConfig.showRaidsLootValue()).thenReturn(true);
		when(lootTrackerConfig.priceType()).thenReturn(LootTrackerPriceType.GRAND_EXCHANGE);

		ItemContainer itemContainer = mock(ItemContainer.class);
		when(itemContainer.getItems()).thenReturn(new Item[]{
			new Item(ItemID.TWISTED_BOW, 1),
			new Item(ItemID.PURE_ESSENCE, 42)
		});
		when(client.getItemContainer(InventoryID.CHAMBERS_OF_XERIC_CHEST)).thenReturn(itemContainer);

		when(itemManager.getItemPrice(ItemID.TWISTED_BOW)).thenReturn(1_100_000_000);
		when(itemManager.getItemPrice(ItemID.PURE_ESSENCE)).thenReturn(6);

		WidgetLoaded widgetLoaded = new WidgetLoaded();
		widgetLoaded.setGroupId(InterfaceID.CHAMBERS_OF_XERIC_REWARD);
		lootTrackerPlugin.onWidgetLoaded(widgetLoaded);

		ArgumentCaptor<QueuedMessage> captor = ArgumentCaptor.forClass(QueuedMessage.class);
		verify(chatMessageManager).queue(captor.capture());

		QueuedMessage queuedMessage = captor.getValue();
		assertEquals("<colNORMAL>Your loot is worth around <colHIGHLIGHT>1,100,000,252<colNORMAL> coins.", queuedMessage.getRuneLiteFormattedMessage());
	}