Fixed pretty much all the things that were triggering my OCD #28

Merged
chomp merged 6 commits from :random-fixes into 3.9.0-DEV 2024-05-20 15:45:36 -04:00
57 changed files with 366 additions and 347 deletions
Showing only changes of commit de74980eb4 - Show all commits

View File

@ -1,4 +1,5 @@
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { Processing } from "./Processing"; import { Processing } from "./Processing";
@ -11,7 +12,7 @@ export class MyMod
// All these types are automatically wired when the container resolves the bean creation // All these types are automatically wired when the container resolves the bean creation
constructor( constructor(
@inject("Processing") private processing: Processing, @inject("Processing") private processing: Processing,
@inject("WinstonLogger") private logger: ILogger @inject("WinstonLogger") private logger: ILogger,
) )
{} {}

View File

@ -1,4 +1,5 @@
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
@injectable() @injectable()
@ -9,7 +10,7 @@ export class Processing
private calls = 0; private calls = 0;
constructor( constructor(
@inject("WinstonLogger") private logger: ILogger @inject("WinstonLogger") private logger: ILogger,
) )
{} {}

View File

@ -1,4 +1,5 @@
import { DependencyContainer, Lifecycle } from "tsyringe"; import { DependencyContainer, Lifecycle } from "tsyringe";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod"; import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod";
import { MyMod } from "./MyMod"; import { MyMod } from "./MyMod";

View File

@ -1,4 +1,5 @@
import { DependencyContainer } from "tsyringe"; import { DependencyContainer } from "tsyringe";
import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod"; import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";

View File

@ -1,3 +1,5 @@
import { inject, injectable } from "tsyringe";
import { LauncherCallbacks } from "@spt-aki/callbacks/LauncherCallbacks"; import { LauncherCallbacks } from "@spt-aki/callbacks/LauncherCallbacks";
import { LauncherController } from "@spt-aki/controllers/LauncherController"; import { LauncherController } from "@spt-aki/controllers/LauncherController";
import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData"; import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData";
@ -5,7 +7,6 @@ import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { SaveServer } from "@spt-aki/servers/SaveServer"; import { SaveServer } from "@spt-aki/servers/SaveServer";
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
import { Watermark } from "@spt-aki/utils/Watermark"; import { Watermark } from "@spt-aki/utils/Watermark";
import { inject, injectable } from "tsyringe";
// We need to declare this class as injectable, this will add the container // We need to declare this class as injectable, this will add the container
// metadata // metadata
@ -20,7 +21,7 @@ export class MyCustomLauncherCallbacks extends LauncherCallbacks // <<<<=== This
@inject("LauncherController") launcherController: LauncherController, @inject("LauncherController") launcherController: LauncherController,
@inject("SaveServer") saveServer: SaveServer, @inject("SaveServer") saveServer: SaveServer,
@inject("Watermark") watermark: Watermark, @inject("Watermark") watermark: Watermark,
@inject("WinstonLogger") private logger: ILogger @inject("WinstonLogger") private logger: ILogger,
) )
{ {
// Pass the parent class (LauncherCallbacks) the dependencies it needs to work // Pass the parent class (LauncherCallbacks) the dependencies it needs to work

View File

@ -1,4 +1,5 @@
import { DependencyContainer } from "tsyringe"; import { DependencyContainer } from "tsyringe";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod" import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"
import { MyCustomLauncherCallbacks } from "./MyCustomLauncherCallbacks"; import { MyCustomLauncherCallbacks } from "./MyCustomLauncherCallbacks";
@ -25,7 +26,6 @@ class Mod implements IPreAkiLoadMod
container.register("LauncherCallbacks", { useToken: "MyCustomLauncherCallbacks" }); container.register("LauncherCallbacks", { useToken: "MyCustomLauncherCallbacks" });
// Now that its registered, the server will automatically find this dependency and use it where ever its needed // Now that its registered, the server will automatically find this dependency and use it where ever its needed
} }
} }

View File

@ -23,18 +23,18 @@ export class FluentAssortConstructor
* @param itemTpl Tpl id of the item you want trader to sell * @param itemTpl Tpl id of the item you want trader to sell
* @param itemId Optional - set your own Id, otherwise unique id will be generated * @param itemId Optional - set your own Id, otherwise unique id will be generated
*/ */
public createSingleAssortItem(itemTpl: string, itemId = undefined): FluentAssortConstructor public createSingleAssortItem(itemTpl: string, itemId: string = undefined): FluentAssortConstructor
{ {
// Create item ready for insertion into assort table // Create item ready for insertion into assort table
const newItemToAdd: Item = { const newItemToAdd: Item = {
_id: !itemId ? this.hashUtil.generate(): itemId, _id: itemId ?? this.hashUtil.generate(),
_tpl: itemTpl, _tpl: itemTpl,
parentId: "hideout", // Should always be "hideout" parentId: "hideout", // Should always be "hideout"
slotId: "hideout", // Should always be "hideout" slotId: "hideout", // Should always be "hideout"
upd: { upd: {
UnlimitedCount: false, UnlimitedCount: false,
StackObjectsCount: 100 StackObjectsCount: 100,
} },
}; };
this.itemsToSell.push(newItemToAdd); this.itemsToSell.push(newItemToAdd);
@ -47,10 +47,7 @@ export class FluentAssortConstructor
items[0].parentId = "hideout"; items[0].parentId = "hideout";
items[0].slotId = "hideout"; items[0].slotId = "hideout";
if (!items[0].upd) items[0].upd ??= {};
{
items[0].upd = {}
}
items[0].upd.UnlimitedCount = false; items[0].upd.UnlimitedCount = false;
items[0].upd.StackObjectsCount = 100; items[0].upd.StackObjectsCount = 100;
@ -99,14 +96,12 @@ export class FluentAssortConstructor
public addMoneyCost(currencyType: Money, amount: number): FluentAssortConstructor public addMoneyCost(currencyType: Money, amount: number): FluentAssortConstructor
{ {
this.barterScheme[this.itemsToSell[0]._id] = [ this.barterScheme[this.itemsToSell[0]._id] = [[
[
{ {
count: amount, count: amount,
_tpl: currencyType _tpl: currencyType,
} },
] ]];
];
return this; return this;
} }
@ -121,8 +116,8 @@ export class FluentAssortConstructor
this.barterScheme[sellableItemId] = [[ this.barterScheme[sellableItemId] = [[
{ {
count: count, count: count,
_tpl: itemTpl _tpl: itemTpl,
} },
]]; ]];
} }
else else
@ -139,10 +134,9 @@ export class FluentAssortConstructor
// No barter for item, add it fresh // No barter for item, add it fresh
this.barterScheme[sellableItemId][0].push({ this.barterScheme[sellableItemId][0].push({
count: count, count: count,
_tpl: itemTpl _tpl: itemTpl,
}) });
} }
} }
return this; return this;

