From d4bf80cbc6566a09f138b660d846718e0e12486c Mon Sep 17 00:00:00 2001 From: George Gaulin Date: Sun, 26 Jun 2022 12:25:24 -0400 Subject: [PATCH] Fix WeightChanges option --- Ereshkigal-AkiConfig/config/config.json | 3 +- Ereshkigal-AkiConfig/models/IConfig.ts | 1 - Ereshkigal-AkiConfig/models/ILocale.ts | 1 - Ereshkigal-AkiConfig/src/bots.ts | 29 ++++++++----- Ereshkigal-AkiConfig/src/generator.ts | 56 ++++++++++++++++--------- Ereshkigal-AkiConfig/src/mod.ts | 1 + 6 files changed, 56 insertions(+), 35 deletions(-) diff --git a/Ereshkigal-AkiConfig/config/config.json b/Ereshkigal-AkiConfig/config/config.json index 1c8f897..e270dad 100644 --- a/Ereshkigal-AkiConfig/config/config.json +++ b/Ereshkigal-AkiConfig/config/config.json @@ -42,8 +42,7 @@ } } } - }, - "enableChristmasGifts": false + } }, "Raids values": { "Loot values": { diff --git a/Ereshkigal-AkiConfig/models/IConfig.ts b/Ereshkigal-AkiConfig/models/IConfig.ts index 790720a..6a3cb03 100644 --- a/Ereshkigal-AkiConfig/models/IConfig.ts +++ b/Ereshkigal-AkiConfig/models/IConfig.ts @@ -215,7 +215,6 @@ export interface ServerValues http: HTTP; health: Health; hideout: Hideout; - enableChristmasGifts: boolean; } export interface RaidsValues diff --git a/Ereshkigal-AkiConfig/models/ILocale.ts b/Ereshkigal-AkiConfig/models/ILocale.ts index c7c4943..84f2fc6 100644 --- a/Ereshkigal-AkiConfig/models/ILocale.ts +++ b/Ereshkigal-AkiConfig/models/ILocale.ts @@ -215,7 +215,6 @@ export interface ServerValues http: HTTP; health: Health; hideout: Hideout; - enableChristmasGifts: boolean; } export interface RaidsValues diff --git a/Ereshkigal-AkiConfig/src/bots.ts b/Ereshkigal-AkiConfig/src/bots.ts index 984e2a2..2730a86 100644 --- a/Ereshkigal-AkiConfig/src/bots.ts +++ b/Ereshkigal-AkiConfig/src/bots.ts @@ -1,18 +1,25 @@ -/* -エレシュキガル -*/ +import { inject, injectable } from "tsyringe"; +import type { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; +import { IBotConfig } from "@spt-aki/models/spt/config/IBotConfig"; +import { AkiConfigHandler } from "./AkiConfigHandler"; -"use strict"; - -class bots +@injectable() +export class bots { - static applyValues() + constructor( + @inject("AkiConfigHandler") private configHandler: AkiConfigHandler, + @inject("DatabaseServer") private database: DatabaseServer + ) + {} + + public applyChanges(): void { - const bots = BotConfig; - const config = require('../../config/pmcConfig.json'); + const configServer = container.resolve("ConfigServer"); + const BotConfig = configServer.getConfig(ConfigTypes.BOT); - const pmcsConfig = config.pmc.types - for (const bot in pmcsConfig) { + const pmcsConfig = this.configHandler.getPmcConfig().pmc.types + for (const bot in pmcsConfig) + { switch (bot) { default: bots.pmc.types[bot] = pmcsConfig[bot] diff --git a/Ereshkigal-AkiConfig/src/generator.ts b/Ereshkigal-AkiConfig/src/generator.ts index 0ecba6e..b03b547 100644 --- a/Ereshkigal-AkiConfig/src/generator.ts +++ b/Ereshkigal-AkiConfig/src/generator.ts @@ -1,20 +1,37 @@ -/* -エレシュキガル -*/ +import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { inject, injectable } from "tsyringe"; +import { VFS } from "@spt-aki/utils/VFS"; +import { ConfigServer } from "@spt-aki/servers/ConfigServer"; +import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; +import { IBotConfig } from "@spt-aki/models/spt/config/IBotConfig"; +import { IAirdropConfig } from "@spt-aki/models/spt/config/IAirdropConfig"; +import { IInRaidConfig } from "@spt-aki/models/spt/config/IInRaidConfig"; +import { IInventoryConfig } from "@spt-aki/models/spt/config/IInventoryConfig"; +import { ILocationConfig } from "@spt-aki/models/spt/config/ILocationConfig"; +import { IRagfairConfig } from "@spt-aki/models/spt/config/IRagfairConfig"; -"use strict"; +@injectable() +export class AkiGenerator +{ + private mod; + private firstRun; -class generator { - static createConfig(file) { - const mod = require("../../package.json"); + constructor( + @inject("WinstonLogger") private logger: ILogger + ) + {} + + private createConfig(file: string): void + { + this.mod = require("../package.json"); this.firstRun = true; let config = null; let dailyConfig = null; let pmcConfig = null; /* - Generate the whole configuration on first run - This way the default values are always up to date to AKI. - */ + Generate the whole configuration on first run + This way the default values are always up to date to AKI. + */ //The default file type must be an object config = { @@ -41,7 +58,7 @@ class generator { pmcConfig = {}; //We will have to gather every config that exists atm and throw them together into the object - const bots = BotConfig; + const bots = ConfigServer.getConfig(ConfigTypes.BOT); const health = HealthConfig; const hideout = HideoutConfig; const http = HttpConfig; @@ -128,7 +145,7 @@ class generator { } else { - Logger.warning(`[AKI-CONFIG] - Generating ${file} file`) + this.logger.warning(`[AKI-CONFIG] - Generating ${file} file`) let toWrite = null if(file === "config"){toWrite = config}else if(file === 'dailyConfig'){toWrite = dailyConfig}else if(file === 'pmcConfig'){toWrite = pmcConfig} VFS.writeFile( @@ -136,10 +153,11 @@ class generator { JsonUtil.serialize(toWrite, true) ); } - Logger.error("[AKI-Config]: New configuration file created, please restart your server to use it."); + this.logger.error("[AKI-Config]: New configuration file created, please restart your server to use it."); } - static checkConfigExisting() { + public checkConfigExisting(): void + { const mod = require("../../package.json"); const modPath = ModLoader.getModPath(mod.name); const validation = []; @@ -162,12 +180,12 @@ class generator { } //All configurations files existing if ((validation.length === 3)) { - Logger.success( + this.logger.success( `[AKI-CONFIG] - All configurations files already created, all green.` ); } else { //One of the 3 file is missing, we only want to regenerate the missing one - Logger.error( + this.logger.error( `[AKI-CONFIG] - A config file is missing. Generating the missing file` ); @@ -182,12 +200,10 @@ class generator { } } } else { - Logger.warning( + this.logger.warning( "First time AKI-Configurator is run, generating the config file..." ); this.createConfig(null); } } -} - -module.exports = generator; \ No newline at end of file +} \ No newline at end of file diff --git a/Ereshkigal-AkiConfig/src/mod.ts b/Ereshkigal-AkiConfig/src/mod.ts index 034995b..8bc0601 100644 --- a/Ereshkigal-AkiConfig/src/mod.ts +++ b/Ereshkigal-AkiConfig/src/mod.ts @@ -1,6 +1,7 @@ import { DependencyContainer, Lifecycle } from "tsyringe"; import type { IMod } from "@spt-aki/models/external/mod"; import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; +import { Bots } from "./bots"; class AkiConfig implements IMod {