mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
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: SPT-AKI/Server#168
77 lines
2.6 KiB
TypeScript
77 lines
2.6 KiB
TypeScript
import { DependencyContainer, inject, injectable } from "tsyringe";
|
|
|
|
import { OnLoad } from "@spt-aki/di/OnLoad";
|
|
import { ModTypeCheck } from "@spt-aki/loaders/ModTypeCheck";
|
|
import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
|
|
import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";
|
|
import { IPostDBLoadModAsync } from "@spt-aki/models/external/IPostDBLoadModAsync";
|
|
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
|
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
|
|
|
@injectable()
|
|
export class PostDBModLoader implements OnLoad
|
|
{
|
|
constructor(
|
|
@inject("WinstonLogger") protected logger: ILogger,
|
|
@inject("PreAkiModLoader") protected preAkiModLoader: PreAkiModLoader,
|
|
@inject("LocalisationService") protected localisationService: LocalisationService,
|
|
@inject("ModTypeCheck") protected modTypeCheck: ModTypeCheck,
|
|
)
|
|
{}
|
|
|
|
public async onLoad(): Promise<void>
|
|
{
|
|
if (globalThis.G_MODS_ENABLED)
|
|
{
|
|
await this.executeMods(this.preAkiModLoader.getContainer());
|
|
}
|
|
}
|
|
|
|
public getRoute(): string
|
|
{
|
|
return "aki-mods";
|
|
}
|
|
|
|
public getModPath(mod: string): string
|
|
{
|
|
return this.preAkiModLoader.getModPath(mod);
|
|
}
|
|
|
|
protected async executeMods(container: DependencyContainer): Promise<void>
|
|
{
|
|
const mods = this.preAkiModLoader.sortModsLoadOrder();
|
|
for (const modName of mods)
|
|
{
|
|
// import class
|
|
const filepath = `${this.preAkiModLoader.getModPath(modName)}${
|
|
this.preAkiModLoader.getImportedModDetails()[modName].main
|
|
}`;
|
|
const modpath = `${process.cwd()}/${filepath}`;
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
const mod = require(modpath);
|
|
|
|
if (this.modTypeCheck.isPostDBAkiLoadAsync(mod.mod))
|
|
{
|
|
try
|
|
{
|
|
await (mod.mod as IPostDBLoadModAsync).postDBLoadAsync(container);
|
|
}
|
|
catch (err)
|
|
{
|
|
this.logger.error(
|
|
this.localisationService.getText(
|
|
"modloader-async_mod_error",
|
|
`${err?.message ?? ""}\n${err.stack ?? ""}`,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
if (this.modTypeCheck.isPostDBAkiLoad(mod.mod))
|
|
{
|
|
(mod.mod as IPostDBLoadMod).postDBLoad(container);
|
|
}
|
|
}
|
|
}
|
|
}
|