Added third party library loading and execution

This commit is contained in:
clodan
2025-02-25 17:35:34 +00:00
parent 4999b80172
commit aca6446d5c
39 changed files with 294 additions and 268 deletions
@@ -10,8 +10,17 @@
<!-- The two lines below will set the output path for the binaries -->
<OutputPath>bin\$(Configuration)\$(ProjectName)\$(AssemblyName)-$(Version)\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="fastJSON5" Version="1.0.4" >
<Private>true</Private>
<CopyLocal>true</CopyLocal>
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
</PackageReference>
</ItemGroup>
<!-- TODO: Change to Nuget Package -->
<ItemGroup>
<Reference Include="Core">
@@ -33,4 +42,10 @@
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
<ItemGroup>
<None Remove="config.json5" />
<Content Include="config.json5">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
@@ -2,6 +2,7 @@
using System.Reflection;
using Core.Models.External;
using Core.Models.Utils;
using fastJSON5;
using SptCommon.Annotations;
namespace _4ReadCustomJson5Config
@@ -24,8 +25,8 @@ namespace _4ReadCustomJson5Config
{
var pathToMod = _modHelper.GetAbsolutePathToModFolder(Assembly.GetExecutingAssembly());
// TODO - fix/implement
var json5Config = _modHelper.GetFileFromModFolder<ModConfig>(pathToMod, "config.json5");
// To use JSON5, you will have to find and provide your own JSON5 library to decode it
var json5Config = JSON5.ToObject<ModConfig>(_modHelper.GetRawFileData(pathToMod, "config.json5"));
_logger.Success($"Read property: 'ExampleProperty' from config with value: {json5Config.ExampleProperty}");
}
+16 -10
View File
@@ -1,13 +1,19 @@
{
"Name": "4ReadCustomJson5Config",
"Version": "1.0.0",
"SptVersion": "~4.0",
"LoadBefore": [],
"LoadAfter": [],
"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"
"url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
"isBundleMod": false,
"author": "SPT",
"contributors": [],
"licence": "MIT",
"dependencies": [
{
"name": "fastJSON5",
"version": "1.0.4"
}
]
}