Cloned blacklist data before returning it

This commit is contained in:
Dev 2024-06-04 18:18:52 +01:00
parent 83dd0ed439
commit dde78b30eb

View File

@ -4,6 +4,7 @@ import { IItemConfig } from "@spt/models/spt/config/IItemConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ILogger } from "@spt/models/spt/utils/ILogger";
import { ConfigServer } from "@spt/servers/ConfigServer"; import { ConfigServer } from "@spt/servers/ConfigServer";
import { DatabaseServer } from "@spt/servers/DatabaseServer"; import { DatabaseServer } from "@spt/servers/DatabaseServer";
import { ICloner } from "@spt/utils/cloners/ICloner";
/** Centralise the handling of blacklisting items, uses blacklist found in config/item.json, stores items that should not be used by players / broken items */ /** Centralise the handling of blacklisting items, uses blacklist found in config/item.json, stores items that should not be used by players / broken items */
@injectable() @injectable()
@ -13,6 +14,7 @@ export class ItemFilterService
constructor( constructor(
@inject("PrimaryLogger") protected logger: ILogger, @inject("PrimaryLogger") protected logger: ILogger,
@inject("PrimaryCloner") protected cloner: ICloner,
@inject("DatabaseServer") protected databaseServer: DatabaseServer, @inject("DatabaseServer") protected databaseServer: DatabaseServer,
@inject("ConfigServer") protected configServer: ConfigServer, @inject("ConfigServer") protected configServer: ConfigServer,
) )
@ -46,7 +48,7 @@ export class ItemFilterService
*/ */
public getItemRewardBlacklist(): string[] public getItemRewardBlacklist(): string[]
{ {
return this.itemConfig.rewardItemBlacklist; return this.cloner.clone(this.itemConfig.rewardItemBlacklist);
} }
/** /**
@ -55,7 +57,7 @@ export class ItemFilterService
*/ */
public getBlacklistedItems(): string[] public getBlacklistedItems(): string[]
{ {
return this.itemConfig.blacklist; return this.cloner.clone(this.itemConfig.blacklist);
} }
/** /**
@ -74,6 +76,6 @@ export class ItemFilterService
*/ */
public getBossItems(): string[] public getBossItems(): string[]
{ {
return this.itemConfig.bossItems; return this.cloner.clone(this.itemConfig.bossItems);
} }
} }