Feature: expose profile save wait delay in config

This commit is contained in:
Dev 2023-03-23 15:03:54 +00:00
parent a207e5778e
commit a5272dc596
3 changed files with 15 additions and 6 deletions

View File

@ -2,5 +2,6 @@
"akiVersion": "3.5.4",
"projectName": "SPT-AKI",
"compatibleTarkovVersion": "0.13.0.22173",
"serverName": "SPT Server"
"serverName": "SPT Server",
"profileSaveIntervalSeconds": 15
}

View File

@ -1,16 +1,23 @@
import { inject, injectable } from "tsyringe";
import { OnLoad } from "../di/OnLoad";
import { OnUpdate } from "../di/OnUpdate";
import { ConfigTypes } from "../models/enums/ConfigTypes";
import { ICoreConfig } from "../models/spt/config/ICoreConfig";
import { ConfigServer } from "../servers/ConfigServer";
import { SaveServer } from "../servers/SaveServer";
@injectable()
export class SaveCallbacks implements OnLoad, OnUpdate
{
protected coreConfig: ICoreConfig;
constructor(
@inject("SaveServer") protected saveServer: SaveServer
@inject("SaveServer") protected saveServer: SaveServer,
@inject("ConfigServer") protected configServer: ConfigServer
)
{
this.coreConfig = this.configServer.getConfig(ConfigTypes.CORE);
}
public async onLoad(): Promise<void>
@ -26,7 +33,7 @@ export class SaveCallbacks implements OnLoad, OnUpdate
public async onUpdate(secondsSinceLastRun: number): Promise<boolean>
{
// run every 15 seconds
if (secondsSinceLastRun > 15)
if (secondsSinceLastRun > this.coreConfig.profileSaveIntervalSeconds)
{
this.saveServer.save();
return true;

View File

@ -5,7 +5,8 @@ export interface ICoreConfig extends IBaseConfig
kind: "aki-core"
akiVersion: string
projectName: string
compatibleTarkovVersion: string,
serverName: string;
compatibleTarkovVersion: string
serverName: string
profileSaveIntervalSeconds: number
commit: string
}