0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00
server/project/src/callbacks/SaveCallbacks.ts
Refringe 5740774a46
Apply Biome Formatting
This is the result of running `npm run format` which applies the Biome formatting rules. Rejoice!
2024-07-23 11:12:53 -04:00

37 lines
1.1 KiB
TypeScript

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