View File

@ -12,21 +12,22 @@ import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
import { ITraderConfig } from "@spt-aki/models/spt/config/ITraderConfig"; import { ITraderConfig } from "@spt-aki/models/spt/config/ITraderConfig";
import { IRagfairConfig } from "@spt-aki/models/spt/config/IRagfairConfig"; import { IRagfairConfig } from "@spt-aki/models/spt/config/IRagfairConfig";
import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { JsonUtil } from "@spt-aki/utils/JsonUtil";
// New trader settings
import * as baseJson from "../db/base.json";
import { TraderHelper } from "./traderHelpers";
import { FluentAssortConstructor as FluentAssortCreator } from "./fluentTraderAssortCreator";
import { Money } from "@spt-aki/models/enums/Money"; import { Money } from "@spt-aki/models/enums/Money";
import { Traders } from "@spt-aki/models/enums/Traders"; import { Traders } from "@spt-aki/models/enums/Traders";
import { HashUtil } from "@spt-aki/utils/HashUtil"; import { HashUtil } from "@spt-aki/utils/HashUtil";
// New trader settings
import * as baseJson from "../db/base.json";
import { TraderHelper } from "./traderHelpers";
import { FluentAssortConstructor as FluentAssortCreator } from "./fluentTraderAssortCreator";
class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod
{ {
private mod: string private mod: string;
private logger: ILogger private logger: ILogger;
private traderHelper: TraderHelper private traderHelper: TraderHelper;
private fluentAssortCreator: FluentAssortCreator private fluentAssortCreator: FluentAssortCreator;
constructor() { constructor() {
this.mod = "13AddTrader"; // Set name of mod so we can log it to console later this.mod = "13AddTrader"; // Set name of mod so we can log it to console later
@ -86,7 +87,8 @@ class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod
// Add milk // Add milk
const MILK_ID = "575146b724597720a27126d5"; // Can find item ids in `database\templates\items.json` or with https://db.sp-tarkov.com/search const MILK_ID = "575146b724597720a27126d5"; // Can find item ids in `database\templates\items.json` or with https://db.sp-tarkov.com/search
this.fluentAssortCreator.createSingleAssortItem(MILK_ID) this.fluentAssortCreator
.createSingleAssortItem(MILK_ID)
.addStackCount(200) .addStackCount(200)
.addBuyRestriction(10) .addBuyRestriction(10)
.addMoneyCost(Money.ROUBLES, 2000) .addMoneyCost(Money.ROUBLES, 2000)
@ -94,9 +96,10 @@ class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod
.export(tables.traders[baseJson._id]); .export(tables.traders[baseJson._id]);
// Add 3x bitcoin + salewa for milk barter // Add 3x bitcoin + salewa for milk barter
const BITCOIN_ID = "59faff1d86f7746c51718c9c" const BITCOIN_ID = "59faff1d86f7746c51718c9c";
const SALEWA_ID = "544fb45d4bdc2dee738b4568"; const SALEWA_ID = "544fb45d4bdc2dee738b4568";
this.fluentAssortCreator.createSingleAssortItem(MILK_ID) this.fluentAssortCreator
.createSingleAssortItem(MILK_ID)
.addStackCount(100) .addStackCount(100)
.addBarterCost(BITCOIN_ID, 3) .addBarterCost(BITCOIN_ID, 3)
.addBarterCost(SALEWA_ID, 1) .addBarterCost(SALEWA_ID, 1)
@ -105,7 +108,8 @@ class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod
// Add glock as money purchase // Add glock as money purchase
this.fluentAssortCreator.createComplexAssortItem(this.traderHelper.createGlock()) this.fluentAssortCreator
.createComplexAssortItem(this.traderHelper.createGlock())
.addUnlimitedStackCount() .addUnlimitedStackCount()
.addMoneyCost(Money.ROUBLES, 20000) .addMoneyCost(Money.ROUBLES, 20000)
.addBuyRestriction(3) .addBuyRestriction(3)
@ -113,7 +117,8 @@ class SampleTrader implements IPreAkiLoadMod, IPostDBLoadMod
.export(tables.traders[baseJson._id]); .export(tables.traders[baseJson._id]);
// Add mp133 preset as mayo barter // Add mp133 preset as mayo barter
this.fluentAssortCreator.createComplexAssortItem(tables.globals.ItemPresets["584148f2245977598f1ad387"]._items) this.fluentAssortCreator
.createComplexAssortItem(tables.globals.ItemPresets["584148f2245977598f1ad387"]._items)
.addStackCount(200) .addStackCount(200)
.addBarterCost("5bc9b156d4351e00367fbce9", 1) .addBarterCost("5bc9b156d4351e00367fbce9", 1)
.addBuyRestriction(3) .addBuyRestriction(3)

View File

@ -11,6 +11,7 @@ export class TraderHelper
/** /**
* Add profile picture to our trader * Add profile picture to our trader
* @param baseJson json file for trader (db/base.json) * @param baseJson json file for trader (db/base.json)
* @param modName mod folder name
* @param preAkiModLoader mod loader class - used to get the mods file path * @param preAkiModLoader mod loader class - used to get the mods file path
* @param imageRouter image router class - used to register the trader image path so we see their image on trader page * @param imageRouter image router class - used to register the trader image path so we see their image on trader page
* @param traderImageName Filename of the trader icon to use * @param traderImageName Filename of the trader icon to use
@ -38,8 +39,9 @@ export class TraderHelper
traderId: baseJson._id, traderId: baseJson._id,
seconds: { seconds: {
min: refreshTimeSecondsMin, min: refreshTimeSecondsMin,
max: refreshTimeSecondsMax max: refreshTimeSecondsMax,
} }; },
};
traderConfig.updateTime.push(traderRefreshRecord); traderConfig.updateTime.push(traderRefreshRecord);
} }
@ -60,15 +62,13 @@ export class TraderHelper
questassort: { questassort: {
started: {}, started: {},
success: {}, success: {},
fail: {} fail: {},
} // questassort is empty as trader has no assorts unlocked by quests }, // questassort is empty as trader has no assorts unlocked by quests
}; };
} }
/** /**
* Create basic data for trader + add empty assorts table for trader * Create basic data for trader + add empty assorts table for trader
* @param tables SPT db
* @param jsonUtil SPT JSON utility class
* @returns ITraderAssort * @returns ITraderAssort
*/ */
private createAssortTable(): ITraderAssort private createAssortTable(): ITraderAssort
@ -78,8 +78,8 @@ export class TraderHelper
nextResupply: 0, nextResupply: 0,
items: [], items: [],
barter_scheme: {}, barter_scheme: {},
loyal_level_items: {} loyal_level_items: {},
} };
return assortTable; return assortTable;
} }
@ -96,7 +96,7 @@ export class TraderHelper
// Add the base first // Add the base first
glock.push({ // Add the base weapon first glock.push({ // Add the base weapon first
_id: "glockBase", // Ids dont matter, as long as they are unique (can use hashUtil.generate() if you dont want to type every id by hand) _id: "glockBase", // Ids dont matter, as long as they are unique (can use hashUtil.generate() if you dont want to type every id by hand)
_tpl: "5a7ae0c351dfba0017554310" // This is the weapons tpl, found on: https://db.sp-tarkov.com/search _tpl: "5a7ae0c351dfba0017554310", // This is the weapons tpl, found on: https://db.sp-tarkov.com/search
}); });
// Add barrel // Add barrel
@ -104,7 +104,7 @@ export class TraderHelper
_id: "glockbarrel", _id: "glockbarrel",
_tpl: "5a6b60158dc32e000a31138b", _tpl: "5a6b60158dc32e000a31138b",
parentId: "glockBase", // This is a sub item, you need to define its parent its attached to / inserted into parentId: "glockBase", // This is a sub item, you need to define its parent its attached to / inserted into
slotId: "mod_barrel" // Required for mods, you need to define what 'role' they have slotId: "mod_barrel", // Required for mods, you need to define what 'role' they have
}); });
// Add reciever // Add reciever
@ -112,7 +112,7 @@ export class TraderHelper
_id: "glockReciever", _id: "glockReciever",
_tpl:"5a9685b1a2750c0032157104", _tpl:"5a9685b1a2750c0032157104",
parentId: "glockBase", parentId: "glockBase",
slotId: "mod_reciever" slotId: "mod_reciever",
}); });
// Add compensator // Add compensator
@ -120,7 +120,7 @@ export class TraderHelper
_id: "glockCompensator", _id: "glockCompensator",
_tpl:"5a7b32a2e899ef00135e345a", _tpl:"5a7b32a2e899ef00135e345a",
parentId: "glockReciever", // The parent of this mod is the reciever NOT weapon, be careful to get the correct parent parentId: "glockReciever", // The parent of this mod is the reciever NOT weapon, be careful to get the correct parent
slotId: "mod_muzzle" slotId: "mod_muzzle",
}); });
// Add Pistol grip // Add Pistol grip
@ -128,7 +128,7 @@ export class TraderHelper
_id: "glockPistolGrip", _id: "glockPistolGrip",
_tpl:"5a7b4960e899ef197b331a2d", _tpl:"5a7b4960e899ef197b331a2d",
parentId: "glockBase", parentId: "glockBase",
slotId: "mod_pistol_grip" slotId: "mod_pistol_grip",
}); });
// Add front sight // Add front sight
@ -136,7 +136,7 @@ export class TraderHelper
_id: "glockRearSight", _id: "glockRearSight",
_tpl: "5a6f5d528dc32e00094b97d9", _tpl: "5a6f5d528dc32e00094b97d9",
parentId: "glockReciever", parentId: "glockReciever",
slotId: "mod_sight_rear" slotId: "mod_sight_rear",
}); });
// Add rear sight // Add rear sight
@ -144,7 +144,7 @@ export class TraderHelper
_id: "glockFrontSight", _id: "glockFrontSight",
_tpl: "5a6f58f68dc32e000a311390", _tpl: "5a6f58f68dc32e000a311390",
parentId: "glockReciever", parentId: "glockReciever",
slotId: "mod_sight_front" slotId: "mod_sight_front",
}); });
// Add magazine // Add magazine
@ -152,7 +152,7 @@ export class TraderHelper
_id: "glockMagazine", _id: "glockMagazine",
_tpl: "630769c4962d0247b029dc60", _tpl: "630769c4962d0247b029dc60",
parentId: "glockBase", parentId: "glockBase",
slotId: "mod_magazine" slotId: "mod_magazine",
}); });
return glock; return glock;
@ -171,7 +171,8 @@ export class TraderHelper
public addTraderToLocales(baseJson: any, tables: IDatabaseTables, fullName: string, firstName: string, nickName: string, location: string, description: string) public addTraderToLocales(baseJson: any, tables: IDatabaseTables, fullName: string, firstName: string, nickName: string, location: string, description: string)
{ {
// For each language, add locale for the new trader // For each language, add locale for the new trader
const locales = Object.values(tables.locales.global) as Record<string, string>[]; const locales = Object.values(tables.locales.global);
for (const locale of locales) { for (const locale of locales) {
locale[`${baseJson._id} FullName`] = fullName; locale[`${baseJson._id} FullName`] = fullName;
locale[`${baseJson._id} FirstName`] = firstName; locale[`${baseJson._id} FirstName`] = firstName;

View File

@ -1,5 +1,6 @@
import { IncomingMessage, ServerResponse } from "node:http";
import { IHttpListener } from "@spt-aki/servers/http/IHttpListener"; import { IHttpListener } from "@spt-aki/servers/http/IHttpListener";
import { IncomingMessage, ServerResponse } from "http";
export class Type2HttpListener implements IHttpListener export class Type2HttpListener implements IHttpListener
{ {
@ -7,7 +8,8 @@ export class Type2HttpListener implements IHttpListener
{ {
return req.method === "GET" && req.url?.includes("/type2-custom-url"); return req.method === "GET" && req.url?.includes("/type2-custom-url");
} }
public handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): void
public async handle(sessionId: string, req: IncomingMessage, resp: ServerResponse): Promise<void>
{ {
resp.writeHead(200, "OK"); resp.writeHead(200, "OK");
resp.end("[2] This is the second example of a mod hooking into the HttpServer"); resp.end("[2] This is the second example of a mod hooking into the HttpServer");

View File

@ -1,7 +1,8 @@
import { IncomingMessage, ServerResponse } from "node:http";
import { DependencyContainer } from "tsyringe"; import { DependencyContainer } from "tsyringe";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { HttpListenerModService } from "@spt-aki/services/mod/httpListener/HttpListenerModService"; import { HttpListenerModService } from "@spt-aki/services/mod/httpListener/HttpListenerModService";
import { IncomingMessage, ServerResponse } from "http";
import { Type2HttpListener } from "./Type2HttpListener"; import { Type2HttpListener } from "./Type2HttpListener";
class Mod implements IPreAkiLoadMod class Mod implements IPreAkiLoadMod

View File

@ -1,8 +1,9 @@
import { DependencyContainer } from "tsyringe";
import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader"; import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { ImporterUtil } from "@spt-aki/utils/ImporterUtil"; import { ImporterUtil } from "@spt-aki/utils/ImporterUtil";
import { DependencyContainer } from "tsyringe";
import { ConfigsModelBase } from "./model/ConfigsModel"; import { ConfigsModelBase } from "./model/ConfigsModel";
class Mod implements IPreAkiLoadMod { class Mod implements IPreAkiLoadMod {

View File

@ -1,8 +1,9 @@
import { DependencyContainer } from "tsyringe";
import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader"; import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
import { IPreAkiLoadModAsync } from "@spt-aki/models/external/IPreAkiLoadModAsync"; import { IPreAkiLoadModAsync } from "@spt-aki/models/external/IPreAkiLoadModAsync";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { ImporterUtil } from "@spt-aki/utils/ImporterUtil"; import { ImporterUtil } from "@spt-aki/utils/ImporterUtil";
import { DependencyContainer } from "tsyringe";
import { ConfigsModelBase } from "./model/ConfigsModel"; import { ConfigsModelBase } from "./model/ConfigsModel";
class Mod implements IPreAkiLoadModAsync { class Mod implements IPreAkiLoadModAsync {

View File

@ -1,8 +1,9 @@
import { DependencyContainer } from "tsyringe";
import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader"; import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
import { IPreAkiLoadModAsync } from "@spt-aki/models/external/IPreAkiLoadModAsync"; import { IPreAkiLoadModAsync } from "@spt-aki/models/external/IPreAkiLoadModAsync";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { ImporterUtil } from "@spt-aki/utils/ImporterUtil"; import { ImporterUtil } from "@spt-aki/utils/ImporterUtil";
import { DependencyContainer } from "tsyringe";
import { ConfigsModelBase } from "./model/ConfigsModel"; import { ConfigsModelBase } from "./model/ConfigsModel";
class Mod implements IPreAkiLoadModAsync { class Mod implements IPreAkiLoadModAsync {

View File

@ -19,13 +19,13 @@ class Mod implements IPostDBLoadMod, IPostAkiLoadMod
overrideProperties: { overrideProperties: {
Chambers: [ Chambers: [
{ {
"_name": "patron_in_weapon_000", _name: "patron_in_weapon_000",
"_id": "61f7c9e189e6fb1a5e3ea791", _id: "61f7c9e189e6fb1a5e3ea791",
"_parent": "CustomMP18", _parent: "CustomMP18",
"_props": { _props: {
"filters": [ filters: [
{ {
"Filter": [ Filter: [
"560d5e524bdc2d25448b4571", "560d5e524bdc2d25448b4571",
"5d6e6772a4b936088465b17c", "5d6e6772a4b936088465b17c",
"5d6e67fba4b9361bc73bc779", "5d6e67fba4b9361bc73bc779",
@ -41,16 +41,16 @@ class Mod implements IPostDBLoadMod, IPostAkiLoadMod
"5d6e68b3a4b9361bca7e50b5", "5d6e68b3a4b9361bca7e50b5",
"5d6e6891a4b9361bd473feea", "5d6e6891a4b9361bd473feea",
"5d6e689ca4b9361bc8618956", "5d6e689ca4b9361bc8618956",
"5d6e68d1a4b93622fe60e845" "5d6e68d1a4b93622fe60e845",
] ],
}
]
}, },
"_required": false, ],
"_mergeSlotWithChildren": false, },
"_proto": "55d4af244bdc2d962f8b4571" _required: false,
} _mergeSlotWithChildren: false,
] _proto: "55d4af244bdc2d962f8b4571",
},
],
}, //Overried properties basically tell the server on what data inside _props to be modified from the cloned item, in this example i am modifying the ammo used to be 12G }, //Overried properties basically tell the server on what data inside _props to be modified from the cloned item, in this example i am modifying the ammo used to be 12G
parentId: "5447b6094bdc2dc3278b4567", //ParentId refers to the Node item the gun will be under, you can check it in https://db.sp-tarkov.com/search parentId: "5447b6094bdc2dc3278b4567", //ParentId refers to the Node item the gun will be under, you can check it in https://db.sp-tarkov.com/search
newId: "CustomMP18", //The new id of our cloned item newId: "CustomMP18", //The new id of our cloned item
@ -59,21 +59,23 @@ class Mod implements IPostDBLoadMod, IPostAkiLoadMod
handbookParentId: "5b5f78e986f77447ed5636b1", //Handbook Parent Id refers to the category the gun will be under handbookParentId: "5b5f78e986f77447ed5636b1", //Handbook Parent Id refers to the category the gun will be under
//you see those side box tab thing that only select gun under specific icon? Handbook parent can be found in Aki_Data\Server\database\templates. //you see those side box tab thing that only select gun under specific icon? Handbook parent can be found in Aki_Data\Server\database\templates.
locales: { locales: {
"en": { en: {
name: "MP-18 12g", name: "MP-18 12g",
shortName: "Custom MP18", shortName: "Custom MP18",
description: "A custom MP18 chambered in 12G" description: "A custom MP18 chambered in 12G",
} },
} },
} };
CustomItem.createItemFromClone(ExampleCloneItem); //Basically calls the function and tell the server to add our Cloned new item into the server CustomItem.createItemFromClone(ExampleCloneItem); //Basically calls the function and tell the server to add our Cloned new item into the server
} }
//Check if our item is in the server or not //Check if our item is in the server or not
public postAkiLoad(container: DependencyContainer): void { public postAkiLoad(container: DependencyContainer): void {
const db = container.resolve<DatabaseServer>("DatabaseServer"); const db = container.resolve<DatabaseServer>("DatabaseServer");
const item = db.getTables().templates.items; const item = db.getTables().templates.items;
console.log(item["CustomMP18"]._props) console.log(item["CustomMP18"]._props);
} }
} }

View File

@ -1,21 +1,21 @@
import { DependencyContainer } from 'tsyringe'; import path from "node:path";
import { DependencyContainer } from "tsyringe";
import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod"; import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { VFS } from "@spt-aki/utils/VFS"; import { VFS } from "@spt-aki/utils/VFS";
import { jsonc } from 'jsonc'; import { jsonc } from "jsonc";
// Our dynamically imported package (via pnpm) not bundled into the server // Our dynamically imported package (via pnpm) not bundled into the server
import ora from "ora-classic"; import ora from "ora-classic";
import path from "path";
class Mod implements IPreAkiLoadMod, IPostAkiLoadMod { class Mod implements IPreAkiLoadMod, IPostAkiLoadMod {
public preAkiLoad(container: DependencyContainer): void { public preAkiLoad(container: DependencyContainer): void {
const VFS = container.resolve<VFS>("VFS"); const vfs = container.resolve<VFS>("VFS");
const logger = container.resolve<ILogger>("WinstonLogger"); const logger = container.resolve<ILogger>("WinstonLogger");
const parsedJsonC = jsonc.parse(VFS.readFile(path.resolve(__dirname, "../test.jsonc"))); const parsedJsonC = jsonc.parse(vfs.readFile(path.resolve(__dirname, "../test.jsonc")));
logger.success(jsonc.stringify(parsedJsonC, null, "\t")); // you could use the built in JSON api here if you really wanted too aswell, i used jsonc to really drive home the point that it works logger.success(jsonc.stringify(parsedJsonC, null, "\t")); // you could use the built in JSON api here if you really wanted too aswell, i used jsonc to really drive home the point that it works
} }

View File

@ -1,4 +1,5 @@
import { DependencyContainer } from "tsyringe"; import { DependencyContainer } from "tsyringe";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { LogTextColor } from "@spt-aki/models/spt/logging/LogTextColor"; import { LogTextColor } from "@spt-aki/models/spt/logging/LogTextColor";
@ -7,7 +8,7 @@ import { LogBackgroundColor } from "@spt-aki/models/spt/logging/LogBackgroundCol
class Mod implements IPreAkiLoadMod class Mod implements IPreAkiLoadMod
{ {
// Code added here will load BEFORE the server has started loading // Code added here will load BEFORE the server has started loading
preAkiLoad(container: DependencyContainer): void public preAkiLoad(container: DependencyContainer): void
{ {
// get the logger from the server container // get the logger from the server container
const logger = container.resolve<ILogger>("WinstonLogger"); const logger = container.resolve<ILogger>("WinstonLogger");

View File

@ -1,25 +1,26 @@
import { inject, injectable } from "tsyringe";
import { IDialogueChatBot } from "@spt-aki/helpers/Dialogue/IDialogueChatBot"; import { IDialogueChatBot } from "@spt-aki/helpers/Dialogue/IDialogueChatBot";
import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest";
import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile";
import { MemberCategory } from "@spt-aki/models/enums/MemberCategory"; import { MemberCategory } from "@spt-aki/models/enums/MemberCategory";
import { MailSendService } from "@spt-aki/services/MailSendService"; import { MailSendService } from "@spt-aki/services/MailSendService";
import { inject, injectable } from "tsyringe";
// \/ dont forger this annotation here! // \/ dont forger this annotation here!
@injectable() @injectable()
export class CustomChatBot implements IDialogueChatBot export class CustomChatBot implements IDialogueChatBot
{ {
public constructor( constructor(
@inject("MailSendService") protected mailSendService: MailSendService, @inject("MailSendService") protected mailSendService: MailSendService,
) )
{ {}
}
public getChatBot(): IUserDialogInfo public getChatBot(): IUserDialogInfo
{ {
return { return {
_id: "modderBuddy", _id: "modderBuddy",
info: { aid: 9999999,
Info: {
Level: 1, Level: 1,
MemberCategory: MemberCategory.SHERPA, MemberCategory: MemberCategory.SHERPA,
Nickname: "Buddy", Nickname: "Buddy",
@ -37,5 +38,4 @@ export class CustomChatBot implements IDialogueChatBot
); );
return request.dialogId; return request.dialogId;
} }
} }

View File

@ -1,8 +1,8 @@
import { DependencyContainer } from 'tsyringe'; import { DependencyContainer } from "tsyringe";
import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod"; import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";
import { DialogueController } from "@spt-aki/controllers/DialogueController"; import { DialogueController } from "@spt-aki/controllers/DialogueController";
import { CustomChatBot } from './CustomChatBot'; import { CustomChatBot } from "./CustomChatBot";
class Mod implements IPostDBLoadMod { class Mod implements IPostDBLoadMod {
public postDBLoad(container: DependencyContainer): void { public postDBLoad(container: DependencyContainer): void {

View File

@ -1,15 +1,16 @@
import { inject, injectable } from "tsyringe";
import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand"; import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand";
import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest";
import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { MailSendService } from "@spt-aki/services/MailSendService"; import { MailSendService } from "@spt-aki/services/MailSendService";
import { inject, injectable } from "tsyringe";
// \/ dont forger this annotation here! // \/ dont forger this annotation here!
@injectable() @injectable()
export class CustomCommandoCommand implements IChatCommand export class CustomCommandoCommand implements IChatCommand
{ {
public constructor( constructor(
@inject("MailSendService") protected mailSendService: MailSendService, @inject("MailSendService") protected mailSendService: MailSendService,
@inject("DatabaseServer") protected databaseServer: DatabaseServer, @inject("DatabaseServer") protected databaseServer: DatabaseServer,
) )

View File

@ -1,8 +1,8 @@
import { DependencyContainer } from 'tsyringe'; import { DependencyContainer } from "tsyringe";
import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod"; import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";
import { CommandoDialogueChatBot } from "@spt-aki/helpers/Dialogue/CommandoDialogueChatBot"; import { CommandoDialogueChatBot } from "@spt-aki/helpers/Dialogue/CommandoDialogueChatBot";
import { CustomCommandoCommand } from './CustomCommandoCommand'; import { CustomCommandoCommand } from "./CustomCommandoCommand";
class Mod implements IPostDBLoadMod { class Mod implements IPostDBLoadMod {
public postDBLoad(container: DependencyContainer): void { public postDBLoad(container: DependencyContainer): void {

View File

@ -1,20 +1,20 @@
import { inject, injectable } from "tsyringe";
import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand"; import { ISptCommand } from "@spt-aki/helpers/Dialogue/Commando/SptCommands/ISptCommand";
import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
import { MailSendService } from "@spt-aki/services/MailSendService"; import { MailSendService } from "@spt-aki/services/MailSendService";
import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest";
import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile";
import { inject, injectable } from "tsyringe";
// \/ dont forger this annotation here! // \/ dont forger this annotation here!
@injectable() @injectable()
export class CustomAkiCommand implements ISptCommand export class CustomAkiCommand implements ISptCommand
{ {
public constructor( constructor(
@inject("ItemHelper") protected itemHelper: ItemHelper, @inject("ItemHelper") protected itemHelper: ItemHelper,
@inject("MailSendService") protected mailSendService: MailSendService, @inject("MailSendService") protected mailSendService: MailSendService,
) )
{ {}
}
public getCommand(): string public getCommand(): string
{ {
@ -23,7 +23,7 @@ export class CustomAkiCommand implements ISptCommand
public getCommandHelp(): string public getCommandHelp(): string
{ {
return "Usage: spt getName tplId" return "Usage: spt getName tplId";
} }
public performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string public performAction(commandHandler: IUserDialogInfo, sessionId: string, request: ISendMessageRequest): string

View File

@ -1,16 +1,15 @@
import { DependencyContainer } from 'tsyringe'; import { DependencyContainer } from "tsyringe";
import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod"; import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";
import { SptCommandoCommands } from "@spt-aki/helpers/Dialogue/Commando/SptCommandoCommands"; import { SptCommandoCommands } from "@spt-aki/helpers/Dialogue/Commando/SptCommandoCommands";
import { CustomAkiCommand } from './CustomAkiCommand'; import { CustomAkiCommand } from "./CustomAkiCommand";
class Mod implements IPostDBLoadMod { class Mod implements IPostDBLoadMod {
public postDBLoad(container: DependencyContainer): void { public postDBLoad(container: DependencyContainer): void {
// We register and re-resolve the dependency so the container takes care of filling in the command dependencies // We register and re-resolve the dependency so the container takes care of filling in the command dependencies
container.register<CustomAkiCommand>("CustomAkiCommand", CustomAkiCommand); container.register<CustomAkiCommand>("CustomAkiCommand", CustomAkiCommand);
container.resolve<SptCommandoCommands>("SptCommandoCommands").registerSptCommandoCommand(container.resolve<CustomAkiCommand>("CustomAkiCommand")) container.resolve<SptCommandoCommands>("SptCommandoCommands").registerSptCommandoCommand(container.resolve<CustomAkiCommand>("CustomAkiCommand"));
} }
} }
export const mod = new Mod(); export const mod = new Mod();

View File

@ -1,15 +1,16 @@
import { inject, injectable } from "tsyringe";
import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand"; import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand";
import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest";
import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile";
import { MailSendService } from "@spt-aki/services/MailSendService"; import { MailSendService } from "@spt-aki/services/MailSendService";
import { inject, injectable } from "tsyringe";
// \/ dont forger this annotation here! // \/ dont forger this annotation here!
@injectable() @injectable()
export class AnotherCoolCommand implements IChatCommand export class AnotherCoolCommand implements IChatCommand
{ {
constructor( constructor(
@inject("MailSendService") protected mailSendService: MailSendService @inject("MailSendService") protected mailSendService: MailSendService,
) )
{} {}
@ -39,5 +40,4 @@ export class AnotherCoolCommand implements IChatCommand
return request.dialogId; return request.dialogId;
} }
} }
} }

View File

@ -1,16 +1,17 @@
import { inject, injectAll, injectable } from "tsyringe";
import { AbstractDialogueChatBot } from "@spt-aki/helpers/Dialogue/AbstractDialogueChatBot"; import { AbstractDialogueChatBot } from "@spt-aki/helpers/Dialogue/AbstractDialogueChatBot";
import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand"; import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand";
import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile";
import { MemberCategory } from "@spt-aki/models/enums/MemberCategory"; import { MemberCategory } from "@spt-aki/models/enums/MemberCategory";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { MailSendService } from "@spt-aki/services/MailSendService"; import { MailSendService } from "@spt-aki/services/MailSendService";
import { inject, injectAll, injectable } from "tsyringe";
// \/ dont forger this annotation here! // \/ dont forger this annotation here!
@injectable() @injectable()
export class CustomSimpleChatBot extends AbstractDialogueChatBot export class CustomSimpleChatBot extends AbstractDialogueChatBot
{ {
public constructor( constructor(
@inject("WinstonLogger") logger: ILogger, @inject("WinstonLogger") logger: ILogger,
@inject("MailSendService") mailSendService: MailSendService, @inject("MailSendService") mailSendService: MailSendService,
// Remember to replace MyCommand for something unique to your mod! // Remember to replace MyCommand for something unique to your mod!
@ -19,7 +20,7 @@ export class CustomSimpleChatBot extends AbstractDialogueChatBot
@injectAll("MyCommand") chatCommands: IChatCommand[], @injectAll("MyCommand") chatCommands: IChatCommand[],
) )
{ {
super(logger, mailSendService, chatCommands) super(logger, mailSendService, chatCommands);
} }
public getChatBot(): IUserDialogInfo public getChatBot(): IUserDialogInfo
@ -37,7 +38,6 @@ export class CustomSimpleChatBot extends AbstractDialogueChatBot
protected getUnrecognizedCommandMessage(): string protected getUnrecognizedCommandMessage(): string
{ {
return "No clue what you are talking about bud!" return "No clue what you are talking about bud!";
} }
} }

View File

@ -1,15 +1,16 @@
import { inject, injectable } from "tsyringe";
import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand"; import { IChatCommand } from "@spt-aki/helpers/Dialogue/Commando/IChatCommand";
import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest"; import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest";
import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile"; import { IUserDialogInfo } from "@spt-aki/models/eft/profile/IAkiProfile";
import { MailSendService } from "@spt-aki/services/MailSendService"; import { MailSendService } from "@spt-aki/services/MailSendService";
import { inject, injectable } from "tsyringe";
// \/ dont forger this annotation here! // \/ dont forger this annotation here!
@injectable() @injectable()
export class MyCoolCommand implements IChatCommand export class MyCoolCommand implements IChatCommand
{ {
constructor( constructor(
@inject("MailSendService") protected mailSendService: MailSendService @inject("MailSendService") protected mailSendService: MailSendService,
) )
{} {}
@ -39,5 +40,4 @@ export class MyCoolCommand implements IChatCommand
return request.dialogId; return request.dialogId;
} }
} }
} }

View File

@ -1,10 +1,10 @@
import { DependencyContainer } from 'tsyringe'; import { DependencyContainer } from "tsyringe";
import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod"; import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";
import { DialogueController } from "@spt-aki/controllers/DialogueController"; import { DialogueController } from "@spt-aki/controllers/DialogueController";
import { CustomSimpleChatBot } from './CustomSimpleChatBot'; import { CustomSimpleChatBot } from "./CustomSimpleChatBot";
import { MyCoolCommand } from './MyCoolCommand'; import { MyCoolCommand } from "./MyCoolCommand";
import { AnotherCoolCommand } from './AnotherCoolCommand'; import { AnotherCoolCommand } from "./AnotherCoolCommand";
class Mod implements IPostDBLoadMod { class Mod implements IPostDBLoadMod {
public postDBLoad(container: DependencyContainer): void { public postDBLoad(container: DependencyContainer): void {

View File

@ -1,17 +1,20 @@
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { IAkiWebSocketMessageHandler } from "@spt-aki/servers/ws/message/IAkiWebSocketMessageHandler";
import { WebSocket, RawData } from "ws"; import { WebSocket, RawData } from "ws";
import { IAkiWebSocketMessageHandler } from "@spt-aki/servers/ws/message/IAkiWebSocketMessageHandler";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
// \/ dont forger this annotation here! // \/ dont forger this annotation here!
@injectable() @injectable()
export class CustomAkiWebSocketMessageHandler implements IAkiWebSocketMessageHandler export class CustomAkiWebSocketMessageHandler implements IAkiWebSocketMessageHandler
{ {
constructor(@inject("WinstonLogger") protected logger: ILogger) constructor(
@inject("WinstonLogger") protected logger: ILogger,
)
{} {}
public onAkiMessage(sessionID: string, client: WebSocket, message: RawData): void public onAkiMessage(sessionID: string, client: WebSocket, message: RawData): void
{ {
this.logger.info(`Custom AKI WebSocket Message handler received a message for ${sessionID}: ${message.toString()}`) this.logger.info(`Custom AKI WebSocket Message handler received a message for ${sessionID}: ${message.toString()}`);
} }
} }

View File

@ -1,16 +1,18 @@
import { IncomingMessage } from "node:http";
import { inject, injectable } from "tsyringe";
import { WebSocket } from "ws";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { IWebSocketConnectionHandler } from "@spt-aki/servers/ws/IWebSocketConnectionHandler"; import { IWebSocketConnectionHandler } from "@spt-aki/servers/ws/IWebSocketConnectionHandler";
import { IncomingMessage } from "http";
import { inject, injectable } from "tsyringe";
import { WebSocket, RawData } from "ws";
// \/ dont forger this annotation here! // \/ dont forger this annotation here!
@injectable() @injectable()
export class CustomWebSocketConnectionHandler implements IWebSocketConnectionHandler export class CustomWebSocketConnectionHandler implements IWebSocketConnectionHandler
{ {
constructor(@inject("WinstonLogger") protected logger: ILogger) constructor(
{ @inject("WinstonLogger") protected logger: ILogger,
} )
{}
public getSocketId(): string public getSocketId(): string
{ {
@ -29,7 +31,7 @@ export class CustomWebSocketConnectionHandler implements IWebSocketConnectionHan
{ {
if (msg.toString() === "toodaloo") if (msg.toString() === "toodaloo")
{ {
ws.send("toodaloo back!") ws.send("toodaloo back!");
} }
}); });
} }

View File

@ -1,11 +1,10 @@
import { DependencyContainer } from 'tsyringe'; import { DependencyContainer } from "tsyringe";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { CustomWebSocketConnectionHandler } from './CustomWebSocketConnectionHandler'; import { CustomWebSocketConnectionHandler } from "./CustomWebSocketConnectionHandler";
import { IWebSocketConnectionHandler } from '@spt-aki/servers/ws/IWebSocketConnectionHandler'; import { IWebSocketConnectionHandler } from "@spt-aki/servers/ws/IWebSocketConnectionHandler";
import { CustomAkiWebSocketMessageHandler } from './CustomAkiWebSocketMessageHandler'; import { CustomAkiWebSocketMessageHandler } from "./CustomAkiWebSocketMessageHandler";
import { IAkiWebSocketMessageHandler } from '@spt-aki/servers/ws/message/IAkiWebSocketMessageHandler'; import { IAkiWebSocketMessageHandler } from "@spt-aki/servers/ws/message/IAkiWebSocketMessageHandler";
class Mod implements IPreAkiLoadMod { class Mod implements IPreAkiLoadMod {
public preAkiLoad(container: DependencyContainer): void { public preAkiLoad(container: DependencyContainer): void {

View File

@ -13,7 +13,6 @@ class Mod implements IPostDBLoadMod
// get database from server // get database from server
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer"); const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
// Get all the in-memory json found in /assets/database // Get all the in-memory json found in /assets/database
const tables: IDatabaseTables = databaseServer.getTables(); const tables: IDatabaseTables = databaseServer.getTables();
@ -62,4 +61,4 @@ class Mod implements IPostDBLoadMod
} }
} }
module.exports = { mod: new Mod() } export const mod = new Mod();

View File

@ -1,6 +1,6 @@
import { DependencyContainer } from "tsyringe"; import { DependencyContainer } from "tsyringe";
import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod";
import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { ConfigServer } from "@spt-aki/servers/ConfigServer"; import { ConfigServer } from "@spt-aki/servers/ConfigServer";
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes"; import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
@ -21,13 +21,13 @@ class Mod implements IPostAkiLoadMod
const locationConfig: ILocationConfig = configServer.getConfig<ILocationConfig>(ConfigTypes.LOCATION); const locationConfig: ILocationConfig = configServer.getConfig<ILocationConfig>(ConfigTypes.LOCATION);
// Log the original customs loose loot multipler // Log the original customs loose loot multipler
logger.info(`Here is the original customs map loose loot multipler: ${locationConfig.looseLootMultiplier.bigmap}`) logger.info(`Here is the original customs map loose loot multipler: ${locationConfig.looseLootMultiplier.bigmap}`);
// Adjust the multipler (customs is called bigmap in bsg land) // Adjust the multipler (customs is called bigmap in bsg land)
locationConfig.looseLootMultiplier.bigmap = 10; locationConfig.looseLootMultiplier.bigmap = 10;
// Log the new multipler // Log the new multipler
logger.info(`Here is the altered customs map loose loot multipler: ${locationConfig.looseLootMultiplier.bigmap}`) logger.info(`Here is the altered customs map loose loot multipler: ${locationConfig.looseLootMultiplier.bigmap}`);
} }
} }

View File

@ -1,3 +1,3 @@
{ {
"myProperty": "i love json5" myProperty: "i love json5"
} }

View File

@ -1,3 +1,4 @@
import path from "node:path";
import { DependencyContainer } from "tsyringe"; import { DependencyContainer } from "tsyringe";
import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod"; import { IPostAkiLoadMod } from "@spt-aki/models/external/IPostAkiLoadMod";
@ -7,8 +8,6 @@ import { VFS } from "@spt-aki/utils/VFS";
import JSON5 from "json5"; import JSON5 from "json5";
import { jsonc } from "jsonc"; import { jsonc } from "jsonc";
import path from "path";
class Mod implements IPostAkiLoadMod class Mod implements IPostAkiLoadMod
{ {
public postAkiLoad(container: DependencyContainer): void { public postAkiLoad(container: DependencyContainer): void {

View File

@ -1,4 +1,5 @@
import { DependencyContainer } from "tsyringe"; import { DependencyContainer } from "tsyringe";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { LauncherController } from "@spt-aki/controllers/LauncherController"; import { LauncherController } from "@spt-aki/controllers/LauncherController";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";

View File

@ -1,7 +1,8 @@
import { DependencyContainer } from "tsyringe"; import { DependencyContainer } from "tsyringe";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"
import { ILogger } from "@spt-aki/models/spt/utils/ILogger" import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { OnLoadModService } from "@spt-aki/services/mod/onLoad/OnLoadModService" import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { OnLoadModService } from "@spt-aki/services/mod/onLoad/OnLoadModService";
class Mod implements IPreAkiLoadMod class Mod implements IPreAkiLoadMod
{ {
@ -13,12 +14,12 @@ class Mod implements IPreAkiLoadMod
"MyCustomMod", // route key "MyCustomMod", // route key
() => this.customFunctionThatRunsOnLoad(logger), () => this.customFunctionThatRunsOnLoad(logger),
() => "custom-mod" // new route name () => "custom-mod" // new route name
) );
} }
public customFunctionThatRunsOnLoad(logger: ILogger): void public customFunctionThatRunsOnLoad(logger: ILogger): void
{ {
logger.info("MyCustomMod custom function is loading right now") logger.info("MyCustomMod custom function is loading right now");
} }
} }

View File

@ -1,7 +1,8 @@
import { DependencyContainer } from "tsyringe"; import { DependencyContainer } from "tsyringe";
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"
import { ILogger } from "@spt-aki/models/spt/utils/ILogger" import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import { OnUpdateModService } from "@spt-aki/services/mod/onUpdate/OnUpdateModService" import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { OnUpdateModService } from "@spt-aki/services/mod/onUpdate/OnUpdateModService";
class Mod implements IPreAkiLoadMod class Mod implements IPreAkiLoadMod
{ {
@ -13,14 +14,14 @@ class Mod implements IPreAkiLoadMod
"MyCustomOnUpdateMod", "MyCustomOnUpdateMod",
(timeSinceLastRun: number) => this.customFunctionThatRunsOnLoad(timeSinceLastRun, logger), (timeSinceLastRun: number) => this.customFunctionThatRunsOnLoad(timeSinceLastRun, logger),
() => "custom-onupdate-mod" // new route name () => "custom-onupdate-mod" // new route name
) );
} }
public customFunctionThatRunsOnLoad(timeSinceLastRun: number, logger: ILogger): boolean public customFunctionThatRunsOnLoad(timeSinceLastRun: number, logger: ILogger): boolean
{ {
if (timeSinceLastRun > 30) if (timeSinceLastRun > 30)
{ {
logger.info("MyCustomMod onupdate custom function is called right now") logger.info("MyCustomMod onupdate custom function is called right now");
return true; // we did something return true; // we did something
} }

View File

@ -1,4 +1,5 @@
import { DependencyContainer } from "tsyringe"; import { DependencyContainer } from "tsyringe";
import type { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; import type { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
import type { ILogger } from "@spt-aki/models/spt/utils/ILogger"; import type { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import type {DynamicRouterModService} from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService"; import type {DynamicRouterModService} from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService";
@ -19,7 +20,7 @@ class Mod implements IPreAkiLoadMod
url: "/my-dynamic-mod/", url: "/my-dynamic-mod/",
action: (url, info, sessionId, output) => action: (url, info, sessionId, output) =>
{ {
logger.info("Custom dynamic route hit") logger.info("Custom dynamic route hit");
return JSON.stringify({response: "OK"}); return JSON.stringify({response: "OK"});
} }
} }
@ -35,7 +36,7 @@ class Mod implements IPreAkiLoadMod
url: "/my-static-route-mod/", url: "/my-static-route-mod/",
action: (url, info, sessionId, output) => action: (url, info, sessionId, output) =>
{ {
logger.info("Custom static route hit") logger.info("Custom static route hit");
return JSON.stringify({response: "OK"}); return JSON.stringify({response: "OK"});
} }
} }
@ -51,7 +52,7 @@ class Mod implements IPreAkiLoadMod
url: "/client/menu/locale/", url: "/client/menu/locale/",
action: (url, info, sessionId, output) => action: (url, info, sessionId, output) =>
{ {
logger.info("/client/menu/locale/ data was: " + JSON.stringify(output)) logger.info("/client/menu/locale/ data was: " + JSON.stringify(output));
return output; return output;
} }
} }
@ -67,14 +68,13 @@ class Mod implements IPreAkiLoadMod
url: "/launcher/ping", url: "/launcher/ping",
action: (url, info, sessionId, output) => action: (url, info, sessionId, output) =>
{ {
logger.info("/launcher/ping data was: " + JSON.stringify(output)) logger.info("/launcher/ping data was: " + JSON.stringify(output));
return output; return output;
} }
} }
], ],
"aki" "aki"
); );
} }
} }