fixed missing import for customitemservice, added bundle loading sequence in the program.cs (#333)
* Added missing import for reflection /bonk * Implemented bundles.json loading directly into program.cs `IsBundleMod` is now read from all loaded mods metadata, and if set to true the bundles.json is read from the mod directory. * re-assign the sorted valid mods to the loadedMods list since ValidateMods returns the sortedLoadedMods, this is the list of mods we should be passing to our other spots --------- Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,7 @@ using SPTarkov.Server.Core.Models.Spt.Mod;
|
||||
using SPTarkov.Server.Core.Models.Utils;
|
||||
using SPTarkov.Server.Core.Utils;
|
||||
using SPTarkov.Server.Core.Utils.Cloners;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SPTarkov.Server.Core.Services.Mod;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Runtime.InteropServices;
|
||||
using SPTarkov.Common.Semver;
|
||||
using SPTarkov.Common.Semver.Implementations;
|
||||
using SPTarkov.DI;
|
||||
using SPTarkov.Server.Core.Loaders;
|
||||
using SPTarkov.Server.Core.Models.Spt.Mod;
|
||||
using SPTarkov.Server.Core.Models.Utils;
|
||||
using SPTarkov.Server.Core.Servers;
|
||||
@@ -36,6 +37,9 @@ public static class Program
|
||||
// validate and sort mods, this will also discard any mods that are invalid
|
||||
var sortedLoadedMods = ValidateMods(loadedMods);
|
||||
|
||||
// update the loadedMods list with our validated sorted mods
|
||||
loadedMods = sortedLoadedMods;
|
||||
|
||||
diHandler.AddInjectableTypesFromAssemblies(sortedLoadedMods.SelectMany(a => a.Assemblies));
|
||||
}
|
||||
diHandler.InjectAll();
|
||||
@@ -44,7 +48,24 @@ public static class Program
|
||||
builder.Services.AddSingleton<IReadOnlyList<SptMod>>(loadedMods);
|
||||
var serviceProvider = builder.Services.BuildServiceProvider();
|
||||
var logger = serviceProvider.GetService<ILoggerFactory>().CreateLogger("Server");
|
||||
// Load bundles for bundle mods
|
||||
if (ProgramStatics.MODS())
|
||||
{
|
||||
var bundleLoader = serviceProvider.GetService<BundleLoader>();
|
||||
foreach (var mod in loadedMods)
|
||||
{
|
||||
if (mod.ModMetadata?.IsBundleMod == true)
|
||||
{
|
||||
// Convert to relative path
|
||||
string relativeModPath = Path.GetRelativePath(
|
||||
Directory.GetCurrentDirectory(),
|
||||
mod.Directory
|
||||
).Replace('\\', '/');
|
||||
|
||||
bundleLoader.AddBundles(relativeModPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
SetConsoleOutputMode();
|
||||
|
||||
Reference in New Issue
Block a user