Implement loading metadata from the assembly
This commit is contained in:
@@ -478,7 +478,7 @@ public class GameController(
|
||||
{
|
||||
if (
|
||||
fullProfile.SptData.Mods.Any(m =>
|
||||
m.Author == mod.PackageJson.Author && m.Version == mod.PackageJson.Version && m.Name == mod.PackageJson.Name
|
||||
m.Author == mod.ModMetadata.Author && m.Version == mod.ModMetadata.Version && m.Name == mod.ModMetadata.Name
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -489,10 +489,10 @@ public class GameController(
|
||||
fullProfile.SptData.Mods.Add(
|
||||
new ModDetails
|
||||
{
|
||||
Author = mod.PackageJson.Author,
|
||||
Version = mod.PackageJson.Version,
|
||||
Name = mod.PackageJson.Name,
|
||||
Url = mod.PackageJson.Url,
|
||||
Author = mod.ModMetadata.Author,
|
||||
Version = mod.ModMetadata.Version,
|
||||
Name = mod.ModMetadata.Name,
|
||||
Url = mod.ModMetadata.Url,
|
||||
DateAdded = _timeUtil.GetTimeStamp()
|
||||
}
|
||||
);
|
||||
|
||||
@@ -240,14 +240,14 @@ public class LauncherController(
|
||||
/// Get the mods the server has currently loaded
|
||||
/// </summary>
|
||||
/// <returns>Dictionary of mod name and mod details</returns>
|
||||
public Dictionary<string, PackageJsonData> GetLoadedServerMods()
|
||||
public Dictionary<string, AbstractModMetadata> GetLoadedServerMods()
|
||||
{
|
||||
var mods = _applicationContext?.GetLatestValue(ContextVariableType.LOADED_MOD_ASSEMBLIES).GetValue<List<SptMod>>();
|
||||
var result = new Dictionary<string, PackageJsonData>();
|
||||
var result = new Dictionary<string, AbstractModMetadata>();
|
||||
|
||||
foreach (var sptMod in mods)
|
||||
{
|
||||
result.Add(sptMod.PackageJson.Name, sptMod.PackageJson);
|
||||
result.Add(sptMod.ModMetadata.Name, sptMod.ModMetadata);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -156,14 +156,14 @@ public class LauncherV2Controller(
|
||||
/// Gets the Servers loaded mods.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, PackageJsonData> LoadedMods()
|
||||
public Dictionary<string, AbstractModMetadata> LoadedMods()
|
||||
{
|
||||
var mods = _applicationContext?.GetLatestValue(ContextVariableType.LOADED_MOD_ASSEMBLIES).GetValue<List<SptMod>>();
|
||||
var result = new Dictionary<string, PackageJsonData>();
|
||||
var result = new Dictionary<string, AbstractModMetadata>();
|
||||
|
||||
foreach (var sptMod in mods)
|
||||
{
|
||||
result.Add(sptMod.PackageJson.Name, sptMod.PackageJson);
|
||||
result.Add(sptMod.ModMetadata.Name, sptMod.ModMetadata);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace SPTarkov.Server.Core.Models.Spt.Launcher;
|
||||
|
||||
public class LauncherV2ModsResponse : IRequestData
|
||||
{
|
||||
public required Dictionary<string, PackageJsonData> Response
|
||||
public required Dictionary<string, AbstractModMetadata> Response
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
namespace SPTarkov.Server.Core.Models.Spt.Mod;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of metadata used to determine things such as author, version,
|
||||
/// pre-defined load order and incompatibilities. This record is required to be overriden by all mods.
|
||||
/// All properties must be overridden. For properties, that you don't need, just assign null.
|
||||
/// </summary>
|
||||
public abstract record AbstractModMetadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of this mod
|
||||
/// </summary>
|
||||
public abstract string? Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Your username
|
||||
/// </summary>
|
||||
public abstract string? Author
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// People who have contributed to this mod
|
||||
/// </summary>
|
||||
public abstract List<string>? Contributors
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Semantic version of this mod, this uses the semver standard
|
||||
/// </summary>
|
||||
public abstract string? Version
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SPT version this mod was built for
|
||||
/// </summary>
|
||||
public abstract string? SptVersion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of mods this mod should load before
|
||||
/// </summary>
|
||||
public abstract List<string>? LoadBefore
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of mods this mod should load after
|
||||
/// </summary>
|
||||
public abstract List<string>? LoadAfter
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List of mods not compatible with this mod
|
||||
/// </summary>
|
||||
public abstract List<string>? Incompatibilities
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of mods this mod depends on.
|
||||
///
|
||||
/// Mod dependency is the key, version is the value
|
||||
/// </summary>
|
||||
public abstract Dictionary<string, string>? ModDependencies
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Link to this mod's mod page, or GitHub page
|
||||
/// </summary>
|
||||
public abstract string? Url
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does this mod load bundles
|
||||
/// </summary>
|
||||
public abstract bool? IsBundleMod
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of the license this mod uses
|
||||
/// </summary>
|
||||
public abstract string? Licence
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SPTarkov.Server.Core.Models.Spt.Mod;
|
||||
|
||||
public record PackageJsonData
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string? Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("author")]
|
||||
public string? Author
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("contributors")]
|
||||
public List<string>? Contributors
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("version")]
|
||||
public string? Version
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("sptVersion")]
|
||||
public string? SptVersion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("loadBefore")]
|
||||
public List<string>? LoadBefore
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("loadAfter")]
|
||||
public List<string>? LoadAfter
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("incompatibilities")]
|
||||
public List<string>? Incompatibilities
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("modDependencies")]
|
||||
public Dictionary<string, string>? ModDependencies
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string? Url
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("isBundleMod")]
|
||||
public bool? IsBundleMod
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("licence")]
|
||||
public string? Licence
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ public class SptMod
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("packageJson")]
|
||||
public PackageJsonData? PackageJson
|
||||
[JsonPropertyName("modMetadata")]
|
||||
public AbstractModMetadata? ModMetadata
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
||||
@@ -316,7 +316,7 @@ public class BackupService
|
||||
|
||||
foreach (var mod in mods)
|
||||
{
|
||||
result.Add($"{mod.PackageJson.Author} - {mod.PackageJson.Version ?? ""}");
|
||||
result.Add($"{mod.ModMetadata.Author} - {mod.ModMetadata.Version ?? ""}");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user