diff --git a/Libraries/Core/Services/ItemFilterService.cs b/Libraries/Core/Services/ItemFilterService.cs deleted file mode 100644 index 3a3067be..00000000 --- a/Libraries/Core/Services/ItemFilterService.cs +++ /dev/null @@ -1,161 +0,0 @@ -using Core.Models.Spt.Config; -using Core.Models.Utils; -using Core.Servers; -using Core.Utils.Cloners; -using SptCommon.Annotations; - -namespace Core.Services; - -[Injectable(InjectionType.Singleton)] -public class ItemFilterService( - ISptLogger _logger, - ICloner _cloner, - ConfigServer _configServer -) -{ - protected HashSet? _itemBlacklistCache = []; - protected ItemConfig _itemConfig = _configServer.GetConfig(); - - protected HashSet? _lootableItemBlacklistCache = []; - - /** - * Check if the provided template id is blacklisted in config/item.json/blacklist - * @param tpl template id - * @returns true if blacklisted - */ - public bool ItemBlacklisted(string tpl) - { - if (_itemBlacklistCache.Count == 0) - { - _itemBlacklistCache.UnionWith(_itemConfig.Blacklist); - } - - return _itemBlacklistCache.Contains(tpl); - } - - /** - * Check if item is blacklisted from being a reward for player - * @param tpl item tpl to check is on blacklist - * @returns True when blacklisted - */ - public bool ItemRewardBlacklisted(string tpl) - { - return _itemConfig.RewardItemBlacklist.Contains(tpl); - } - - /** - * Get an array of items that should never be given as a reward to player - * @returns string array of item tpls - */ - public HashSet GetItemRewardBlacklist() - { - return _cloner.Clone(_itemConfig.RewardItemBlacklist); - } - - /** - * Get an array of item types that should never be given as a reward to player - * @returns string array of item base ids - */ - public HashSet GetItemRewardBaseTypeBlacklist() - { - return _cloner.Clone(_itemConfig.RewardItemTypeBlacklist); - } - - /** - * Return every template id blacklisted in config/item.json - * @returns string array of blacklisted template ids - */ - public HashSet GetBlacklistedItems() - { - return _cloner.Clone(_itemConfig.Blacklist); - } - - /** - * Return every template id blacklisted in config/item.json/lootableItemBlacklist - * @returns string array of blacklisted template ids - */ - public HashSet GetBlacklistedLootableItems() - { - return _cloner.Clone(_itemConfig.LootableItemBlacklist); - } - - /** - * Check if the provided template id is boss item in config/item.json - * @param tpl template id - * @returns true if boss item - */ - public bool BossItem(string tpl) - { - return _itemConfig.BossItems.Contains(tpl); - } - - /** - * Return boss items in config/item.json - * @returns string array of boss item template ids - */ - public HashSet GetBossItems() - { - return _cloner.Clone(_itemConfig.BossItems).ToHashSet(); - } - - /** - * Check if the provided template id is blacklisted in config/item.json/lootableItemBlacklist - * @param tpl template id - * @returns true if blacklisted - */ - public bool IsLootableItemBlacklisted(string itemKey) - { - if (!_lootableItemBlacklistCache.Any()) - { - HydrateLootableItemBlacklist(); - } - - return _lootableItemBlacklistCache.Contains(itemKey); - } - - public bool IsItemBlacklisted(string tpl) - { - if (!_itemBlacklistCache.Any()) - { - HydrateBlacklist(); - } - - return _itemBlacklistCache.Contains(tpl); - } - - protected void HydrateLootableItemBlacklist() - { - foreach (var item in _itemConfig.LootableItemBlacklist) - { - _lootableItemBlacklistCache.Add(item); - } - } - - protected void HydrateBlacklist() - { - foreach (var item in _itemConfig.Blacklist) - { - _itemBlacklistCache.Add(item); - } - } - - /** - * Check if the provided template id is boss item in config/item.json - * @param tpl template id - * @returns true if boss item - */ - public bool IsBossItem(string tpl) - { - return _itemConfig.BossItems.Contains(tpl); - } - - /** - * Check if item is blacklisted from being a reward for player - * @param tpl item tpl to check is on blacklist - * @returns True when blacklisted - */ - public bool IsItemRewardBlacklisted(string tpl) - { - return _itemConfig.RewardItemBlacklist.Contains(tpl); - } -}