Delete Libraries/Core/Services/ItemFilterService.cs

Removed file, as wrongly rebased.
This commit is contained in:
TetrisGG
2025-03-09 13:47:06 +01:00
committed by GitHub
parent b7a5fc592a
commit 45a131ae3c
@@ -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<ItemFilterService> _logger,
ICloner _cloner,
ConfigServer _configServer
)
{
protected HashSet<string>? _itemBlacklistCache = [];
protected ItemConfig _itemConfig = _configServer.GetConfig<ItemConfig>();
protected HashSet<string>? _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<string> 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<string> GetItemRewardBaseTypeBlacklist()
{
return _cloner.Clone(_itemConfig.RewardItemTypeBlacklist);
}
/**
* Return every template id blacklisted in config/item.json
* @returns string array of blacklisted template ids
*/
public HashSet<string> 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<string> 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<string> 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);
}
}