Server/project/src/callbacks/ModCallbacks.ts

42 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-03-03 16:23:46 +01:00
import { inject, injectable } from "tsyringe";
import { OnLoad } from "@spt/di/OnLoad";
import { PostSptModLoader } from "@spt/loaders/PostSptModLoader";
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
import { IHttpConfig } from "@spt/models/spt/config/IHttpConfig";
import { ILogger } from "@spt/models/spt/utils/ILogger";
import { ConfigServer } from "@spt/servers/ConfigServer";
import { LocalisationService } from "@spt/services/LocalisationService";
import { HttpFileUtil } from "@spt/utils/HttpFileUtil";
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
2023-03-03 16:23:46 +01:00
@injectable()
2023-11-10 21:19:56 +01:00
export class ModCallbacks implements OnLoad
2023-03-03 16:23:46 +01:00
{
protected httpConfig: IHttpConfig;
constructor(
@inject("PrimaryLogger") protected logger: ILogger,
2023-03-03 16:23:46 +01:00
@inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil,
@inject("HttpFileUtil") protected httpFileUtil: HttpFileUtil,
@inject("PostSptModLoader") protected postSptModLoader: PostSptModLoader,
2023-03-03 16:23:46 +01:00
@inject("LocalisationService") protected localisationService: LocalisationService,
2023-11-10 21:19:56 +01:00
@inject("ConfigServer") protected configServer: ConfigServer,
2023-03-03 16:23:46 +01:00
)
{
this.httpConfig = this.configServer.getConfig(ConfigTypes.HTTP);
}
2023-11-10 21:19:56 +01:00
2023-03-03 16:23:46 +01:00
public async onLoad(): Promise<void>
{
if (globalThis.G_MODS_ENABLED)
{
await this.postSptModLoader.load();
2023-03-03 16:23:46 +01:00
}
}
public getRoute(): string
{
return "spt-mods";
2023-03-03 16:23:46 +01:00
}
}