diff --git a/Live/CWX_DebugTool/dist/src/logging.ts b/Live/CWX_DebugTool/dist/src/logging.ts index bd2f5ae..441fae2 100644 --- a/Live/CWX_DebugTool/dist/src/logging.ts +++ b/Live/CWX_DebugTool/dist/src/logging.ts @@ -37,6 +37,7 @@ export class CWX_Logging // items this.changeShrapProps(); this.changeMaxAmmoForKS23(); + this.removeDevFromBlacklist(); } @@ -104,7 +105,7 @@ export class CWX_Logging } } - private changeShrapProps():void + private changeShrapProps(): void { if (this.config.itemsConfig.changeShrapProps) { @@ -112,11 +113,20 @@ export class CWX_Logging } } - private changeMaxAmmoForKS23():void + private changeMaxAmmoForKS23(): void { if (this.config.itemsConfig.changeMaxAmmoForKS23) { this.logger.info("Change Max Ammo For KS23 Activated"); } } + + private removeDevFromBlacklist(): void + { + if (this.config.itemsConfig.removeDevFromBlacklist) + { + this.logger.info("Remove Dev From Blacklist Activated"); + } + } + } \ No newline at end of file diff --git a/Live/CWX_DebugTool/src/logging.ts b/Live/CWX_DebugTool/src/logging.ts index bd2f5ae..441fae2 100644 --- a/Live/CWX_DebugTool/src/logging.ts +++ b/Live/CWX_DebugTool/src/logging.ts @@ -37,6 +37,7 @@ export class CWX_Logging // items this.changeShrapProps(); this.changeMaxAmmoForKS23(); + this.removeDevFromBlacklist(); } @@ -104,7 +105,7 @@ export class CWX_Logging } } - private changeShrapProps():void + private changeShrapProps(): void { if (this.config.itemsConfig.changeShrapProps) { @@ -112,11 +113,20 @@ export class CWX_Logging } } - private changeMaxAmmoForKS23():void + private changeMaxAmmoForKS23(): void { if (this.config.itemsConfig.changeMaxAmmoForKS23) { this.logger.info("Change Max Ammo For KS23 Activated"); } } + + private removeDevFromBlacklist(): void + { + if (this.config.itemsConfig.removeDevFromBlacklist) + { + this.logger.info("Remove Dev From Blacklist Activated"); + } + } + } \ No newline at end of file diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/bepInEx/plugins/CWX-MasterKey.dll b/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/bepInEx/plugins/CWX-MasterKey.dll deleted file mode 100644 index f57a5ec..0000000 Binary files a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/bepInEx/plugins/CWX-MasterKey.dll and /dev/null differ diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/src/mod.ts b/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/src/mod.ts deleted file mode 100644 index 04faadb..0000000 --- a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/src/mod.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { DependencyContainer } from "tsyringe"; -import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; - -class CWX_MasterKey implements IPreAkiLoadMod -{ - public preAkiLoad(container: DependencyContainer): void - { - } -} - -module.exports = { mod: new CWX_MasterKey() } \ No newline at end of file diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/bepInEx/plugins/CWX-MasterKey.dll b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/bepInEx/plugins/CWX-MasterKey.dll new file mode 100644 index 0000000..052c745 Binary files /dev/null and b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/bepInEx/plugins/CWX-MasterKey.dll differ diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/LICENSE.txt b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/LICENSE.txt similarity index 100% rename from Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/LICENSE.txt rename to Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/LICENSE.txt diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/package.json b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/package.json similarity index 97% rename from Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/package.json rename to Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/package.json index 5ec29d5..4ef5e2a 100644 --- a/Live/CWX_MasterKey/CWX_MasterKey 1.3.5/user/mods/CWX-MasterKey 1.3.5/package.json +++ b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/package.json @@ -1,7 +1,7 @@ { "name": "MasterKey", "author": "CWX", - "version": "1.3.5", + "version": "1.3.6", "license": "NCSA", "main": "src/mod.js", "akiVersion": "3.2.3", diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/config.json b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/config.json new file mode 100644 index 0000000..a17c1d5 --- /dev/null +++ b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/config.json @@ -0,0 +1,3 @@ +{ + "keyId": "5c1d0d6d86f7744bb2683e1f" +} \ No newline at end of file diff --git a/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/mod.ts b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/mod.ts new file mode 100644 index 0000000..c7452ef --- /dev/null +++ b/Live/CWX_MasterKey/CWX_MasterKey 1.3.6/user/mods/CWX-MasterKey 1.3.6/src/mod.ts @@ -0,0 +1,50 @@ +import { DependencyContainer } from "tsyringe"; +import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; +import { DynamicRouterModService } from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService"; +import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; + +class CWX_MasterKey implements IPreAkiLoadMod +{ + + private router: DynamicRouterModService; + private cfg; + private http: HttpResponseUtil; + + public preAkiLoad(container: DependencyContainer): void + { + this.router = container.resolve("DynamicRouterModService"); + this.http = container.resolve("HttpResponseUtil"); + this.cfg = require("./config.json"); + + this.addRoute(); + } + + private addRoute() : void + { + this.router.registerDynamicRouter( + "MasterKey", + [ + { + url: "/cwx/masterkey", + action: (url, info, sessionId, output) => + { + return this.onRequestConfig(); + } + } + ], + "MasterKey" + ) + } + + private onRequestConfig(): any + { + if (typeof this.cfg.keyId !== "string") + { + return this.http.noBody({ keyId: "5c1d0d6d86f7744bb2683e1f" }); + } + + return this.http.noBody({ keyId: this.cfg.keyId}); + } +} + +module.exports = { mod: new CWX_MasterKey() } \ No newline at end of file diff --git a/Live/CWX_MasterKey/ConfigClass.cs b/Live/CWX_MasterKey/ConfigClass.cs new file mode 100644 index 0000000..f98e0db --- /dev/null +++ b/Live/CWX_MasterKey/ConfigClass.cs @@ -0,0 +1,7 @@ +namespace CWX_MasterKey +{ + public class ConfigClass + { + public string keyId { get; set; } + } +} diff --git a/Live/CWX_MasterKey/MasterKey.cs b/Live/CWX_MasterKey/MasterKey.cs index dd3e6b2..cf5b727 100644 --- a/Live/CWX_MasterKey/MasterKey.cs +++ b/Live/CWX_MasterKey/MasterKey.cs @@ -2,49 +2,95 @@ using EFT.Interactive; using System.Linq; using UnityEngine; +using System.Net; +using System.Threading; +using System.Collections.Generic; +using Aki.Common.Http; +using Aki.Common.Utils; namespace CWX_MasterKey { public static class MasterKey { + static object lockObject = new object(); + + // Black, Blue, Green, Red, Yellow, Violet + static string[] keys = new string[] { "5c1d0f4986f7744bb01837fa", "5c1d0c5f86f7744bb2683cf0", "5c1d0dc586f7744baf2e7b79", "5c1d0efb86f7744baf2e7b7b", "5c1d0d6d86f7744bb2683e1f", "5c1e495a86f7743109743dfb" }; + public static void Start() { - var allDoors = GameObject.FindObjectsOfType().ToList(); // mechanical doors - var allKeyCardDoors = GameObject.FindObjectsOfType().ToList(); // keycard doors - var allKeyContainers = GameObject.FindObjectsOfType().ToList(); // locked loot containers - var allTrunks = GameObject.FindObjectsOfType().ToList(); // locked car trunks + ConfigClass config = new ConfigClass(); + bool lockWasTaken = false; - foreach (var door in allDoors) // mechanical doors + string keyToUse = "5c1d0d6d86f7744bb2683e1f"; + + try + { + Monitor.Enter(lockObject, ref lockWasTaken); + + config = GetConfig(); + } + catch (WebException) + { + Debug.LogError("[CWX_Masterkey] Issue happened whilst getting config from server"); + } + finally + { + if (lockWasTaken) + { + Monitor.Exit(lockObject); + } + } + + if (keys.Any(x => x == config.keyId)) + { + keyToUse = config.keyId; + } + + List allDoors = GameObject.FindObjectsOfType().ToList(); // mechanical doors + List allKeyCardDoors = GameObject.FindObjectsOfType().ToList(); // keycard doors + List allKeyContainers = GameObject.FindObjectsOfType().ToList(); // locked loot containers + List allTrunks = GameObject.FindObjectsOfType().ToList(); // locked car trunks + + foreach (Door door in allDoors) // mechanical doors { if (!door.KeyId.IsNullOrWhiteSpace() || !door.KeyId.IsNullOrEmpty()) { - door.KeyId = "5c1d0d6d86f7744bb2683e1f"; + door.KeyId = keyToUse; } } - foreach (var door in allKeyCardDoors) // keycard doors + foreach (KeycardDoor door in allKeyCardDoors) // keycard doors { if (!door.KeyId.IsNullOrWhiteSpace() || !door.KeyId.IsNullOrEmpty()) { - door.KeyId = "5c1d0d6d86f7744bb2683e1f"; + door.KeyId = keyToUse; } } - foreach (var door in allKeyContainers) // locked loot containers + foreach (LootableContainer door in allKeyContainers) // locked loot containers { if (!door.KeyId.IsNullOrWhiteSpace() || !door.KeyId.IsNullOrEmpty()) { - door.KeyId = "5c1d0d6d86f7744bb2683e1f"; + door.KeyId = keyToUse; } } - foreach (var door in allTrunks) // locked car trunks + foreach (Trunk door in allTrunks) // locked car trunks { if (!door.KeyId.IsNullOrWhiteSpace() || !door.KeyId.IsNullOrEmpty()) { - door.KeyId = "5c1d0d6d86f7744bb2683e1f"; + door.KeyId = keyToUse; } } } + + public static ConfigClass GetConfig() + { + var json = RequestHandler.GetJson($"/cwx/masterkey"); + var jsonClass = Json.Deserialize(json); + + return jsonClass; + } } } \ No newline at end of file diff --git a/Live/CWX_MasterKey/server/dist/package.json b/Live/CWX_MasterKey/server/dist/package.json index 5ec29d5..4ef5e2a 100644 --- a/Live/CWX_MasterKey/server/dist/package.json +++ b/Live/CWX_MasterKey/server/dist/package.json @@ -1,7 +1,7 @@ { "name": "MasterKey", "author": "CWX", - "version": "1.3.5", + "version": "1.3.6", "license": "NCSA", "main": "src/mod.js", "akiVersion": "3.2.3", diff --git a/Live/CWX_MasterKey/server/dist/src/config.json b/Live/CWX_MasterKey/server/dist/src/config.json new file mode 100644 index 0000000..a17c1d5 --- /dev/null +++ b/Live/CWX_MasterKey/server/dist/src/config.json @@ -0,0 +1,3 @@ +{ + "keyId": "5c1d0d6d86f7744bb2683e1f" +} \ No newline at end of file diff --git a/Live/CWX_MasterKey/server/dist/src/mod.ts b/Live/CWX_MasterKey/server/dist/src/mod.ts index 04faadb..c7452ef 100644 --- a/Live/CWX_MasterKey/server/dist/src/mod.ts +++ b/Live/CWX_MasterKey/server/dist/src/mod.ts @@ -1,10 +1,49 @@ import { DependencyContainer } from "tsyringe"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; +import { DynamicRouterModService } from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService"; +import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; class CWX_MasterKey implements IPreAkiLoadMod { + + private router: DynamicRouterModService; + private cfg; + private http: HttpResponseUtil; + public preAkiLoad(container: DependencyContainer): void - { + { + this.router = container.resolve("DynamicRouterModService"); + this.http = container.resolve("HttpResponseUtil"); + this.cfg = require("./config.json"); + + this.addRoute(); + } + + private addRoute() : void + { + this.router.registerDynamicRouter( + "MasterKey", + [ + { + url: "/cwx/masterkey", + action: (url, info, sessionId, output) => + { + return this.onRequestConfig(); + } + } + ], + "MasterKey" + ) + } + + private onRequestConfig(): any + { + if (typeof this.cfg.keyId !== "string") + { + return this.http.noBody({ keyId: "5c1d0d6d86f7744bb2683e1f" }); + } + + return this.http.noBody({ keyId: this.cfg.keyId}); } } diff --git a/Live/CWX_MasterKey/server/package.json b/Live/CWX_MasterKey/server/package.json index 5ec29d5..4ef5e2a 100644 --- a/Live/CWX_MasterKey/server/package.json +++ b/Live/CWX_MasterKey/server/package.json @@ -1,7 +1,7 @@ { "name": "MasterKey", "author": "CWX", - "version": "1.3.5", + "version": "1.3.6", "license": "NCSA", "main": "src/mod.js", "akiVersion": "3.2.3", diff --git a/Live/CWX_MasterKey/server/src/config.json b/Live/CWX_MasterKey/server/src/config.json new file mode 100644 index 0000000..a17c1d5 --- /dev/null +++ b/Live/CWX_MasterKey/server/src/config.json @@ -0,0 +1,3 @@ +{ + "keyId": "5c1d0d6d86f7744bb2683e1f" +} \ No newline at end of file diff --git a/Live/CWX_MasterKey/server/src/mod.ts b/Live/CWX_MasterKey/server/src/mod.ts index 04faadb..c7452ef 100644 --- a/Live/CWX_MasterKey/server/src/mod.ts +++ b/Live/CWX_MasterKey/server/src/mod.ts @@ -1,10 +1,49 @@ import { DependencyContainer } from "tsyringe"; import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod"; +import { DynamicRouterModService } from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService"; +import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil"; class CWX_MasterKey implements IPreAkiLoadMod { + + private router: DynamicRouterModService; + private cfg; + private http: HttpResponseUtil; + public preAkiLoad(container: DependencyContainer): void - { + { + this.router = container.resolve("DynamicRouterModService"); + this.http = container.resolve("HttpResponseUtil"); + this.cfg = require("./config.json"); + + this.addRoute(); + } + + private addRoute() : void + { + this.router.registerDynamicRouter( + "MasterKey", + [ + { + url: "/cwx/masterkey", + action: (url, info, sessionId, output) => + { + return this.onRequestConfig(); + } + } + ], + "MasterKey" + ) + } + + private onRequestConfig(): any + { + if (typeof this.cfg.keyId !== "string") + { + return this.http.noBody({ keyId: "5c1d0d6d86f7744bb2683e1f" }); + } + + return this.http.noBody({ keyId: this.cfg.keyId}); } }