From 212dfd0d6533c44aed28192922a0c367a6af8b1b Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 8 Feb 2025 11:56:14 +0000 Subject: [PATCH] Added package jsons to mods + updated related poco --- ExampleMods/Mods/1Logging/package.json | 13 ++++++++ ExampleMods/Mods/2EditDatabase/package.json | 13 ++++++++ ExampleMods/Mods/3EditSptConfig/package.json | 13 ++++++++ .../Mods/4ReadCustomJson5Config/package.json | 13 ++++++++ .../Mods/5ReadCustomJsonConfig/package.json | 13 ++++++++ ExampleMods/Mods/6ReplaceMethod/package.json | 13 ++++++++ .../Mods/7UseMultipleClasses/SecondClass.cs | 16 ++++++++++ .../7UseMultipleClasses/UseMultipleClasses.cs | 31 +++++++++++++++++++ .../Mods/7UseMultipleClasses/package.json | 13 ++++++++ .../Core/Models/Spt/Mod/PackageJsonData.cs | 12 ------- 10 files changed, 138 insertions(+), 12 deletions(-) create mode 100644 ExampleMods/Mods/1Logging/package.json create mode 100644 ExampleMods/Mods/2EditDatabase/package.json create mode 100644 ExampleMods/Mods/3EditSptConfig/package.json create mode 100644 ExampleMods/Mods/4ReadCustomJson5Config/package.json create mode 100644 ExampleMods/Mods/5ReadCustomJsonConfig/package.json create mode 100644 ExampleMods/Mods/6ReplaceMethod/package.json create mode 100644 ExampleMods/Mods/7UseMultipleClasses/SecondClass.cs create mode 100644 ExampleMods/Mods/7UseMultipleClasses/UseMultipleClasses.cs create mode 100644 ExampleMods/Mods/7UseMultipleClasses/package.json diff --git a/ExampleMods/Mods/1Logging/package.json b/ExampleMods/Mods/1Logging/package.json new file mode 100644 index 00000000..1c1b5ea5 --- /dev/null +++ b/ExampleMods/Mods/1Logging/package.json @@ -0,0 +1,13 @@ +{ + "Name": "1Logging", + "Version": "1.0.0", + "SptVersion": "~4.0", + "LoadBefore": [], + "LoadAfter": [], + "IncompatibileMods": [], + "Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods", + "IsBundleMod": false, + "Author": "SPT", + "Contributors": [], + "Licence": "MIT" +} diff --git a/ExampleMods/Mods/2EditDatabase/package.json b/ExampleMods/Mods/2EditDatabase/package.json new file mode 100644 index 00000000..af514afd --- /dev/null +++ b/ExampleMods/Mods/2EditDatabase/package.json @@ -0,0 +1,13 @@ +{ + "Name": "2EditDatabase", + "Version": "1.0.0", + "SptVersion": "~4.0", + "LoadBefore": [], + "LoadAfter": [], + "IncompatibileMods": [], + "Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods", + "IsBundleMod": false, + "Author": "SPT", + "Contributors": [], + "Licence": "MIT" +} diff --git a/ExampleMods/Mods/3EditSptConfig/package.json b/ExampleMods/Mods/3EditSptConfig/package.json new file mode 100644 index 00000000..b59d90bb --- /dev/null +++ b/ExampleMods/Mods/3EditSptConfig/package.json @@ -0,0 +1,13 @@ +{ + "Name": "3EditSptConfig", + "Version": "1.0.0", + "SptVersion": "~4.0", + "LoadBefore": [], + "LoadAfter": [], + "IncompatibileMods": [], + "Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods", + "IsBundleMod": false, + "Author": "SPT", + "Contributors": [], + "Licence": "MIT" +} diff --git a/ExampleMods/Mods/4ReadCustomJson5Config/package.json b/ExampleMods/Mods/4ReadCustomJson5Config/package.json new file mode 100644 index 00000000..59eafcd4 --- /dev/null +++ b/ExampleMods/Mods/4ReadCustomJson5Config/package.json @@ -0,0 +1,13 @@ +{ + "Name": "4ReadCustomJson5Config", + "Version": "1.0.0", + "SptVersion": "~4.0", + "LoadBefore": [], + "LoadAfter": [], + "IncompatibileMods": [], + "Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods", + "IsBundleMod": false, + "Author": "SPT", + "Contributors": [], + "Licence": "MIT" +} diff --git a/ExampleMods/Mods/5ReadCustomJsonConfig/package.json b/ExampleMods/Mods/5ReadCustomJsonConfig/package.json new file mode 100644 index 00000000..cb56b6b3 --- /dev/null +++ b/ExampleMods/Mods/5ReadCustomJsonConfig/package.json @@ -0,0 +1,13 @@ +{ + "Name": "5ReadCustomConfig", + "Version": "1.0.0", + "SptVersion": "~4.0", + "LoadBefore": [], + "LoadAfter": [], + "IncompatibileMods": [], + "Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods", + "IsBundleMod": false, + "Author": "SPT", + "Contributors": [], + "Licence": "MIT" +} diff --git a/ExampleMods/Mods/6ReplaceMethod/package.json b/ExampleMods/Mods/6ReplaceMethod/package.json new file mode 100644 index 00000000..54d950c2 --- /dev/null +++ b/ExampleMods/Mods/6ReplaceMethod/package.json @@ -0,0 +1,13 @@ +{ + "Name": "6ReplaceMethod", + "Version": "1.0.0", + "SptVersion": "~4.0", + "LoadBefore": [], + "LoadAfter": [], + "IncompatibileMods": [], + "Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods", + "IsBundleMod": false, + "Author": "SPT", + "Contributors": [], + "Licence": "MIT" +} diff --git a/ExampleMods/Mods/7UseMultipleClasses/SecondClass.cs b/ExampleMods/Mods/7UseMultipleClasses/SecondClass.cs new file mode 100644 index 00000000..9e3e183d --- /dev/null +++ b/ExampleMods/Mods/7UseMultipleClasses/SecondClass.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ExampleMods.Mods._7UseMultipleClasses +{ + public class SecondClass + { + public string GetText() + { + return "test text"; + } + } +} diff --git a/ExampleMods/Mods/7UseMultipleClasses/UseMultipleClasses.cs b/ExampleMods/Mods/7UseMultipleClasses/UseMultipleClasses.cs new file mode 100644 index 00000000..40419e34 --- /dev/null +++ b/ExampleMods/Mods/7UseMultipleClasses/UseMultipleClasses.cs @@ -0,0 +1,31 @@ +using Core.Models.External; +using Core.Models.Utils; + +namespace ExampleMods.Mods._7UseMultipleClasses +{ + /// + /// Having multiple classes can make keeping your code maintainable easier, you can split related code into their own class + /// + public class UseMultipleClasses: IPostDBLoadMod + { + private readonly ISptLogger _logger; + + public UseMultipleClasses( + ISptLogger _logger) + { + this._logger = _logger; + } + + public void PostDBLoad() + { + // We create an instance of the other class + var otherClass = new SecondClass(); + + // We call the "GetText" method that exists in the other class + var text = otherClass.GetText(); + + // Log the result to the server console + _logger.Info($"The SecondClass returned the text: {text}"); + } + } +} diff --git a/ExampleMods/Mods/7UseMultipleClasses/package.json b/ExampleMods/Mods/7UseMultipleClasses/package.json new file mode 100644 index 00000000..51711196 --- /dev/null +++ b/ExampleMods/Mods/7UseMultipleClasses/package.json @@ -0,0 +1,13 @@ +{ + "Name": "7UseMultipleClasses", + "Version": "1.0.0", + "SptVersion": "~4.0", + "LoadBefore": [], + "LoadAfter": [], + "IncompatibileMods": [], + "Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods", + "IsBundleMod": false, + "Author": "SPT", + "Contributors": [], + "Licence": "MIT" +} diff --git a/Libraries/Core/Models/Spt/Mod/PackageJsonData.cs b/Libraries/Core/Models/Spt/Mod/PackageJsonData.cs index 28106c97..96d22f90 100644 --- a/Libraries/Core/Models/Spt/Mod/PackageJsonData.cs +++ b/Libraries/Core/Models/Spt/Mod/PackageJsonData.cs @@ -62,18 +62,6 @@ public record PackageJsonData set; } - public Dictionary? Scripts - { - get; - set; - } - - public Dictionary? DevDependencies - { - get; - set; - } - public string? Licence { get;