Refactor inventory event lookup logic

Replaced ContainsKey and indexer access with TryGetValue for InventoryEvents dictionary to improve performance and readability in EventsService.
This commit is contained in:
Madpeter 2025-10-04 23:11:34 +01:00
parent 04b4e872a8
commit 7411ba3268

View file

@ -33,9 +33,9 @@ namespace SecondBotEvents.Services
{
detail["itemtype"] = detail["itemtype"].ToLower().FirstCharToUpper();
if (InventoryEvents.ContainsKey(detail["itemtype"]) == true)
if (InventoryEvents.TryGetValue(detail["itemtype"], out var targets))
{
foreach (string A in InventoryEvents[detail["itemtype"]])
foreach (string A in targets)
{
string output = JsonSerializer.Serialize(detail);
if (UUID.TryParse(A, out UUID OutputAvatar) == true)