Update Mods to be foldered/ own csproj/ ref dll

This commit is contained in:
CWX
2025-02-10 15:04:40 +00:00
parent ed54312f35
commit 7cd8ef9179
49 changed files with 361 additions and 121 deletions
+23
View File
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>_1Logging</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<!-- TODO: Change to Nuget Package -->
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
+36
View File
@@ -0,0 +1,36 @@
using Core.Models.External;
using Core.Models.Logging;
using Core.Models.Utils;
using SptCommon.Annotations;
namespace _1Logging;
[Injectable]
public class Logging : IPostSptLoadMod // Using this interface means our mod will run AFTER SPT has finished loading
{
// Our logger we create in the constructor below
private readonly ISptLogger<Logging> _logger;
// Constructor - Inject a 'ISptLogger' with your mods Class inside the diamond brackets
public Logging(
ISptLogger<Logging> logger
)
{
// Save the logger we're injecting into a private variable that is scoped to this class (only this class has access to it)
_logger = logger;
}
public void PostSptLoad()
{
// We can access the logger to assigned in the constructor here
_logger.Success("This is a success message");
_logger.Warning("This is a warning message");
_logger.Error("This is an error message");
_logger.Info("This is an info message");
_logger.Critical("this is a critical message");
// Logging with colors requires you to 'pass' the text color and background color
_logger.LogWithColor("This is a message with custom colors", LogTextColor.Red, LogBackgroundColor.Black);
_logger.Debug("This is a debug message that gets written to the log file, not the console");
}
}
+13
View File
@@ -0,0 +1,13 @@
{
"Name": "1Logging",
"Version": "1.0.0",
"SptVersion": "~4.0",
"LoadBefore": [],
"LoadAfter": [],
"IncompatibileMods": [],
"Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
"IsBundleMod": false,
"Author": "SPT",
"Contributors": [],
"Licence": "MIT"
}