This is the first pass of ESLint on the codebase. ESLint formatting is less strict when it comes to line-length and line-breaks then dprint/biome, so if you see formatting that you don't like... fix it! It shouldn't require a configuration change. - This should merge clean into master (when the time comes). - This will not merge clean into `3.9.0-DEV`, but the conflicts aren't that bad.
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { inject, injectable } from "tsyringe";
|
|
import { OnLoad } from "@spt-aki/di/OnLoad";
|
|
import { OnUpdate } from "@spt-aki/di/OnUpdate";
|
|
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
|
import { ICoreConfig } from "@spt-aki/models/spt/config/ICoreConfig";
|
|
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
|
import { SaveServer } from "@spt-aki/servers/SaveServer";
|
|
|
|
@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 "aki-save";
|
|
}
|
|
|
|
public async onUpdate(secondsSinceLastRun: number): Promise<boolean>
|
|
{
|
|
// run every 15 seconds
|
|
if (secondsSinceLastRun > this.coreConfig.profileSaveIntervalSeconds)
|
|
{
|
|
this.saveServer.save();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|