diff --git a/Libraries/SPTarkov.Server.Core/Loaders/PostDBModLoader.cs b/Libraries/SPTarkov.Server.Core/Loaders/PostDBModLoader.cs
index 247c1538..999937c9 100644
--- a/Libraries/SPTarkov.Server.Core/Loaders/PostDBModLoader.cs
+++ b/Libraries/SPTarkov.Server.Core/Loaders/PostDBModLoader.cs
@@ -2,6 +2,7 @@ using SPTarkov.Server.Core.DI;
using SPTarkov.Server.Core.Models.External;
using SPTarkov.Server.Core.Models.Utils;
using SPTarkov.Common.Annotations;
+using SPTarkov.Server.Core.Utils;
namespace SPTarkov.Server.Core.Loaders;
@@ -13,13 +14,16 @@ public class PostDBModLoader(
{
public async Task OnLoad()
{
- _logger.Info("Loading PostDBLoadMod...");
- foreach (var postDbLoadMod in _postDbLoadMods)
+ if (ProgramStatics.MODS())
{
- postDbLoadMod.PostDBLoad();
- }
+ _logger.Info("Loading PostDBMods...");
+ foreach (var postDbLoadMod in _postDbLoadMods)
+ {
+ postDbLoadMod.PostDBLoad();
+ }
- _logger.Info("Finished loading PostDBLoadMod...");
+ _logger.Info("Finished loading PostDBMods...");
+ }
}
public string GetRoute()
diff --git a/Libraries/SPTarkov.Server.Core/Loaders/PostSptModLoader.cs b/Libraries/SPTarkov.Server.Core/Loaders/PostSptModLoader.cs
index 44a1c2f4..7d88b03a 100644
--- a/Libraries/SPTarkov.Server.Core/Loaders/PostSptModLoader.cs
+++ b/Libraries/SPTarkov.Server.Core/Loaders/PostSptModLoader.cs
@@ -16,17 +16,14 @@ public class PostSptModLoader(
{
if (ProgramStatics.MODS())
{
- // await _postSptModLoader.load();
- // TODO: Huh?
- }
+ _logger.Info("Loading PostSptMods...");
+ foreach (var postSptLoadMod in _postSptLoadMods)
+ {
+ postSptLoadMod.PostSptLoad();
+ }
- _logger.Info("Loading PostSptMods...");
- foreach (var postSptLoadMod in _postSptLoadMods)
- {
- postSptLoadMod.PostSptLoad();
+ _logger.Info("Finished loading PostSptMods...");
}
-
- _logger.Info("Finished loading PostSptMods...");
}
public string GetRoute()
diff --git a/Libraries/SPTarkov.Server.Core/SPTarkov.Server.Core.csproj b/Libraries/SPTarkov.Server.Core/SPTarkov.Server.Core.csproj
index b956c25c..48eef631 100644
--- a/Libraries/SPTarkov.Server.Core/SPTarkov.Server.Core.csproj
+++ b/Libraries/SPTarkov.Server.Core/SPTarkov.Server.Core.csproj
@@ -30,13 +30,14 @@
-
- 0.0.0
+ 4.0.0
a12b34
0000000000
LOCAL
+
+
assemblies)
{
+ if (!ProgramStatics.MODS())
+ {
+ return;
+ }
+
var hamony = new Harmony("SPT");
foreach (var assembly in assemblies)
{
diff --git a/SPTarkov.Server/Modding/ModDllLoader.cs b/SPTarkov.Server/Modding/ModDllLoader.cs
index 5f149c5b..45e49fb4 100644
--- a/SPTarkov.Server/Modding/ModDllLoader.cs
+++ b/SPTarkov.Server/Modding/ModDllLoader.cs
@@ -2,6 +2,7 @@ using System.Reflection;
using System.Runtime.Loader;
using System.Text.Json;
using SPTarkov.Server.Core.Models.Spt.Mod;
+using SPTarkov.Server.Core.Utils;
namespace SPTarkov.Server.Modding;
@@ -18,6 +19,11 @@ public class ModDllLoader
var mods = new List();
+ if (!ProgramStatics.MODS())
+ {
+ return mods;
+ }
+
// foreach directory in /user/mods/
// treat this as the MOD
// should contain a dll and Package.json
diff --git a/SPTarkov.Server/Program.cs b/SPTarkov.Server/Program.cs
index 50ba4e28..a83a4839 100644
--- a/SPTarkov.Server/Program.cs
+++ b/SPTarkov.Server/Program.cs
@@ -21,12 +21,14 @@ public static class Program
{
public static void Main(string[] args)
{
+ // Initialize the program variables
+ ProgramStatics.Initialize();
+
// Search for mod dlls
var mods = ModDllLoader.LoadAllMods();
+
// Create web builder and logger
var builder = CreateNewHostBuilder(args);
- // Initialize the program variables TODO: this needs to be implemented properly
- ProgramStatics.Initialize();
// validate and sort mods, this will also discard any mods that are invalid
var sortedLoadedMods = ValidateMods(mods);
@@ -35,8 +37,13 @@ public static class Program
// 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.SelectMany(a => a.Assemblies).ToList());
+
+ if (ProgramStatics.MODS())
+ {
+ // register mod components from the filtered list
+ DependencyInjectionRegistrator.RegisterModOverrideComponents(builder.Services, sortedLoadedMods.SelectMany(a => a.Assemblies).ToList());
+ }
+
var serviceProvider = builder.Services.BuildServiceProvider();
var logger = serviceProvider.GetService().CreateLogger("Server");
try
@@ -57,6 +64,7 @@ public static class Program
// Add the Loaded Mod Assemblies for later
appContext?.AddValue(ContextVariableType.LOADED_MOD_ASSEMBLIES, mods);
+
// This is the builder that will get use by the HttpServer to start up the web application
appContext?.AddValue(ContextVariableType.APP_BUILDER, builder);
@@ -89,11 +97,15 @@ public static class Program
{
var builder = WebApplication.CreateBuilder(args);
builder.Logging.ClearProviders();
-#if DEBUG
- builder.Configuration.AddJsonFile("appsettings.Development.json", true, true);
-#else
- builder.Configuration.AddJsonFile("appsettings.json", true, true);
-#endif
+
+ if (ProgramStatics.DEBUG())
+ {
+ builder.Configuration.AddJsonFile("appsettings.Development.json", true, true);
+ }
+ else
+ {
+ builder.Configuration.AddJsonFile("appsettings.json", true, true);
+ }
builder.Host.UseSerilog((context, provider, logger) =>
{
@@ -111,6 +123,11 @@ public static class Program
private static List ValidateMods(List mods)
{
+ if (!ProgramStatics.MODS())
+ {
+ return [];
+ }
+
// We need the SPT dependencies for the ModValidator, but mods are loaded before the web application
// So we create a disposable web application that we will throw away after getting the mods to load
var builder = CreateNewHostBuilder();