diff --git a/Core/Services/ItemFilterService.cs b/Core/Services/ItemFilterService.cs index bc4622d9..b3f1fbd7 100644 --- a/Core/Services/ItemFilterService.cs +++ b/Core/Services/ItemFilterService.cs @@ -1,10 +1,38 @@ -using Core.Annotations; +using Core.Annotations; +using Core.Models.Enums; +using Core.Models.Spt.Config; +using Core.Servers; +using Core.Utils.Cloners; +using ILogger = Core.Models.Utils.ILogger; namespace Core.Services; [Injectable(InjectionType.Singleton)] public class ItemFilterService { + private readonly ILogger _logger; + private readonly ICloner _cloner; + private readonly DatabaseServer _databaseServer; + private readonly ConfigServer _configServer; + + private readonly HashSet _lootableItemBlacklistCache = []; + private readonly ItemConfig _itemConfig; + + public ItemFilterService( + ILogger logger, + ICloner cloner, + DatabaseServer databaseServer, + ConfigServer configServer + ) + { + _logger = logger; + _cloner = cloner; + _databaseServer = databaseServer; + _configServer = configServer; + + _itemConfig = _configServer.GetConfig(ConfigTypes.ITEM); + } + /** * Check if the provided template id is blacklisted in config/item.json/blacklist * @param tpl template id @@ -90,8 +118,15 @@ public class ItemFilterService throw new NotImplementedException(); } - public static bool IsLootableItemBlacklisted(string itemKey) + public bool IsLootableItemBlacklisted(string itemKey) { - throw new NotImplementedException(); + if (_lootableItemBlacklistCache.Count == 0) + { + foreach (var item in _itemConfig.LootableItemBlacklist) { + _lootableItemBlacklistCache.Add(item); + } + } + + return _lootableItemBlacklistCache.Contains(itemKey); } }