From 7411ba326867474747dbbb2d7ab8e4cc65470f01 Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Sat, 4 Oct 2025 23:11:34 +0100 Subject: [PATCH] Refactor inventory event lookup logic Replaced ContainsKey and indexer access with TryGetValue for InventoryEvents dictionary to improve performance and readability in EventsService. --- SecondBotEvents/Services/EventsService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SecondBotEvents/Services/EventsService.cs b/SecondBotEvents/Services/EventsService.cs index f0497f2..f81995f 100644 --- a/SecondBotEvents/Services/EventsService.cs +++ b/SecondBotEvents/Services/EventsService.cs @@ -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)