Implemented isItemBlacklisted
This commit is contained in:
@@ -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<string> _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<ItemConfig>(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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user