4ac12ef70a
These are the formatting & linting configuration changes from the `3.8.0` branch and the changes that they make to the overall project. The majority of these changes are from running two commands: `npm run lint:fix` `npm run style:fix` This has already been run on the `3.8.0` branch and this PR should make `master` play nicer when it comes to merges going forward. There are now four VSCode plugins recommended for server development. They've been added to the workspace file and a user should get a UI notification when the workspace is opened if they're not installed. The four plugins are: https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig https://marketplace.visualstudio.com/items?itemName=dprint.dprint https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint https://marketplace.visualstudio.com/items?itemName=biomejs.biome Once installed they should just work within the workspace. Also, be sure to `npm i` to get the new dprint application. Co-authored-by: Refringe <brownelltyler@gmail.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/168
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import { inject, injectable } from "tsyringe";
|
|
|
|
import { IAkiProfile } from "@spt-aki/models/eft/profile/IAkiProfile";
|
|
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
|
|
|
@injectable()
|
|
export class ProfileSnapshotService
|
|
{
|
|
protected storedProfileSnapshots: Record<string, IAkiProfile> = {};
|
|
|
|
constructor(@inject("JsonUtil") protected jsonUtil: JsonUtil)
|
|
{}
|
|
|
|
/**
|
|
* Store a profile into an in-memory object
|
|
* @param sessionID session id - acts as the key
|
|
* @param profile - profile to save
|
|
*/
|
|
public storeProfileSnapshot(sessionID: string, profile: IAkiProfile): void
|
|
{
|
|
this.storedProfileSnapshots[sessionID] = this.jsonUtil.clone(profile);
|
|
}
|
|
|
|
/**
|
|
* Retreve a stored profile
|
|
* @param sessionID key
|
|
* @returns A player profile object
|
|
*/
|
|
public getProfileSnapshot(sessionID: string): IAkiProfile
|
|
{
|
|
if (this.storedProfileSnapshots[sessionID])
|
|
{
|
|
return this.storedProfileSnapshots[sessionID];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Does a profile exists against the provided key
|
|
* @param sessionID key
|
|
* @returns true if exists
|
|
*/
|
|
public hasProfileSnapshot(sessionID: string): boolean
|
|
{
|
|
if (this.storedProfileSnapshots[sessionID])
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Remove a stored profile by key
|
|
* @param sessionID key
|
|
*/
|
|
public clearProfileSnapshot(sessionID: string): void
|
|
{
|
|
delete this.storedProfileSnapshots[sessionID];
|
|
}
|
|
}
|