Added OnWebAppBuild load step (#489)
* Fingers crossed this will fix the mod loading issue for configs * Renamed classes and documentation for clarity * Remove some extra traces of the old PreSptLoader * Renamed interface for clarity and updated docs * Re-introduced PreSptModLoad for now --------- Co-authored-by: Alex <clodanSPT@hotmail.com>
This commit is contained in:
@@ -9,10 +9,9 @@ public static class OnLoadOrder
|
|||||||
public const int PostDBModLoader = 4000;
|
public const int PostDBModLoader = 4000;
|
||||||
public const int TraderRegistration = 5000;
|
public const int TraderRegistration = 5000;
|
||||||
public const int HandbookCallbacks = 6000;
|
public const int HandbookCallbacks = 6000;
|
||||||
public const int HttpCallbacks = 7000;
|
public const int SaveCallbacks = 7000;
|
||||||
public const int SaveCallbacks = 8000;
|
public const int TraderCallbacks = 8000;
|
||||||
public const int TraderCallbacks = 9000;
|
public const int PresetCallbacks = 9000;
|
||||||
public const int PresetCallbacks = 10000;
|
public const int RagfairCallbacks = 10000;
|
||||||
public const int RagfairCallbacks = 11000;
|
public const int PostSptModLoader = 11000;
|
||||||
public const int PostSptModLoader = 12000;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using SPTarkov.DI.Annotations;
|
||||||
|
using SPTarkov.Server.Core.Models.External;
|
||||||
|
using SPTarkov.Server.Core.Models.Utils;
|
||||||
|
using SPTarkov.Server.Core.Utils;
|
||||||
|
|
||||||
|
namespace SPTarkov.Server.Core.Loaders;
|
||||||
|
|
||||||
|
[Injectable(InjectionType.Singleton)]
|
||||||
|
public class OnWebAppBuildModLoader(
|
||||||
|
ISptLogger<OnWebAppBuildModLoader> _logger,
|
||||||
|
IEnumerable<IOnWebAppBuildModAsync> _onWebAppBuildMods
|
||||||
|
)
|
||||||
|
{
|
||||||
|
public async Task OnLoad()
|
||||||
|
{
|
||||||
|
if (ProgramStatics.MODS())
|
||||||
|
{
|
||||||
|
_logger.Info("Loading OnWebAppBuildMods...");
|
||||||
|
foreach (var onWebAppBuildMod in _onWebAppBuildMods)
|
||||||
|
{
|
||||||
|
await onWebAppBuildMod.OnWebAppBuildAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Info("Finished loading OnWebAppBuildMods...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-4
@@ -1,4 +1,4 @@
|
|||||||
using SPTarkov.DI.Annotations;
|
using SPTarkov.DI.Annotations;
|
||||||
using SPTarkov.Server.Core.DI;
|
using SPTarkov.Server.Core.DI;
|
||||||
using SPTarkov.Server.Core.Models.External;
|
using SPTarkov.Server.Core.Models.External;
|
||||||
using SPTarkov.Server.Core.Models.Utils;
|
using SPTarkov.Server.Core.Models.Utils;
|
||||||
@@ -6,9 +6,6 @@ using SPTarkov.Server.Core.Utils;
|
|||||||
|
|
||||||
namespace SPTarkov.Server.Core.Loaders;
|
namespace SPTarkov.Server.Core.Loaders;
|
||||||
|
|
||||||
[Obsolete(
|
|
||||||
"This mod loader is obsolete and will be removed in 4.1.0. See documentation in IPreSptLoadModAsync for more information."
|
|
||||||
)]
|
|
||||||
[Injectable(InjectionType.Singleton, TypePriority = OnLoadOrder.PreSptModLoader)]
|
[Injectable(InjectionType.Singleton, TypePriority = OnLoadOrder.PreSptModLoader)]
|
||||||
public class PreSptModLoader(
|
public class PreSptModLoader(
|
||||||
ISptLogger<PreSptModLoader> _logger,
|
ISptLogger<PreSptModLoader> _logger,
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace SPTarkov.Server.Core.Models.External;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class now runs the Kestrel server is being configured/built, making it the perfect spot to change server configurations.
|
||||||
|
/// </summary>
|
||||||
|
public interface IOnWebAppBuildModAsync
|
||||||
|
{
|
||||||
|
Task OnWebAppBuildAsync();
|
||||||
|
}
|
||||||
@@ -1,22 +1,8 @@
|
|||||||
namespace SPTarkov.Server.Core.Models.External;
|
namespace SPTarkov.Server.Core.Models.External;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This interface used to be used in TS to load mods before SPT components loading.
|
/// Interface used to make changes before any of the SPT server logic runs. After the Watermark print, but before the Database loads
|
||||||
/// This class is now deprecated and should not be used, see code example below for replacement.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <code>
|
|
||||||
/// [Injectable(TypePriority = OnLoadOrder.Watermark + 1)]
|
|
||||||
/// public class MyMod : IOnLoad
|
|
||||||
/// {
|
|
||||||
/// // ... implementation
|
|
||||||
/// }
|
|
||||||
/// </code>
|
|
||||||
/// <remarks>
|
|
||||||
/// <b>DEPRECATED, see code example above for replacement!</b>
|
|
||||||
/// </remarks>
|
|
||||||
[Obsolete(
|
|
||||||
"This interface is obsolete and will be removed in 4.1.0, please use IOnLoad instead with the desired Injectable(TypePriority). See class documentation for examples."
|
|
||||||
)]
|
|
||||||
public interface IPreSptLoadModAsync
|
public interface IPreSptLoadModAsync
|
||||||
{
|
{
|
||||||
Task PreSptLoadAsync();
|
Task PreSptLoadAsync();
|
||||||
|
|||||||
@@ -121,9 +121,9 @@ public static class Program
|
|||||||
builder.WebHost.ConfigureKestrel(
|
builder.WebHost.ConfigureKestrel(
|
||||||
(_, options) =>
|
(_, options) =>
|
||||||
{
|
{
|
||||||
var httpConfig = options
|
// This method is not expected to be async so we need to wait for the Task instead of using await keyword
|
||||||
.ApplicationServices.GetService<ConfigServer>()
|
options.ApplicationServices.GetService<OnWebAppBuildModLoader>()!.OnLoad().Wait();
|
||||||
?.GetConfig<HttpConfig>()!;
|
var httpConfig = options.ApplicationServices.GetService<ConfigServer>()?.GetConfig<HttpConfig>()!;
|
||||||
var certHelper = options.ApplicationServices.GetService<CertificateHelper>()!;
|
var certHelper = options.ApplicationServices.GetService<CertificateHelper>()!;
|
||||||
options.Listen(
|
options.Listen(
|
||||||
IPAddress.Parse(httpConfig.Ip),
|
IPAddress.Parse(httpConfig.Ip),
|
||||||
|
|||||||
Reference in New Issue
Block a user