From 534e9d2ba117d164909cced22959c71442c4766b Mon Sep 17 00:00:00 2001 From: Cj Date: Mon, 4 Mar 2024 19:36:31 +0000 Subject: [PATCH] [Enhancement] Custom flea category blacklist (!244) Allows modders to blacklist entire categories from ragfair in relation to https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/525 new properties under `RagfairConfig.dynamic.blacklist` `enableCustomItemCategoryList` - this enables the custom custom category blacklist `customItemCategoryList` - this is an array to take a list of parent id's I tested it to confirm its working, will need some further testing. Co-authored-by: Corey Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/244 Co-authored-by: Cj Co-committed-by: Cj --- project/assets/configs/ragfair.json | 4 +++- project/src/helpers/RagfairServerHelper.ts | 19 +++++++++++++++++++ .../src/models/spt/config/IRagfairConfig.ts | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/project/assets/configs/ragfair.json b/project/assets/configs/ragfair.json index b1776e2c..621cc410 100644 --- a/project/assets/configs/ragfair.json +++ b/project/assets/configs/ragfair.json @@ -297,7 +297,9 @@ "armorPlate": { "maxProtectionLevel": 4, "ignoreSlots": ["right_side_plate", "left_side_plate"] - } + }, + "enableCustomItemCategoryList": false, + "customItemCategoryList": [] }, "unreasonableModPrices": { "5448fe124bdc2da5018b4567": { diff --git a/project/src/helpers/RagfairServerHelper.ts b/project/src/helpers/RagfairServerHelper.ts index 4fe0fdb4..3e3003a3 100644 --- a/project/src/helpers/RagfairServerHelper.ts +++ b/project/src/helpers/RagfairServerHelper.ts @@ -90,6 +90,15 @@ export class RagfairServerHelper return false; } + // Skip custom category blacklisted items + if ( + blacklistConfig.enableCustomItemCategoryList + && this.isItemCategoryOnCustomFleaBlacklist(itemDetails[1]._parent) + ) + { + return false; + } + // Skip quest items if (blacklistConfig.enableQuestList && this.itemHelper.isQuestItem(itemDetails[1]._id)) { @@ -123,6 +132,16 @@ export class RagfairServerHelper return this.ragfairConfig.dynamic.blacklist.custom.includes(itemTemplateId); } + /** + * Is supplied parent id on the ragfair custom item category blacklist + * @param parentId Parent Id to check is blacklisted + * @returns true if blacklisted + */ + protected isItemCategoryOnCustomFleaBlacklist(itemParentId: string): boolean + { + return this.ragfairConfig.dynamic.blacklist.customItemCategoryList.includes(itemParentId); + } + /** * is supplied id a trader * @param traderId diff --git a/project/src/models/spt/config/IRagfairConfig.ts b/project/src/models/spt/config/IRagfairConfig.ts index 43e08e24..7ebc081f 100644 --- a/project/src/models/spt/config/IRagfairConfig.ts +++ b/project/src/models/spt/config/IRagfairConfig.ts @@ -150,6 +150,10 @@ export interface Blacklist traderItems: boolean; /** Maximum level an armor plate can be found in a flea-listed armor item */ armorPlate: IArmorPlateBlacklistSettings; + /** Should specific categories be blacklisted from the flea, true = use blacklist */ + enableCustomItemCategoryList: boolean; + /** Custom category blacklist for parent Ids */ + customItemCategoryList: string[]; } export interface IArmorPlateBlacklistSettings