Added third party library loading and execution
This commit is contained in:
@@ -24,13 +24,19 @@ namespace Core.Helpers
|
||||
return Path.GetDirectoryName(modAssembly.Location);
|
||||
}
|
||||
|
||||
public T GetFileFromModFolder<T>(string pathToFile, string fileName)
|
||||
public string GetRawFileData(string pathToFile, string fileName)
|
||||
{
|
||||
// Read the content of the config file as a string
|
||||
return _fileUtil.ReadFile(Path.Combine(pathToFile, fileName));
|
||||
}
|
||||
|
||||
public T GetJsonDataFromFile<T>(string pathToFile, string fileName)
|
||||
{
|
||||
// Read the content of the config file as a string
|
||||
var rawContent = _fileUtil.ReadFile(Path.Combine(pathToFile, fileName));
|
||||
|
||||
// Take the string above and deserialise it into a file with a type (defined between the diamond brackets)
|
||||
return _jsonUtil.DeserializeFromFile<T>(rawContent);
|
||||
return _jsonUtil.Deserialize<T>(rawContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,22 @@ namespace Core.Models.Spt.Mod;
|
||||
|
||||
public class SptMod
|
||||
{
|
||||
[JsonPropertyName("PackageJson")]
|
||||
[JsonPropertyName("directory")]
|
||||
public string Directory
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("packageJson")]
|
||||
public PackageJsonData? PackageJson
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("Assembly")]
|
||||
public Assembly? Assembly
|
||||
[JsonPropertyName("assemblies")]
|
||||
public List<Assembly>? Assemblies
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class SemanticVersioningSemVer : ISemVer
|
||||
|
||||
public bool Satisfies(string version, string testVersion)
|
||||
{
|
||||
return Range.IsSatisfied(version, testVersion, true);
|
||||
return Range.IsSatisfied(testVersion, version, true);
|
||||
}
|
||||
|
||||
public bool AnySatisfies(string version, List<string> testVersions)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "10CustomStaticRouter",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "10CustomStaticRouter",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "11RegisterClassesInDI",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "11RegisterClassesInDI",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "12Bundle",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "12Bundle",
|
||||
"version": "1.0.0",
|
||||
"sptVersion": "~4.0",
|
||||
"loadBefore": [],
|
||||
"loadAfter": [],
|
||||
"IncompatibileMods": [],
|
||||
"Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
|
||||
"IsBundleMod": true,
|
||||
"Author": "SPT",
|
||||
"Contributors": [],
|
||||
"Licence": "MIT"
|
||||
"url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
|
||||
"isBundleMod": true,
|
||||
"author": "SPT",
|
||||
"contributors": [],
|
||||
"licence": "MIT"
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class AddTraderWithDynamicAssorts : IPostDBLoadMod
|
||||
var pathToMod = _modHelper.GetAbsolutePathToModFolder(Assembly.GetExecutingAssembly());
|
||||
|
||||
var traderImagePath = Path.Combine(pathToMod, "db/cat.jpg");
|
||||
var traderBase = _modHelper.GetFileFromModFolder<TraderBase>(pathToMod, "db/base.json");
|
||||
var traderBase = _modHelper.GetJsonDataFromFile<TraderBase>(pathToMod, "db/base.json");
|
||||
|
||||
// Create helper class and use it to register our traders image/icon + set its stock refresh time
|
||||
var addTraderHelper = new AddTraderHelper();
|
||||
@@ -112,7 +112,7 @@ public class AddTraderWithDynamicAssorts : IPostDBLoadMod
|
||||
.AddLoyaltyLevel(1)
|
||||
.Export(tables.Traders[traderBase.Id]);
|
||||
|
||||
// Add mp133 preset as a barter for mayonase
|
||||
// Add mp133 preset as a barter for mayonase
|
||||
fluentAssortCreator
|
||||
.CreateComplexAssortItem(tables.Globals.ItemPresets["584148f2245977598f1ad387"].Items) // Weapon preset id comes from globals.json
|
||||
.AddStackCount(200)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "13.1AddTraderWithDynamicAssorts",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "13.1AddTraderWithDynamicAssorts",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ public class AddTraderWithAssortJson : IPostDBLoadMod
|
||||
var pathToMod = _modHelper.GetAbsolutePathToModFolder(Assembly.GetExecutingAssembly());
|
||||
|
||||
var traderImagePath = Path.Combine(pathToMod, "db/cat.jpg");
|
||||
var traderBase = _modHelper.GetFileFromModFolder<TraderBase>(pathToMod, "db/base.json");
|
||||
var traderBase = _modHelper.GetJsonDataFromFile<TraderBase>(pathToMod, "db/base.json");
|
||||
|
||||
var assort = _modHelper.GetFileFromModFolder<TraderAssort>(pathToMod, "db/assort.json");
|
||||
var assort = _modHelper.GetJsonDataFromFile<TraderAssort>(pathToMod, "db/assort.json");
|
||||
|
||||
// Create helper class and use it to register our traders image/icon + set its stock refresh time
|
||||
var addTraderHelper = new AddTraderHelper();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "1313AddTraderWithAssortJson",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "1313AddTraderWithAssortJson",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "14AfterDBLoadHook",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "14AfterDBLoadHook",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "15HttpListenerExample",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "15HttpListenerExample",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "18.1CustomItemServiceLootBox",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "18.1CustomItemServiceLootBox",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "18CustomItemService",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "18CustomItemService",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"Name": "1Logging",
|
||||
"Author": "SPT",
|
||||
"Contributors": [],
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"IncompatibleMods": [],
|
||||
"Dependencies": [],
|
||||
"Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
|
||||
"IsBundleMod": false,
|
||||
"Licence": "MIT"
|
||||
"name": "1Logging",
|
||||
"author": "SPT",
|
||||
"contributors": [],
|
||||
"version": "1.0.0",
|
||||
"sptVersion": "~4.0",
|
||||
"loadBefore": [],
|
||||
"loadAfter": [],
|
||||
"incompatibilities": [],
|
||||
"dependencies": [],
|
||||
"url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
|
||||
"isBundleMod": false,
|
||||
"licence": "MIT"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "20CustomChatBot",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "20CustomChatBot",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "21CustomCommandoCommand",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "21CustomCommandoCommand",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "22CustomSptCommand",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "22CustomSptCommand",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "23CustomAbstractChatBot",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "23CustomAbstractChatBot",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "24Websocket",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "24Websocket",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "2EditDatabase",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"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"
|
||||
"url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
|
||||
"isBundleMod": false,
|
||||
"author": "SPT",
|
||||
"contributors": [],
|
||||
"licence": "MIT"
|
||||
}
|
||||
|
||||
@@ -71,16 +71,6 @@ public class EditConfigs : IPostDBLoadMod
|
||||
// Let's disable loot on scavs
|
||||
_botConfig.DisableLootOnBotTypes.Add("assault");
|
||||
|
||||
// Let's make the conversion rate of scavs to pmcs 100% on factory day
|
||||
var factory4DayConversionSettings = _pmcConfig.ConvertIntoPmcChance["factory4_day"];
|
||||
|
||||
// We get assault bot settings for factory day
|
||||
var assaultConversionSettings = factory4DayConversionSettings["assault"];
|
||||
|
||||
// Set min and max to 100%
|
||||
assaultConversionSettings.Min = 100;
|
||||
assaultConversionSettings.Max = 100;
|
||||
|
||||
_logger.Success("Finished Editing Configs");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "3EditSptConfig",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"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"
|
||||
"url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
|
||||
"isBundleMod": false,
|
||||
"author": "SPT",
|
||||
"contributors": [],
|
||||
"licence": "MIT"
|
||||
}
|
||||
|
||||
@@ -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}");
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace _5ReadCustomJsonConfig
|
||||
var pathToMod = _modHelper.GetAbsolutePathToModFolder(Assembly.GetExecutingAssembly());
|
||||
|
||||
// We give the path to the mod folder and the file we want to get, giving us the config, supply the files 'type' between the diamond brackets
|
||||
var config = _modHelper.GetFileFromModFolder<ModConfig>(pathToMod, "config.json");
|
||||
var config = _modHelper.GetJsonDataFromFile<ModConfig>(pathToMod, "config.json");
|
||||
|
||||
_logger.Success($"Read property: 'ExampleProperty' from config with value: {config.ExampleProperty}");
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "5ReadCustomConfig",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"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"
|
||||
"url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
|
||||
"isBundleMod": false,
|
||||
"author": "SPT",
|
||||
"contributors": [],
|
||||
"licence": "MIT"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "6OverrideMethod",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "6OverrideMethod",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "7UseMultipleClasses",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"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"
|
||||
"url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
|
||||
"isBundleMod": false,
|
||||
"author": "SPT",
|
||||
"contributors": [],
|
||||
"licence": "MIT"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "8OnLoadExample",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "8OnLoadExample",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Name": "9OnUpdateExample",
|
||||
"Version": "1.0.0",
|
||||
"SptVersion": "~4.0",
|
||||
"LoadBefore": [],
|
||||
"LoadAfter": [],
|
||||
"name": "9OnUpdateExample",
|
||||
"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"
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using System.Text.Json;
|
||||
using Core.Models.Spt.Mod;
|
||||
|
||||
@@ -48,7 +49,11 @@ public class ModDllLoader
|
||||
/// <returns>SptMod</returns>
|
||||
private static SptMod LoadMod(string path)
|
||||
{
|
||||
var result = new SptMod();
|
||||
var result = new SptMod
|
||||
{
|
||||
Directory = path,
|
||||
Assemblies = []
|
||||
};
|
||||
var asmCount = 0;
|
||||
var packCount = 0;
|
||||
foreach (var file in new DirectoryInfo(path).GetFiles()) // only search top level
|
||||
@@ -69,12 +74,7 @@ public class ModDllLoader
|
||||
if (file.Extension.ToLower() == ".dll")
|
||||
{
|
||||
asmCount++;
|
||||
|
||||
result.Assembly = Assembly.LoadFile(Path.GetFullPath(file.FullName));
|
||||
if (asmCount > 1)
|
||||
{
|
||||
throw new Exception($"More than one Assembly found in: {path}");
|
||||
}
|
||||
result.Assemblies.Add(AssemblyLoadContext.Default.LoadFromAssemblyPath(Path.GetFullPath(file.FullName)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class ModDllLoader
|
||||
throw new Exception($"The package.json file for {path} is missing one of these properties: name, author, licence, version or sptVersion");
|
||||
}
|
||||
|
||||
if (result.Assembly is not null && result.PackageJson is not null)
|
||||
if (result.Assemblies is not null && result.PackageJson is not null)
|
||||
{
|
||||
Console.WriteLine($"Loaded: {result.PackageJson.Name} Version: {result.PackageJson.Version} by: {result.PackageJson.Author}");
|
||||
}
|
||||
|
||||
@@ -377,9 +377,9 @@ public class ModValidator(
|
||||
var modIsCalledUser = modName.ToLower() == "user";
|
||||
var modIsCalledSrc = modName.ToLower() == "src";
|
||||
var modIsCalledDb = modName.ToLower() == "db";
|
||||
var hasBepinExFolderStructure = fileUtil.DirectoryExists($"{modPath}/plugins");
|
||||
var containsJs = fileUtil.GetFiles(modPath, true, "*.js").Count > 0;
|
||||
var containsTs = fileUtil.GetFiles(modPath, true, "*.ts").Count > 0;
|
||||
var hasBepinExFolderStructure = fileUtil.DirectoryExists($"{mod.Directory}/plugins");
|
||||
var containsJs = fileUtil.GetFiles(mod.Directory, true, "*.js").Count > 0;
|
||||
var containsTs = fileUtil.GetFiles(mod.Directory, true, "*.ts").Count > 0;
|
||||
|
||||
if (modIsCalledSrc || modIsCalledDb || modIsCalledUser)
|
||||
{
|
||||
|
||||
+2
-2
@@ -31,12 +31,12 @@ public static class Program
|
||||
// validate and sort mods, this will also discard any mods that are invalid
|
||||
var sortedLoadedMods = ValidateMods(mods);
|
||||
// for harmony we use the original list, as some mods may only be bepinex patches only
|
||||
HarmonyBootstrapper.LoadAllPatches(mods.Select(asm => asm.Assembly).ToList());
|
||||
HarmonyBootstrapper.LoadAllPatches(mods.SelectMany(asm => asm.Assemblies).ToList());
|
||||
|
||||
// register SPT components
|
||||
DependencyInjectionRegistrator.RegisterSptComponents(typeof(Program).Assembly, typeof(App).Assembly, builder.Services);
|
||||
// register mod components from the filtered list
|
||||
DependencyInjectionRegistrator.RegisterModOverrideComponents(builder.Services, sortedLoadedMods.Select(a => a.Assembly).ToList());
|
||||
DependencyInjectionRegistrator.RegisterModOverrideComponents(builder.Services, sortedLoadedMods.SelectMany(a => a.Assemblies).ToList());
|
||||
var logger = new SerilogLoggerProvider(registeredLogger).CreateLogger("Server");
|
||||
try
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Version>4.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user