From e688f4d2f63b593c922cdbd3788bab793b9f2cea Mon Sep 17 00:00:00 2001 From: CWX Date: Sun, 19 Jan 2025 19:32:31 +0000 Subject: [PATCH] null guard --- Libraries/Core/Services/BotEquipmentFilterService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/Core/Services/BotEquipmentFilterService.cs b/Libraries/Core/Services/BotEquipmentFilterService.cs index 2de2e85f..1d29ae9b 100644 --- a/Libraries/Core/Services/BotEquipmentFilterService.cs +++ b/Libraries/Core/Services/BotEquipmentFilterService.cs @@ -18,7 +18,7 @@ public class BotEquipmentFilterService protected BotHelper _botHelper; protected BotConfig _botConfig; - protected Dictionary _botEquipmentConfig; + protected Dictionary _botEquipmentConfig; public BotEquipmentFilterService( ISptLogger logger, @@ -164,7 +164,7 @@ public class BotEquipmentFilterService { var blacklistDetailsForBot = _botEquipmentConfig.GetValueOrDefault(botRole, null); - return blacklistDetailsForBot?.Blacklist.FirstOrDefault( + return (blacklistDetailsForBot?.Blacklist ?? []).FirstOrDefault( equipmentFilter => playerLevel >= equipmentFilter.LevelRange.Min && playerLevel <= equipmentFilter.LevelRange.Max ); } @@ -179,7 +179,7 @@ public class BotEquipmentFilterService { var whitelistDetailsForBot = _botEquipmentConfig.GetValueOrDefault(botRole, null); - return whitelistDetailsForBot?.Whitelist.FirstOrDefault( + return (whitelistDetailsForBot?.Whitelist ?? []).FirstOrDefault( equipmentFilter => playerLevel >= equipmentFilter.LevelRange.Min && playerLevel <= equipmentFilter.LevelRange.Max ); } @@ -194,7 +194,7 @@ public class BotEquipmentFilterService { var weightingDetailsForBot = _botEquipmentConfig.GetValueOrDefault(botRole, null); - return weightingDetailsForBot?.WeightingAdjustmentsByBotLevel.FirstOrDefault( + return (weightingDetailsForBot?.WeightingAdjustmentsByBotLevel ?? [] ).FirstOrDefault( x => botLevel >= x.LevelRange.Min && botLevel <= x.LevelRange.Max ); } @@ -209,7 +209,7 @@ public class BotEquipmentFilterService { var weightingDetailsForBot = _botEquipmentConfig.GetValueOrDefault(botRole, null); - return weightingDetailsForBot?.WeightingAdjustmentsByBotLevel.FirstOrDefault( + return (weightingDetailsForBot?.WeightingAdjustmentsByBotLevel ?? []).FirstOrDefault( x => playerlevel >= x.LevelRange.Min && playerlevel <= x.LevelRange.Max ); }