-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInstantInsurance.cs
More file actions
57 lines (50 loc) · 1.63 KB
/
Copy pathInstantInsurance.cs
File metadata and controls
57 lines (50 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Reflection;
using InstantInsurance.Configuration;
using InstantInsurance.Utils;
using SPTarkov.DI.Annotations;
using SPTarkov.Reflection.Patching;
using SPTarkov.Server.Core.DI;
using SPTarkov.Server.Core.Helpers;
using SPTarkov.Server.Core.Models.Utils;
using SPTarkov.Server.Core.Utils;
namespace InstantInsurance;
[Injectable(TypePriority = OnLoadOrder.PreSptModLoader + 1)]
public class InstantInsurance(
ISptLogger<InstantInsurance> logger,
ModHelper modHelper,
JsonUtil jsonUtil,
ItemHelper itemHelper,
PatchManager patchManager
) : IOnLoad
{
public static ModConfig ModConfig { get; private set; } = new();
public Task OnLoad()
{
LoggerUtil.Logger = logger;
LoggerUtil.ItemHelper = itemHelper;
var modPath = modHelper.GetAbsolutePathToModFolder(Assembly.GetExecutingAssembly());
var configPath = Path.Combine(modPath, "config", "config.json");
LoadConfig(configPath);
patchManager.PatcherName = "FoldablesPatcher";
patchManager.AutoPatch = true;
patchManager.EnablePatches();
LoggerUtil.Success("loaded successfully!");
return Task.CompletedTask;
}
private void LoadConfig(string path)
{
try
{
if (!File.Exists(path))
{
throw new FileNotFoundException(path);
}
ModConfig = jsonUtil.DeserializeFromFile<ModConfig>(path);
}
catch (Exception ex)
{
LoggerUtil.Error(ex.ToString());
LoggerUtil.Error("Configuration load error, using default values. Misconfigured config.json? ");
}
}
}