Refactored pre spt mod loader to user IOnLoad, moved Watermark to IOnLoad as well (#313)
Co-authored-by: Alex <alex@dm-me-for-questions.com>
This commit is contained in:
@@ -23,11 +23,6 @@ public class DialogueCallbacks(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-dialogue";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle client/friend/list
|
/// Handle client/friend/list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -24,11 +24,6 @@ public class GameCallbacks(
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-game";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle client/game/version/validate
|
/// Handle client/game/version/validate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -12,9 +12,4 @@ public class HandbookCallbacks(HandBookController _handBookController) : IOnLoad
|
|||||||
_handBookController.Load();
|
_handBookController.Load();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-handbook";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,11 +28,6 @@ public class HideoutCallbacks(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-hideout";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle HideoutUpgrade event
|
/// Handle HideoutUpgrade event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -14,11 +14,6 @@ public class HttpCallbacks(HttpServer _httpServer) : IOnLoad
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-http";
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetImage()
|
public string GetImage()
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
@@ -33,11 +33,6 @@ public class InsuranceCallbacks(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-insurance";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle client/insurance/items/list/cost
|
/// Handle client/insurance/items/list/cost
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -12,9 +12,4 @@ public class PresetCallbacks(PresetController _presetController) : IOnLoad
|
|||||||
_presetController.Initialize();
|
_presetController.Initialize();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-presets";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ public class RagfairCallbacks(
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-ragfair";
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool OnUpdate(long timeSinceLastRun)
|
public bool OnUpdate(long timeSinceLastRun)
|
||||||
{
|
{
|
||||||
if (timeSinceLastRun > _ragfairConfig.RunIntervalSeconds)
|
if (timeSinceLastRun > _ragfairConfig.RunIntervalSeconds)
|
||||||
|
|||||||
@@ -22,11 +22,6 @@ public class SaveCallbacks(
|
|||||||
_saveServer.Load();
|
_saveServer.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-save";
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool OnUpdate(long timeSinceLastRun)
|
public bool OnUpdate(long timeSinceLastRun)
|
||||||
{
|
{
|
||||||
if (timeSinceLastRun > _coreConfig.ProfileSaveIntervalInSeconds)
|
if (timeSinceLastRun > _coreConfig.ProfileSaveIntervalInSeconds)
|
||||||
|
|||||||
@@ -23,11 +23,6 @@ public class TraderCallbacks(
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-traders";
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool OnUpdate(long _)
|
public bool OnUpdate(long _)
|
||||||
{
|
{
|
||||||
return _traderController.Update();
|
return _traderController.Update();
|
||||||
|
|||||||
@@ -3,5 +3,4 @@ namespace SPTarkov.Server.Core.DI;
|
|||||||
public interface IOnLoad
|
public interface IOnLoad
|
||||||
{
|
{
|
||||||
Task OnLoad();
|
Task OnLoad();
|
||||||
string GetRoute();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,4 @@ namespace SPTarkov.Server.Core.DI;
|
|||||||
public interface IOnUpdate
|
public interface IOnUpdate
|
||||||
{
|
{
|
||||||
bool OnUpdate(long timeSinceLastRun);
|
bool OnUpdate(long timeSinceLastRun);
|
||||||
string GetRoute();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,17 @@ namespace SPTarkov.Server.Core.DI;
|
|||||||
|
|
||||||
public static class OnLoadOrder
|
public static class OnLoadOrder
|
||||||
{
|
{
|
||||||
public const int Database = 0;
|
public const int Watermark = 0;
|
||||||
public const int GameCallbacks = 100;
|
public const int PreSptModLoader = 1000;
|
||||||
public const int PostDBModLoader = 200;
|
public const int Database = 2000;
|
||||||
public const int TraderRegistration = 300;
|
public const int GameCallbacks = 3000;
|
||||||
public const int HandbookCallbacks = 400;
|
public const int PostDBModLoader = 4000;
|
||||||
public const int HttpCallbacks = 500;
|
public const int TraderRegistration = 5000;
|
||||||
public const int SaveCallbacks = 600;
|
public const int HandbookCallbacks = 6000;
|
||||||
public const int TraderCallbacks = 700;
|
public const int HttpCallbacks = 7000;
|
||||||
public const int PresetCallbacks = 800;
|
public const int SaveCallbacks = 8000;
|
||||||
public const int RagfairCallbacks = 900;
|
public const int TraderCallbacks = 9000;
|
||||||
public const int PostSptModLoader = 1000;
|
public const int PresetCallbacks = 10000;
|
||||||
|
public const int RagfairCallbacks = 11000;
|
||||||
|
public const int PostSptModLoader = 12000;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,7 @@ namespace SPTarkov.Server.Core.DI;
|
|||||||
|
|
||||||
public static class OnUpdateOrder
|
public static class OnUpdateOrder
|
||||||
{
|
{
|
||||||
public const int PreSptUpdate = 0;
|
public const int DialogueCallbacks = 1000;
|
||||||
public const int DialogueCallbacks = 1;
|
public const int HideoutCallbacks = 2000;
|
||||||
public const int HideoutCallbacks = 100;
|
public const int InsuranceCallbacks = 3000;
|
||||||
public const int TraderCallbacks = 200;
|
|
||||||
public const int RagfairCallbacks = 300;
|
|
||||||
public const int InsuranceCallbacks = 400;
|
|
||||||
public const int SaveCallbacks = 500;
|
|
||||||
public const int PostSptUpdate = 9999;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,11 +49,6 @@ public class BotGeneratorHelper(
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-botGeneratorHelper";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds properties to an item
|
/// Adds properties to an item
|
||||||
/// e.g. Repairable / HasHinge / Foldable / MaxDurability
|
/// e.g. Repairable / HasHinge / Foldable / MaxDurability
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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 IPostDBLoadModAsync for more information.")]
|
||||||
[Injectable(TypePriority = OnLoadOrder.PostDBModLoader)]
|
[Injectable(TypePriority = OnLoadOrder.PostDBModLoader)]
|
||||||
public class PostDBModLoader(
|
public class PostDBModLoader(
|
||||||
ISptLogger<PostDBModLoader> _logger,
|
ISptLogger<PostDBModLoader> _logger,
|
||||||
@@ -25,9 +26,4 @@ public class PostDBModLoader(
|
|||||||
_logger.Info("Finished loading PostDBMods...");
|
_logger.Info("Finished loading PostDBMods...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-post-db-mods";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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 IPostSptLoadModAsync for more information.")]
|
||||||
[Injectable(TypePriority = OnLoadOrder.PostSptModLoader)]
|
[Injectable(TypePriority = OnLoadOrder.PostSptModLoader)]
|
||||||
public class PostSptModLoader(
|
public class PostSptModLoader(
|
||||||
ISptLogger<PostSptModLoader> _logger,
|
ISptLogger<PostSptModLoader> _logger,
|
||||||
@@ -25,9 +26,4 @@ public class PostSptModLoader(
|
|||||||
_logger.Info("Finished loading PostSptMods...");
|
_logger.Info("Finished loading PostSptMods...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-post-spt-mods";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using SPTarkov.DI.Annotations;
|
||||||
|
using SPTarkov.Server.Core.DI;
|
||||||
|
using SPTarkov.Server.Core.Models.External;
|
||||||
|
using SPTarkov.Server.Core.Models.Utils;
|
||||||
|
using SPTarkov.Server.Core.Utils;
|
||||||
|
|
||||||
|
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)]
|
||||||
|
public class PreSptModLoader(
|
||||||
|
ISptLogger<PreSptModLoader> _logger,
|
||||||
|
IEnumerable<IPreSptLoadModAsync> _preSptLoadMods
|
||||||
|
) : IOnLoad
|
||||||
|
{
|
||||||
|
public async Task OnLoad()
|
||||||
|
{
|
||||||
|
if (ProgramStatics.MODS())
|
||||||
|
{
|
||||||
|
_logger.Info("Loading PreSptMods...");
|
||||||
|
foreach (var postSptLoadMod in _preSptLoadMods)
|
||||||
|
{
|
||||||
|
await postSptLoadMod.PreSptLoadAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Info("Finished loading PreSptMods...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,20 @@
|
|||||||
namespace SPTarkov.Server.Core.Models.External;
|
namespace SPTarkov.Server.Core.Models.External;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface used to be used in TS to load mods after the database finished loading.
|
||||||
|
/// This class is now deprecated and should not be used, see code example below for replacement.
|
||||||
|
/// </summary>
|
||||||
|
/// <code>
|
||||||
|
/// [Injectable(TypePriority = OnLoadOrder.Database + 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 IPostDBLoadModAsync
|
public interface IPostDBLoadModAsync
|
||||||
{
|
{
|
||||||
Task PostDBLoadAsync();
|
Task PostDBLoadAsync();
|
||||||
|
|||||||
@@ -1,5 +1,20 @@
|
|||||||
namespace SPTarkov.Server.Core.Models.External;
|
namespace SPTarkov.Server.Core.Models.External;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface used to be used in TS to load mods after SPT finished loading.
|
||||||
|
/// This class is now deprecated and should not be used, see code example below for replacement.
|
||||||
|
/// </summary>
|
||||||
|
/// <code>
|
||||||
|
/// [Injectable(TypePriority = OnLoadOrder.RagfairCallbacks + 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 IPostSptLoadModAsync
|
public interface IPostSptLoadModAsync
|
||||||
{
|
{
|
||||||
Task PostSptLoadAsync();
|
Task PostSptLoadAsync();
|
||||||
|
|||||||
@@ -1,5 +1,20 @@
|
|||||||
namespace SPTarkov.Server.Core.Models.External;
|
namespace SPTarkov.Server.Core.Models.External;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface used to be used in TS to load mods before SPT components loading.
|
||||||
|
/// This class is now deprecated and should not be used, see code example below for replacement.
|
||||||
|
/// </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();
|
||||||
|
|||||||
@@ -67,11 +67,6 @@ public class TraderStore : IOnLoad
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-trader-registration";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a trader by given ID.
|
/// Returns a trader by given ID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -10,52 +10,23 @@ using LogLevel = SPTarkov.Server.Core.Models.Spt.Logging.LogLevel;
|
|||||||
namespace SPTarkov.Server.Core.Utils;
|
namespace SPTarkov.Server.Core.Utils;
|
||||||
|
|
||||||
[Injectable(InjectionType.Singleton)]
|
[Injectable(InjectionType.Singleton)]
|
||||||
public class App
|
public class App(
|
||||||
|
ISptLogger<App> _logger,
|
||||||
|
TimeUtil _timeUtil,
|
||||||
|
RandomUtil _randomUtil,
|
||||||
|
LocalisationService _localisationService,
|
||||||
|
ConfigServer _configServer,
|
||||||
|
EncodingUtil _encodingUtil,
|
||||||
|
HttpServer _httpServer,
|
||||||
|
DatabaseService _databaseService,
|
||||||
|
IEnumerable<IOnLoad> _onLoadComponents,
|
||||||
|
IEnumerable<IOnUpdate> _onUpdateComponents,
|
||||||
|
HttpServerHelper _httpServerHelper
|
||||||
|
)
|
||||||
{
|
{
|
||||||
protected readonly RandomUtil _randomUtil;
|
protected CoreConfig _coreConfig = _configServer.GetConfig<CoreConfig>();
|
||||||
protected ConfigServer _configServer;
|
|
||||||
protected CoreConfig _coreConfig;
|
|
||||||
protected DatabaseService _databaseService;
|
|
||||||
protected EncodingUtil _encodingUtil;
|
|
||||||
protected HttpServer _httpServer;
|
|
||||||
protected HttpServerHelper _httpServerHelper;
|
|
||||||
protected LocalisationService _localisationService;
|
|
||||||
|
|
||||||
protected ISptLogger<App> _logger;
|
|
||||||
protected IEnumerable<IOnLoad> _onLoad;
|
|
||||||
protected IEnumerable<IOnUpdate> _onUpdate;
|
|
||||||
protected Dictionary<string, long> _onUpdateLastRun = new();
|
protected Dictionary<string, long> _onUpdateLastRun = new();
|
||||||
protected Timer _timer;
|
protected Timer _timer;
|
||||||
protected TimeUtil _timeUtil;
|
|
||||||
|
|
||||||
public App(
|
|
||||||
ISptLogger<App> logger,
|
|
||||||
TimeUtil timeUtil,
|
|
||||||
RandomUtil randomUtil,
|
|
||||||
LocalisationService localisationService,
|
|
||||||
ConfigServer configServer,
|
|
||||||
EncodingUtil encodingUtil,
|
|
||||||
HttpServer httpServer,
|
|
||||||
DatabaseService databaseService,
|
|
||||||
IEnumerable<IOnLoad> onLoadComponents,
|
|
||||||
IEnumerable<IOnUpdate> onUpdateComponents,
|
|
||||||
HttpServerHelper httpServerHelper
|
|
||||||
)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_timeUtil = timeUtil;
|
|
||||||
_randomUtil = randomUtil;
|
|
||||||
_localisationService = localisationService;
|
|
||||||
_configServer = configServer;
|
|
||||||
_encodingUtil = encodingUtil;
|
|
||||||
_httpServer = httpServer;
|
|
||||||
_httpServerHelper = httpServerHelper;
|
|
||||||
_databaseService = databaseService;
|
|
||||||
_onLoad = onLoadComponents;
|
|
||||||
_onUpdate = onUpdateComponents;
|
|
||||||
|
|
||||||
_coreConfig = configServer.GetConfig<CoreConfig>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task InitializeAsync()
|
public async Task InitializeAsync()
|
||||||
{
|
{
|
||||||
@@ -90,12 +61,12 @@ public class App
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var onLoad in _onLoad)
|
foreach (var onLoad in _onLoadComponents)
|
||||||
{
|
{
|
||||||
await onLoad.OnLoad();
|
await onLoad.OnLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
_timer = new Timer(_ => Update(_onUpdate), null, TimeSpan.Zero, TimeSpan.FromMilliseconds(5000));
|
_timer = new Timer(_ => Update(_onUpdateComponents), null, TimeSpan.Zero, TimeSpan.FromMilliseconds(5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StartAsync()
|
public async Task StartAsync()
|
||||||
@@ -133,8 +104,14 @@ public class App
|
|||||||
|
|
||||||
foreach (var updateable in onUpdateComponents)
|
foreach (var updateable in onUpdateComponents)
|
||||||
{
|
{
|
||||||
|
var updateableName = updateable.GetType().FullName;
|
||||||
|
if (string.IsNullOrEmpty(updateableName))
|
||||||
|
{
|
||||||
|
updateableName = $"{updateable.GetType().Namespace}.{updateable.GetType().Name}";
|
||||||
|
}
|
||||||
|
|
||||||
var success = false;
|
var success = false;
|
||||||
if (!_onUpdateLastRun.TryGetValue(updateable.GetRoute(), out var lastRunTimeTimestamp))
|
if (!_onUpdateLastRun.TryGetValue(updateableName, out var lastRunTimeTimestamp))
|
||||||
{
|
{
|
||||||
lastRunTimeTimestamp = 0;
|
lastRunTimeTimestamp = 0;
|
||||||
}
|
}
|
||||||
@@ -152,7 +129,7 @@ public class App
|
|||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
_onUpdateLastRun[updateable.GetRoute()] = _timeUtil.GetTimeStamp();
|
_onUpdateLastRun[updateableName] = _timeUtil.GetTimeStamp();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -163,7 +140,7 @@ public class App
|
|||||||
{
|
{
|
||||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||||
{
|
{
|
||||||
_logger.Debug(_localisationService.GetText("route_onupdate_no_response", updateable.GetRoute()));
|
_logger.Debug(_localisationService.GetText("route_onupdate_no_response", updateableName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,7 +155,7 @@ public class App
|
|||||||
|
|
||||||
protected void LogUpdateException(Exception err, IOnUpdate updateable)
|
protected void LogUpdateException(Exception err, IOnUpdate updateable)
|
||||||
{
|
{
|
||||||
_logger.Error(_localisationService.GetText("scheduled_event_failed_to_run", updateable.GetRoute()));
|
_logger.Error(_localisationService.GetText("scheduled_event_failed_to_run", updateable.GetType().FullName));
|
||||||
_logger.Error(err.ToString());
|
_logger.Error(err.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,11 +90,6 @@ public class DatabaseImporter : IOnLoad
|
|||||||
CreateRouteMapping(imageFilePath, "files");
|
CreateRouteMapping(imageFilePath, "files");
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetRoute()
|
|
||||||
{
|
|
||||||
return "spt-database";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get path to spt data
|
* Get path to spt data
|
||||||
* @returns path to data
|
* @returns path to data
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using SPTarkov.DI.Annotations;
|
using SPTarkov.DI.Annotations;
|
||||||
|
using SPTarkov.Server.Core.DI;
|
||||||
using SPTarkov.Server.Core.Models.Logging;
|
using SPTarkov.Server.Core.Models.Logging;
|
||||||
using SPTarkov.Server.Core.Models.Spt.Config;
|
using SPTarkov.Server.Core.Models.Spt.Config;
|
||||||
using SPTarkov.Server.Core.Models.Utils;
|
using SPTarkov.Server.Core.Models.Utils;
|
||||||
@@ -61,8 +62,8 @@ public class WatermarkLocale
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Injectable]
|
[Injectable(TypePriority = OnLoadOrder.Watermark)]
|
||||||
public class Watermark
|
public class Watermark : IOnLoad
|
||||||
{
|
{
|
||||||
protected ConfigServer _configServer;
|
protected ConfigServer _configServer;
|
||||||
protected LocalisationService _localisationService;
|
protected LocalisationService _localisationService;
|
||||||
@@ -87,7 +88,7 @@ public class Watermark
|
|||||||
sptConfig = _configServer.GetConfig<CoreConfig>();
|
sptConfig = _configServer.GetConfig<CoreConfig>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Initialize()
|
public Task OnLoad()
|
||||||
{
|
{
|
||||||
var description = _watermarkLocale.GetDescription();
|
var description = _watermarkLocale.GetDescription();
|
||||||
var warning = _watermarkLocale.GetWarning();
|
var warning = _watermarkLocale.GetWarning();
|
||||||
@@ -121,6 +122,8 @@ public class Watermark
|
|||||||
|
|
||||||
SetTitle();
|
SetTitle();
|
||||||
Draw();
|
Draw();
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -52,23 +52,9 @@ public static class Program
|
|||||||
{
|
{
|
||||||
SetConsoleOutputMode();
|
SetConsoleOutputMode();
|
||||||
|
|
||||||
var watermark = serviceProvider.GetService<Watermark>();
|
|
||||||
// Initialize Watermark
|
|
||||||
watermark?.Initialize();
|
|
||||||
|
|
||||||
var appContext = serviceProvider.GetService<ApplicationContext>();
|
var appContext = serviceProvider.GetService<ApplicationContext>();
|
||||||
appContext?.AddValue(ContextVariableType.SERVICE_PROVIDER, serviceProvider);
|
appContext?.AddValue(ContextVariableType.SERVICE_PROVIDER, serviceProvider);
|
||||||
|
|
||||||
if (ProgramStatics.MODS())
|
|
||||||
{
|
|
||||||
// Initialize PreSptMods
|
|
||||||
var preSptLoadMods = serviceProvider.GetServices<IPreSptLoadModAsync>();
|
|
||||||
foreach (var preSptLoadMod in preSptLoadMods)
|
|
||||||
{
|
|
||||||
await preSptLoadMod.PreSptLoadAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the Built app and run it
|
// Get the Built app and run it
|
||||||
var app = serviceProvider.GetService<App>();
|
var app = serviceProvider.GetService<App>();
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class HideoutCraftQuestIdGenerator(
|
|||||||
DatabaseServer _databaseServer,
|
DatabaseServer _databaseServer,
|
||||||
LocaleService _localeService,
|
LocaleService _localeService,
|
||||||
ItemHelper _itemHelper,
|
ItemHelper _itemHelper,
|
||||||
IEnumerable<IOnLoad> _onLoadComponents
|
DatabaseImporter _databaseImporter
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
private static readonly HashSet<string> _blacklistedProductions =
|
private static readonly HashSet<string> _blacklistedProductions =
|
||||||
@@ -43,9 +43,7 @@ public class HideoutCraftQuestIdGenerator(
|
|||||||
|
|
||||||
public async Task Run()
|
public async Task Run()
|
||||||
{
|
{
|
||||||
// We only need the DB for this, other OnLoad events alter the data
|
await _databaseImporter.OnLoad();
|
||||||
var dbOnload = _onLoadComponents.FirstOrDefault(x => x.GetRoute() == "spt-database");
|
|
||||||
await dbOnload.OnLoad();
|
|
||||||
|
|
||||||
// Build up our dataset
|
// Build up our dataset
|
||||||
BuildQuestProductionList();
|
BuildQuestProductionList();
|
||||||
|
|||||||
Reference in New Issue
Block a user