From 4d0eb4d4f39eab9991e0629f1b99f956969a7c1d Mon Sep 17 00:00:00 2001 From: Cj <161484149+CJ-SPT@users.noreply.github.com> Date: Sat, 9 Aug 2025 16:40:25 -0400 Subject: [PATCH] Change to using builtin `SemVer` type for `AbstractModMetadata` and `ProgramStatistics.Generated` (#536) * Change to using SemVer builtin type * Remove SptVersion from config, remove redundant .ToString() * Update test mod, fix watermark string conversion --- Libraries/SPTarkov.Common/Semver/ISemVer.cs | 20 ++++---- .../SemanticVersioningSemVer.cs | 25 +++++----- .../SPT_Data/configs/core.json | 1 - .../SPT_Data/database/locales/server/ar.json | 1 - .../SPT_Data/database/locales/server/cs.json | 1 - .../SPT_Data/database/locales/server/de.json | 1 - .../SPT_Data/database/locales/server/el.json | 1 - .../SPT_Data/database/locales/server/en.json | 1 - .../database/locales/server/es-es.json | 1 - .../SPT_Data/database/locales/server/fr.json | 1 - .../SPT_Data/database/locales/server/hu.json | 1 - .../SPT_Data/database/locales/server/id.json | 1 - .../SPT_Data/database/locales/server/it.json | 1 - .../SPT_Data/database/locales/server/ja.json | 1 - .../SPT_Data/database/locales/server/ko.json | 1 - .../SPT_Data/database/locales/server/nl.json | 1 - .../SPT_Data/database/locales/server/no.json | 1 - .../SPT_Data/database/locales/server/pl.json | 1 - .../database/locales/server/pt-br.json | 1 - .../database/locales/server/pt-pt.json | 1 - .../SPT_Data/database/locales/server/ru.json | 1 - .../database/locales/server/sv-se.json | 1 - .../SPT_Data/database/locales/server/tr.json | 1 - .../SPT_Data/database/locales/server/uk.json | 1 - .../database/locales/server/zh-cn.json | 1 - .../Controllers/GameController.cs | 6 +-- .../Models/Spt/Config/CoreConfig.cs | 3 -- .../Models/Spt/Mod/AbstractModMetadata.cs | 22 +++++--- .../SPTarkov.Server.Core.csproj | 2 +- Libraries/SPTarkov.Server.Core/Utils/App.cs | 2 +- .../Utils/ProgramStatics.cs | 3 +- .../SPTarkov.Server.Core/Utils/Watermark.cs | 50 +++++++++---------- SPTarkov.Server/Modding/ModDllLoader.cs | 4 +- SPTarkov.Server/Modding/ModValidator.cs | 26 +++------- Testing/TestMod/TestMod.cs | 7 +-- 35 files changed, 85 insertions(+), 108 deletions(-) diff --git a/Libraries/SPTarkov.Common/Semver/ISemVer.cs b/Libraries/SPTarkov.Common/Semver/ISemVer.cs index 4ab78aed..42d207c2 100644 --- a/Libraries/SPTarkov.Common/Semver/ISemVer.cs +++ b/Libraries/SPTarkov.Common/Semver/ISemVer.cs @@ -1,13 +1,15 @@ -namespace SPTarkov.Common.Semver; +using Version = SemanticVersioning.Version; + +namespace SPTarkov.Common.Semver; public interface ISemVer { - string MaxSatisfying(List versions); - string MaxSatisfying(IEnumerable versions); - string MaxSatisfying(string version, List versions); - string MaxSatisfying(string version, IEnumerable versions); - bool Satisfies(string version, string testVersion); - bool AnySatisfies(string version, List testVersions); - bool IsValid(string version); - bool IsValidRange(string version); + string MaxSatisfying(List versions); + string MaxSatisfying(IEnumerable versions); + string MaxSatisfying(string version, List versions); + string MaxSatisfying(string version, IEnumerable versions); + bool Satisfies(Version version, Version testVersion); + bool AnySatisfies(Version version, List testVersions); + bool IsValid(Version version); + bool IsValidRange(Version version); } diff --git a/Libraries/SPTarkov.Common/Semver/Implementations/SemanticVersioningSemVer.cs b/Libraries/SPTarkov.Common/Semver/Implementations/SemanticVersioningSemVer.cs index 4ad00e60..9709aeae 100644 --- a/Libraries/SPTarkov.Common/Semver/Implementations/SemanticVersioningSemVer.cs +++ b/Libraries/SPTarkov.Common/Semver/Implementations/SemanticVersioningSemVer.cs @@ -5,43 +5,44 @@ namespace SPTarkov.Common.Semver.Implementations; public class SemanticVersioningSemVer : ISemVer { - public string MaxSatisfying(List versions) + public string MaxSatisfying(List versions) { return MaxSatisfying(versions.AsEnumerable()); } - public string MaxSatisfying(IEnumerable versions) + public string MaxSatisfying(IEnumerable versions) { return MaxSatisfying("*", versions); } - public string MaxSatisfying(string version, List versions) + public string MaxSatisfying(string version, List versions) { return MaxSatisfying(version, versions.AsEnumerable()); } - public string MaxSatisfying(string version, IEnumerable versions) + public string MaxSatisfying(string version, IEnumerable versions) { - return Range.MaxSatisfying(version, versions, true); + var versionRanges = versions.Select(versionInner => versionInner.ToString()); + return Range.MaxSatisfying(version, versionRanges, true); } - public bool Satisfies(string version, string testVersion) + public bool Satisfies(Version version, Version testVersion) { - return Range.IsSatisfied(testVersion, version, true); + return Range.IsSatisfied(testVersion.ToString(), version.ToString(), true); } - public bool AnySatisfies(string version, List testVersions) + public bool AnySatisfies(Version version, List testVersions) { return testVersions.Any(v => Satisfies(version, v)); } - public bool IsValid(string version) + public bool IsValid(Version version) { - return Version.TryParse(version, out _); + return Version.TryParse(version.ToString(), out _); } - public bool IsValidRange(string version) + public bool IsValidRange(Version version) { - return Range.TryParse(version, out _); + return Range.TryParse(version.ToString(), out _); } } diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/core.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/core.json index b8669e37..a7a23c6a 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/core.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/core.json @@ -1,5 +1,4 @@ { - "sptVersion": "4.0.0", "projectName": "SPT", "compatibleTarkovVersion": "0.16.0.38114", "serverName": "SPT Server", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ar.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ar.json index 75e4ba9e..c67cc14c 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ar.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ar.json @@ -133,7 +133,6 @@ "modloader-error_parsing_mod_load_order": "حدث خطأ أثناء تحليل ترتيب المودات.\n\n\n\n\n\n\n", "modloader-incompatibilities_not_string_array": "يجب أن يكون Mod %s package.json الخاصية 'incompatibilities' مصفوفة سلاسل", "modloader-incompatible_mod_found": "المود {{author}}-{{name}} غير متوافق مع {{incompatibleModName}}.\n\n\n\n\n\n\n", - "modloader-invalid_version_property": "ملف package.json للمود %s يحتوي على سلسلة إصدار غير صالحة.\n\n\n\n\n\n\n", "modloader-is_client_mod": "المود (%s) هو مود خاص بالعميل ويجب وضعه في المجلد التالي: /spt/bepinex/plugins\n\n\n\n\n\n\n", "modloader-load_order_conflict": "{{modOneName}} و {{modTwoName}} لديهما متطلبات تعارض في ترتيب التحميل، لا يمكن للخادم أن يبدأ حتى يتم حل هذا وسيتم إيقاف التشغيل.\n\n\n\n\n\n\n", "modloader-loaded_mod": "الإضافة: الإصدار {{name}}: {{version}} من قبل {{author}} تم تحميلها", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/cs.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/cs.json index 093c1579..eb5d008f 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/cs.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/cs.json @@ -207,7 +207,6 @@ "modloader-incompatibilities_not_string_array": "Vlastnost módu %s package.json 'incompatibility' by měla být pole pro řetězec", "modloader-incompatible_mod_found": "Modifikace {{author}}-{{name}} je nekompatibilní s {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "Mod: %s obsahuje neplatný semver string v sptVersion field. Příklady platných hodnot: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "Mód %s package.json obsahuje neplatnou verzi řetězce", "modloader-is_client_mod": "Mód (%s) je klientský mód a měl by být umístěn v následující složce: /spt/bepinex/plugins", "modloader-is-old-js-mod": "Mod (%s) je určen pro verzi serveru před 4.0.0. Najdi prosím odpovídající verzi nebo počkej na aktualizaci.", "modloader-load_order_conflict": "`{{modOneName}}` a `{{modTwoName}}` mají protichůdné požadavky na pořadí načítání, server není schopen spustit, dokud nebude opraven a nebude vypnut", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/de.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/de.json index 70c00c47..ed7a8476 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/de.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/de.json @@ -201,7 +201,6 @@ "modloader-incompatibilities_not_string_array": "Die Mod %s package.json Eigenschaft 'Inkompatibilitäten' sollte ein String-Array sein", "modloader-incompatible_mod_found": "Mod {{author}}-{{name}} ist nicht kompatibel mit {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "Mod: %s enthält eine ungültige ´semver´ Zeichenkette im ´sptversions´ Feld. Beispiele für gültige Werte: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "Mod %s package.json enthält eine ungültige Versionszeichenfolge", "modloader-is_client_mod": "Mod (%s) ist ein Client-Mod und sollte im folgenden Ordner abgelegt werden: /spt/bepinex/plugins", "modloader-load_order_conflict": "'{{modOneName}}' und '{{modTwoName}}' haben widersprüchliche Anforderungen an die Ladereihenfolge. Der Server kann erst gestartet werden, wenn dies behoben ist, und wird heruntergefahren", "modloader-loaded_mod": "Mod: {{name}} Version: {{version}} von: {{author}} geladen", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/el.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/el.json index d6c9988f..2ce70cb6 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/el.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/el.json @@ -207,7 +207,6 @@ "modloader-incompatibilities_not_string_array": "Στο πρόσθετο %s package.json η ιδιότητα \"ασυμβατότητες\" θα πρέπει να είναι μία συστοιχία συμβολοσειρών", "modloader-incompatible_mod_found": "Το πρόσθετο {{author}}-{{name}} δεν είναι συμβατό με το {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "Το πρόσθετο %s περιέχει μία μη έγκυρη semver συμβολοσειρά στο πεδίο sptVersion. Παραδείγματα έγκυρων τιμών: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "Το πρόσθετο %s package.json περιέχει μια μη έγκυρη έκδοση συμβολοσειράς", "modloader-is_client_mod": "Το πρόσθετο (%s) είναι ένα πρόσθετο πελάτη και θα πρέπει να τοποθετηθεί στον ακόλουθο φάκελο: /spt/bepinex/plugins", "modloader-is-old-js-mod": "Το Mod (%s) είναι μια λειτουργία διακομιστή προ της έκδοσης 4.0.0. Παρακαλώ βρείτε την κατάλληλη έκδοση ή περιμένετε για μια ενημέρωση.", "modloader-load_order_conflict": "Τα `{{modOneName}}` και `{{modTwoName}}` έχουν αντικρουόμενες απαιτήσεις σειράς φόρτωσης, ο διακομιστής δεν μπορεί να ξεκινήσει μέχρι να αυτό διορθωθεί και θα τερματιστεί", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/en.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/en.json index 952741a1..0352e0b8 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/en.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/en.json @@ -209,7 +209,6 @@ "modloader-incompatibilities_not_string_array": "Mod %s package.json property 'incompatibilities' should be a string array", "modloader-incompatible_mod_found": "Mod: {{author}}-{{name}} is incompatible with: {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "Mod: %s contains an invalid semver string in the sptVersion field. Examples of valid values: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "Mod: %s package.json contains an invalid version string", "modloader-is_client_mod": "Mod (%s) is a client mod and should be placed in the following folder: /spt/bepinex/plugins", "modloader-is-old-js-mod": "Mod (%s) is a pre-4.0.0 server mod. Please find the appropriate version or wait for an update.", "modloader-load_order_conflict": "`{{modOneName}}` and `{{modTwoName}}` have conflicting load order requirements, the server is unable to start until this is fixed and will shut down", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/es-es.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/es-es.json index 6b2a143f..b80869bf 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/es-es.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/es-es.json @@ -202,7 +202,6 @@ "modloader-incompatibilities_not_string_array": "La propiedad 'incompatibilities' de la modificacion %s package.json deberia ser un arreglo de string", "modloader-incompatible_mod_found": "La modificación {{author}}-{{name}} no es compatible con {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "Mod %s contiene una cadena semver inválida en el campo sptVersion. Ejemplos de valores válidos: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "La modificacion %s package.json contiene un valor invalido de version", "modloader-is_client_mod": "La modificación (%s) es de cliente, esta debería ponerse en el directorio: /spt/bepinex/plugins", "modloader-is-old-js-mod": "El Mod (%s) es para una versión anterior a la 4.0.0 del servidor. Por favor encuentre la versión adecuada o espere a una actualización.", "modloader-load_order_conflict": "`{{modOneName}}` y `{{modTwoName}}` tienen un conflicto de requerimientos en orden de carga, el servidor en incapaz de iniciarse asta que se solucione y se apagara", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/fr.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/fr.json index 2910160c..3737eb81 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/fr.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/fr.json @@ -207,7 +207,6 @@ "modloader-incompatibilities_not_string_array": "la propriété 'incompatibilities' dans le fichier package.json du mod %s doit être un tableau de chaînes de caractères", "modloader-incompatible_mod_found": "Le mod {{author}}-{{name}} est incompatible avec {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "Le mod %s contient une chaîne de caractères semver invalide dans le champ sptVersion. Exemples de chaînes correctes: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "Le mod %s package.json contient une chaîne de version invalide", "modloader-is_client_mod": "Le mod (%s) est un mod client et doit être placé dans le dossier suivant : /spt/bepinex/plugins", "modloader-is-old-js-mod": "Mod (%s) est un mod server pour versions antérieures à 4.0.0. Trouvez une version appropriée ou attendez que le mod soit à jour.", "modloader-load_order_conflict": "`{{modOneName}}` et `{{modTwoName}}` ont des ordres de chargement en conflit, le serveur ne peut pas démarrer tant que ceci n'est pas corrigé et s'arrêtera", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/hu.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/hu.json index de69bda5..ea0846ad 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/hu.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/hu.json @@ -174,7 +174,6 @@ "modloader-error_parsing_mod_load_order": "Hiba a mod betöltési sorrendjének elemzésekor", "modloader-incompatibilities_not_string_array": "A Mod %s package.json „incompatibilities” tulajdonságának karakterlánc tömbnek kell lennie", "modloader-incompatible_mod_found": "{{author}}-{{name}} mod nem kompatibilis a következővel: {{incompatibleModName}}", - "modloader-invalid_version_property": "A(z) %s mod package.json fájlja érvénytelen verziójú karakterláncot tartalmaz", "modloader-is_client_mod": "A következő mod (%s) egy kliens mod és a következő mappába kell helyezni: /spt/bepinex/plugins", "modloader-load_order_conflict": "`{{modOneName}}` és`{{modTwoName}}` modoknak ellentmondásos betöltési sorrend követelményei vannak, a szerver nem tud elindulni amíg ezt nem javítják, és leáll", "modloader-loaded_mod": "Mod: {{name}} verzió: {{version}} by: {{author}} betöltve", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/id.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/id.json index 531b99b9..a03d1cf2 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/id.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/id.json @@ -183,7 +183,6 @@ "modloader-error_parsing_mod_load_order": "Permasalahan dalam penguraian urutan pemuatan mod", "modloader-incompatibilities_not_string_array": "Mod %s data package.json 'incompatibilities' harus string array", "modloader-incompatible_mod_found": "Mod {{author}}-{{name}} tidak compatibel dengan {{incompatibleModName}}", - "modloader-invalid_version_property": "Mod %s package.json memiliki versi string yang invalid", "modloader-is_client_mod": "Mod (%s) merupakan mod client dan harus dipasang dalam folder: /spt/bepinex/plugins", "modloader-load_order_conflict": "'{{modOneName}}' dan '{{modTwoName}}' memiliki urutan pemuatan yang bertentangan, server tidak bisa mulai hingga masalah ini diperbaiki dan akan dimatikan", "modloader-loaded_mod": "Mod: {{name}} versi: {{version}} oleh: {{author}} dimuat", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/it.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/it.json index 4b10b6a9..3de46051 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/it.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/it.json @@ -207,7 +207,6 @@ "modloader-incompatibilities_not_string_array": "Le proprietà 'incompatibilities' della mod %s, nel package.json, devono essere uno string array", "modloader-incompatible_mod_found": "La mod {{author}}-{{name}} è incompatibile con {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "La mod %s contiene una stringa semver non valida nel campo akiVersion. Esempi di valori validi: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "Il package.json della Mod %s contiene una stringa 'version' non valida", "modloader-is_client_mod": "La mod (%s) è una mod del client e dovrebbe essere posizionata nella seguente cartella: /spt/bepinex/plugins", "modloader-is-old-js-mod": "La Mod (%s) è una server mod pre-4.0.0. Si prega di utilizzare la versione appropriata della mod o aspettare che venga aggiornata.", "modloader-load_order_conflict": "Il server si spegnerà perché i requisiti dell'ordine di carico per `{{modOneName}}` e `{{modTwoName}}` sono in conflitto. Sistemali prima di avviare", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ja.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ja.json index 2f6ebe6a..8eaeca0a 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ja.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ja.json @@ -189,7 +189,6 @@ "modloader-incompatibilities_not_string_array": "Mod %s package.json プロパティ '非互換性' は文字列配列でなければなりません。", "modloader-incompatible_mod_found": "Mod {{author}}-{{name}} is incompatible with {{incompatibleModName}}。", "modloader-invalid_sptVersion_field": "Mod %s の sptVersion フィールドで不正な Semver 文字列が使用されています。正しい例はこちら: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "モッド %s のpackage.jsonにで不正確なバージョン文字列が使用されています。", "modloader-is_client_mod": "モッド %s はクライアントタイプのモッドです。正しいインストール先はこちら: /spt/bepinex/plugins", "modloader-is-old-js-mod": "Mod %s は 4.0.0 より前のバージョン向けのModです。適切なバージョンを見つけるか、アップデートされるまでお待ちください。", "modloader-load_order_conflict": "`{{modOneName}}` と `{{modTwoName}}` のロードの順序の条件が競合しています。 これが修正されるまでサーバーを起動できずシャットダウンします", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ko.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ko.json index 63080a5c..20269f2c 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ko.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ko.json @@ -207,7 +207,6 @@ "modloader-incompatibilities_not_string_array": "모드 %s 의 package.json 파일 중 'incompatibilities' 속성은 문자 배열 타입이어야 합니다", "modloader-incompatible_mod_found": "모드 {{author}}-{{name}} 는 {{incompatibleModName}} 모드와 호환되지 않습니다", "modloader-invalid_sptVersion_field": "모드 %s 가 sptVersion 필드에 부적합한 semver 스트링 값을 보유하고 있습니다. 올바른 값들의 예시: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "모드 %s 의 package.json 은(는) 잘못된 version 문자열을 포함하고 있습니다", "modloader-is_client_mod": "모드 (%s) 는 클라이언트 모드로 '/spt/bepinex/plugins' 폴더에 위치해야 합니다", "modloader-is-old-js-mod": "%s 모드는 4.0 이전 버전용 서버모드입니다. 올바른 버전을 찾아 다시 설치하거나 모드가 업데이트 되기를 기다리세요.", "modloader-load_order_conflict": "`{{modOneName}}` 과 `{{modTwoName}}` 는 요구되는 모드 순서가 서로 충돌됩니다, 이 문제를 해결하기 전까지 서버를 실행할 수 없으며 서버가 종료됩니다", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/nl.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/nl.json index f33e79b7..7da76154 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/nl.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/nl.json @@ -207,7 +207,6 @@ "modloader-incompatibilities_not_string_array": "Mod %s package.json property 'incompatibilities' moet een string array zijn", "modloader-incompatible_mod_found": "Mod {{author}}-{{name}} is niet compatibel met {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "Mod: %s bevat een ongeldige semver string in het sptVersion veld. Voorbeelden van geldige waarden: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "Mod %s package.json bevat een invalide versie string", "modloader-is_client_mod": "Mod (%s) is een client mod en moet in de volgende map geplaatst worden: /spt/bepinex/plugins", "modloader-is-old-js-mod": "Mod (%s) is een pre-4.0.0 server mod. Zoek de juiste versie of wacht op een update.", "modloader-load_order_conflict": "`{{modOneName}}` en`{{modTwoName}}` hebben een conflict in de volgorde van laden, de server kan niet opstarten tot het conflict is opgelost. De server word gestopt", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/no.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/no.json index 3596a356..19f68c4b 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/no.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/no.json @@ -129,7 +129,6 @@ "modloader-error_parsing_mod_load_order": "Feil under parsing av mod lastings rekkefølge", "modloader-incompatibilities_not_string_array": "Mod %s package.json egenskaps 'inkompatibiliteter' bør være en streng array", "modloader-incompatible_mod_found": "Mod {{author}}–{{name}} er inkompatibel med {{incompatibleModName}}", - "modloader-invalid_version_property": "Mod %s pakke.json inneholder en ugyldig versjonstreng", "modloader-is_client_mod": "Mod (%s) er en klientmod og skal plasseres i følgende mappe: /spt/bepinex/plugins", "modloader-load_order_conflict": "`{{modOneName}}` og `{{modTwoName}}` har motstridende krav for innlastingsrekkefølge. serveren kan ikke starte før dette er fikset og vil slå seg av", "modloader-loaded_mod": "Mod: {{name}} versjon: {{version}} av: {{author}} lastet inn", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pl.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pl.json index b0521411..b41a7ed5 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pl.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pl.json @@ -207,7 +207,6 @@ "modloader-incompatibilities_not_string_array": "Mod %s właściwość package.json 'incompatibilities' powinna być tabelą string", "modloader-incompatible_mod_found": "Mod {{author}}-{{name}} jest niezgodny z {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "Mod %s zawiera nieprawidłowy string semver w polu sptVersion. Przykłady prawidłowych wartości: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "Mod %s package.json zawiera nieprawidłowy string wersji", "modloader-is_client_mod": "Mod (%s) jest modem klienta i powinien zostać umieszczony w następującym folderze: /spt/bepinex/plugins", "modloader-is-old-js-mod": "Modyfikacja (%s) jest modem serwera sprzed wersji 4.0.0. Znajdź odpowiednią wersję lub poczekaj na aktualizację.", "modloader-load_order_conflict": "`{{modOneName}}` and `{{modTwoName}}` mają sprzeczne wymagania dotyczące kolejności ładowania, serwer nie może się uruchomić, dopóki błąd występuje i zostanie teraz wyłączony", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pt-br.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pt-br.json index c785bc30..7eb81d7c 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pt-br.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pt-br.json @@ -201,7 +201,6 @@ "modloader-incompatibilities_not_string_array": "A propriedade 'incompatibilities' do arquivo package.json do mod %s deveria ser uma matriz de strings", "modloader-incompatible_mod_found": "Mod {{author}}-{{name}} é incompatível com {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "O mod %s contém uma string semver inválida no campo sptVersion. Exemplos de valores válidos: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "Mod %s package.json contém uma string de versão inválida", "modloader-is_client_mod": "O mod (%s) é um mod de cliente e deve ser colocado na seguinte pasta: /spt/bepinex/plugins", "modloader-is-old-js-mod": "O mod (%s) foi feito para servidores pré-4.0.0. Por favor, busque a versão apropriada ou espere por uma atualização.", "modloader-load_order_conflict": "{{modOneName}} e {{modTwoName}} têm requisitos de ordem de carregamento conflitantes. O servidor não conseguirá iniciar até que isso seja corrigido e será encerrado", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pt-pt.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pt-pt.json index 6e002a43..e9366a5e 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pt-pt.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/pt-pt.json @@ -134,7 +134,6 @@ "modloader-error_parsing_mod_load_order": "Erro ao analisar ordem de carregamento de mods", "modloader-incompatibilities_not_string_array": "A propriedade 'incompatibilities' no package.json do mod %s deve ser um array de strings", "modloader-incompatible_mod_found": "Mod {{author}}-{{name}} é incompatível com {{incompatibleModName}}", - "modloader-invalid_version_property": "O package.json do Mod %s contém uma string de versão inválida", "modloader-is_client_mod": "Mod (%s) é um mod de cliente e deve ser colocado na seguinte pasta: /spt/bepinex/plugins", "modloader-load_order_conflict": "O '{{modOneName}}' e '{{modTwoName}}' têm requisitos de ordem de carregamento que entram em conflito. O servidor é incapaz de iniciar e será desligado até isto ser corrigido", "modloader-loaded_mod": "Mod: {{name}} versão: {{version}} por: {{author}} carregado", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ru.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ru.json index 1eed1e1f..52621ed9 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ru.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/ru.json @@ -207,7 +207,6 @@ "modloader-incompatibilities_not_string_array": "В файле package.json мода %s свойство 'incompatibilities' должно быть массивом строк", "modloader-incompatible_mod_found": "Мод {{author}}-{{name}} не совместим с модом {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "В поле sptVersion мода %s содержится некорректная семвер-строка. См. примеры корректных значений: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "В моде %s package.json содержит недопустимую строку версии", "modloader-is_client_mod": "Мод (%s) является модом для клиента и должен находиться в следующей папке: /spt/bepinex/plugins", "modloader-is-old-js-mod": "Мод (%s) - это серверный мод, выпущенный до версии 4.0.0. Пожалуйста, найдите подходящую версию или дождитесь обновления.", "modloader-load_order_conflict": "`{{modOneName}}` и `{{modTwoName}}` имеют конфликтующие требования к порядку загрузки, сервер не запустится и закроется, пока это не будет исправлено", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/sv-se.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/sv-se.json index f871128e..d228fea0 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/sv-se.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/sv-se.json @@ -141,7 +141,6 @@ "modloader-error_parsing_mod_load_order": "Fel vid analys av modladdningsordning", "modloader-incompatibilities_not_string_array": "Mod %s package.json-egenskapen 'incompatibilities' bör vara en strängmatris", "modloader-incompatible_mod_found": "Mod {{author}}-{{name}} är inkompatibel med {{incompatibleModName}}", - "modloader-invalid_version_property": "Mod %s package.json innehåller en ogiltig versionssträng", "modloader-is_client_mod": "Mod (%s) är en klientmod och bör placeras i följande mapp: /spt/bepinex/plugins", "modloader-load_order_conflict": "`{{modOneName}}` och `{{modTwoName}}` har motstridiga laddordningskrav, servern kan inte starta förrän detta är fixat och kommer att stängas ner", "modloader-loaded_mod": "Mod {{name}} version{{version}} av {{author}} har laddats", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/tr.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/tr.json index 906f67d8..78122f67 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/tr.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/tr.json @@ -207,7 +207,6 @@ "modloader-incompatibilities_not_string_array": "Mod %s package.json özelliği 'incompatibilities' bir dize dizisi olmalıdır", "modloader-incompatible_mod_found": "Mod {{author}}-{{name}}, {{incompatibleModName}} ile uyumsuz", "modloader-invalid_sptVersion_field": "Mod %s, sptVersion alanında geçersiz bir semver dizesi içeriyor. Geçerli değerlere örnekler: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "Mod %s package.json geçersiz bir sürüm dizesi içeriyor", "modloader-is_client_mod": "Mod (%s) bir istemci modudur ve aşağıdaki klasöre yerleştirilmelidir: /spt/bepinex/plugins", "modloader-is-old-js-mod": "Mod (%s) 4.0.0 öncesi bir sunucu modudur. Lütfen uygun sürümü bulun veya bir güncelleme bekleyin.", "modloader-load_order_conflict": "`{{modOneName}}` ve `{{modTwoName}}` yük sırası gereksinimleri çakışıyor, bu sorun giderilene kadar sunucu başlayamıyor ve kapanacak", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/uk.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/uk.json index 9333d013..bc02b6c9 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/uk.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/uk.json @@ -200,7 +200,6 @@ "modloader-incompatibilities_not_string_array": "У файлі package.json мода %s властивість 'incompatibilities' має бути масивом рядків", "modloader-incompatible_mod_found": "Мод:{{author}}-{{name}} не сумісний з:{{incompatibleModName}}", "modloader-invalid_sptVersion_field": "У полі sptVersion мода %s міститься некоректний семвер рядок. Див. приклади коректних значень: https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "У моді %s package.json містить неприпустимий рядок версії", "modloader-is_client_mod": "Мод (%s) є модом для клієнта і повинен знаходитися в такій папці: /spt/bepinex/plugins", "modloader-load_order_conflict": "`{{modOneName}}` і `{{modTwoName}}` мають конфліктуючи вимоги до порядку завантаження, сервер не запуститься і закриється, поки це не буде виправлено", "modloader-loaded_mod": "Мод {{name}} версії {{version}} от {{author}} завантажено", diff --git a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/zh-cn.json b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/zh-cn.json index 6cf94ff2..b1feb0be 100644 --- a/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/zh-cn.json +++ b/Libraries/SPTarkov.Server.Assets/SPT_Data/database/locales/server/zh-cn.json @@ -207,7 +207,6 @@ "modloader-incompatibilities_not_string_array": "模组%s package.json属性“incompatibilities”应该是字符串数组", "modloader-incompatible_mod_found": "模组 {{author}}-{{name}} 不兼容 {{incompatibleModName}}", "modloader-invalid_sptVersion_field": "模组 %s 在sptVersion字段中包含无效的semver字符串。有效值示例:https://github.com/npm/node-semver#versions", - "modloader-invalid_version_property": "模组 %s package.json包含无效的版本字符串", "modloader-is_client_mod": "模组 %s 是一个客户端模组,应该被放置在这个文件夹:/spt/bepinex/plugins", "modloader-is-old-js-mod": "模组 (%s) 是 4.0.0 版本前的服务端模组,请使用对应版本的客户端或等待该模组更新适配。", "modloader-load_order_conflict": "模组`{{modOneName}} `和`{{modTwoName}} `存在载入顺序冲突,在解决此冲突前服务器将因无法正常启动而关闭", diff --git a/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs b/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs index cec58bd7..9d0d6002 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/GameController.cs @@ -431,7 +431,7 @@ public class GameController( { if ( fullProfile.SptData.Mods.Any(m => - m.Author == mod.ModMetadata.Author && m.Version == mod.ModMetadata.Version && m.Name == mod.ModMetadata.Name + m.Author == mod.ModMetadata.Author && m.Version == mod.ModMetadata.Version.ToString() && m.Name == mod.ModMetadata.Name ) ) { @@ -443,7 +443,7 @@ public class GameController( new ModDetails { Author = mod.ModMetadata.Author, - Version = mod.ModMetadata.Version, + Version = mod.ModMetadata.Version.ToString(), Name = mod.ModMetadata.Name, Url = mod.ModMetadata.Url, DateAdded = timeUtil.GetTimeStamp(), @@ -496,7 +496,7 @@ public class GameController( if (logger.IsLogEnabled(LogLevel.Debug)) { logger.Debug($"Profile made with: {fullProfile.SptData?.Version}"); - logger.Debug($"Server version: {ProgramStatics.SPT_VERSION() ?? _coreConfig.SptVersion} {ProgramStatics.COMMIT()}"); + logger.Debug($"Server version: {ProgramStatics.SPT_VERSION()} {ProgramStatics.COMMIT()}"); logger.Debug($"Debug enabled: {ProgramStatics.DEBUG()}"); logger.Debug($"Mods enabled: {ProgramStatics.MODS()}"); } diff --git a/Libraries/SPTarkov.Server.Core/Models/Spt/Config/CoreConfig.cs b/Libraries/SPTarkov.Server.Core/Models/Spt/Config/CoreConfig.cs index 0c39e6eb..69374d36 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Spt/Config/CoreConfig.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Spt/Config/CoreConfig.cs @@ -9,9 +9,6 @@ public record CoreConfig : BaseConfig [JsonPropertyName("kind")] public override string Kind { get; set; } = "spt-core"; - [JsonPropertyName("sptVersion")] - public required string SptVersion { get; set; } - [JsonPropertyName("projectName")] public required string ProjectName { get; set; } diff --git a/Libraries/SPTarkov.Server.Core/Models/Spt/Mod/AbstractModMetadata.cs b/Libraries/SPTarkov.Server.Core/Models/Spt/Mod/AbstractModMetadata.cs index c14ec81a..06a3c3ac 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Spt/Mod/AbstractModMetadata.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Spt/Mod/AbstractModMetadata.cs @@ -1,4 +1,6 @@ -namespace SPTarkov.Server.Core.Models.Spt.Mod; +using Version = SemanticVersioning.Version; + +namespace SPTarkov.Server.Core.Models.Spt.Mod; /// /// Represents a collection of metadata used to determine things such as author, version, @@ -31,14 +33,22 @@ public abstract record AbstractModMetadata public abstract List? Contributors { get; set; } /// - /// Semantic version of this mod, this uses the semver standard + /// Semantic version of this mod, this uses the semver standard: https://semver.org/ + ///

+ /// Version = new Version("1.0.0"); is valid + ///
+ /// Version = new Version("1.0.0.0"); is not ///
- public abstract string Version { get; init; } + public abstract Version Version { get; } /// - /// SPT version this mod was built for + /// SPT version this mod was built for, this uses the semver standard: https://semver.org/ + ///

+ /// Version = new Version("4.0.0"); is valid + ///
+ /// Version = new Version("4.0.0.0"); is not ///
- public abstract string SptVersion { get; init; } + public abstract Version SptVersion { get; } /// /// List of mods this mod should load before @@ -60,7 +70,7 @@ public abstract record AbstractModMetadata /// /// Mod dependency is the key, version is the value /// - public abstract Dictionary? ModDependencies { get; set; } + public abstract Dictionary? ModDependencies { get; set; } /// /// Link to this mod's mod page, or GitHub page diff --git a/Libraries/SPTarkov.Server.Core/SPTarkov.Server.Core.csproj b/Libraries/SPTarkov.Server.Core/SPTarkov.Server.Core.csproj index 766f6efe..82754f00 100644 --- a/Libraries/SPTarkov.Server.Core/SPTarkov.Server.Core.csproj +++ b/Libraries/SPTarkov.Server.Core/SPTarkov.Server.Core.csproj @@ -44,7 +44,7 @@ diff --git a/Libraries/SPTarkov.Server.Core/Utils/App.cs b/Libraries/SPTarkov.Server.Core/Utils/App.cs index e88eadab..ced8fd6c 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/App.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/App.cs @@ -39,7 +39,7 @@ public class App( _logger.Debug($"Ran as admin: {Environment.IsPrivilegedProcess}"); _logger.Debug($"CPU cores: {Environment.ProcessorCount}"); _logger.Debug($"PATH: {(Environment.ProcessPath ?? "null returned").Encode(EncodeType.BASE64)}"); - _logger.Debug($"Server: {ProgramStatics.SPT_VERSION() ?? _coreConfig.SptVersion}"); + _logger.Debug($"Server: {ProgramStatics.SPT_VERSION()}"); // _logger.Debug($"RAM: {(os.totalmem() / 1024 / 1024 / 1024).toFixed(2)}GB"); diff --git a/Libraries/SPTarkov.Server.Core/Utils/ProgramStatics.cs b/Libraries/SPTarkov.Server.Core/Utils/ProgramStatics.cs index 804bc4f9..72badc6c 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/ProgramStatics.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/ProgramStatics.cs @@ -1,5 +1,6 @@ using SPTarkov.Server.Core.Models.Enums; using SPTarkov.Server.Core.Models.Logging; +using Version = SemanticVersioning.Version; namespace SPTarkov.Server.Core.Utils; @@ -68,7 +69,7 @@ public static partial class ProgramStatics return _mods; } - public static string SPT_VERSION() + public static Version SPT_VERSION() { return SptVersion; } diff --git a/Libraries/SPTarkov.Server.Core/Utils/Watermark.cs b/Libraries/SPTarkov.Server.Core/Utils/Watermark.cs index 15838576..de7a2053 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/Watermark.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/Watermark.cs @@ -12,32 +12,32 @@ namespace SPTarkov.Server.Core.Utils; public class WatermarkLocale(ServerLocalisationService serverLocalisationService) { public IReadOnlyList Description { get; } = - [ - serverLocalisationService.GetText("watermark-discord_url"), - "", - serverLocalisationService.GetText("watermark-free_of_charge"), - serverLocalisationService.GetText("watermark-paid_scammed"), - serverLocalisationService.GetText("watermark-commercial_use_prohibited"), - ]; + [ + serverLocalisationService.GetText("watermark-discord_url"), + "", + serverLocalisationService.GetText("watermark-free_of_charge"), + serverLocalisationService.GetText("watermark-paid_scammed"), + serverLocalisationService.GetText("watermark-commercial_use_prohibited"), + ]; public IReadOnlyList Modding { get; } = - [ - "", - serverLocalisationService.GetText("watermark-modding_disabled"), - "", - serverLocalisationService.GetText("watermark-not_an_issue"), - serverLocalisationService.GetText("watermark-do_not_report"), - ]; + [ + "", + serverLocalisationService.GetText("watermark-modding_disabled"), + "", + serverLocalisationService.GetText("watermark-not_an_issue"), + serverLocalisationService.GetText("watermark-do_not_report"), + ]; public IReadOnlyList Warning { get; } = - [ - "", - serverLocalisationService.GetText("watermark-testing_build"), - serverLocalisationService.GetText("watermark-no_support"), - "", - $"{serverLocalisationService.GetText("watermark-report_issues_to")}:", - serverLocalisationService.GetText("watermark-issue_tracker_url"), - "", - serverLocalisationService.GetText("watermark-use_at_own_risk"), - ]; + [ + "", + serverLocalisationService.GetText("watermark-testing_build"), + serverLocalisationService.GetText("watermark-no_support"), + "", + $"{serverLocalisationService.GetText("watermark-report_issues_to")}:", + serverLocalisationService.GetText("watermark-issue_tracker_url"), + "", + serverLocalisationService.GetText("watermark-use_at_own_risk"), + ]; } [Injectable(TypePriority = OnLoadOrder.Watermark)] @@ -93,7 +93,7 @@ public class Watermark( /// public string GetVersionTag(bool withEftVersion = false) { - var sptVersion = ProgramStatics.SPT_VERSION() ?? sptConfig.SptVersion; + var sptVersion = ProgramStatics.SPT_VERSION().ToString(); var versionTag = ProgramStatics.DEBUG() ? $"{sptVersion} - {serverLocalisationService.GetText("bleeding_edge_build")}" : sptVersion; if (withEftVersion) diff --git a/SPTarkov.Server/Modding/ModDllLoader.cs b/SPTarkov.Server/Modding/ModDllLoader.cs index d3ac489e..4cda25b9 100644 --- a/SPTarkov.Server/Modding/ModDllLoader.cs +++ b/SPTarkov.Server/Modding/ModDllLoader.cs @@ -78,13 +78,11 @@ public class ModDllLoader string.IsNullOrEmpty(result.ModMetadata.ModGuid) || string.IsNullOrEmpty(result.ModMetadata.Name) || string.IsNullOrEmpty(result.ModMetadata.Author) - || string.IsNullOrEmpty(result.ModMetadata.Version) || string.IsNullOrEmpty(result.ModMetadata.License) - || string.IsNullOrEmpty(result.ModMetadata.SptVersion) ) { throw new Exception( - $"The mod metadata for: {Path.GetFullPath(path)} is missing one of these properties: ModGuid, Name, Author, License, Version or SptVersion" + $"The mod metadata for: {Path.GetFullPath(path)} is missing one of these properties: ModGuid, Name, Author, or License" ); } diff --git a/SPTarkov.Server/Modding/ModValidator.cs b/SPTarkov.Server/Modding/ModValidator.cs index fb55efcc..65dac27d 100644 --- a/SPTarkov.Server/Modding/ModValidator.cs +++ b/SPTarkov.Server/Modding/ModValidator.cs @@ -6,6 +6,7 @@ using SPTarkov.Server.Core.Servers; using SPTarkov.Server.Core.Services; using SPTarkov.Server.Core.Utils; using LogLevel = SPTarkov.Server.Core.Models.Spt.Logging.LogLevel; +using Version = SemanticVersioning.Version; namespace SPTarkov.Server.Modding; @@ -215,7 +216,7 @@ public class ModValidator( /// True if compatible protected bool IsModCompatibleWithSpt(AbstractModMetadata mod) { - var sptVersion = ProgramStatics.SPT_VERSION() ?? sptConfig.SptVersion; + var sptVersion = ProgramStatics.SPT_VERSION(); var modName = $"{mod.Author}-{mod.Name}"; // Error and prevent loading if sptVersion property is not a valid semver string @@ -306,13 +307,13 @@ public class ModValidator( foreach (var (modDependency, requiredVersion) in pkg.ModDependencies) { // Raise dependency version incompatible if the dependency is not found in the mod list - if (!loadedMods.ContainsKey(modDependency)) + if (!loadedMods.TryGetValue(modDependency, out var value)) { logger.Error(localisationService.GetText("modloader-missing_dependency", new { mod = modName, modDependency })); return false; } - if (!semVer.Satisfies(loadedMods[modDependency].Version, requiredVersion)) + if (!semVer.Satisfies(value.Version, requiredVersion)) { logger.Error( localisationService.GetText( @@ -321,7 +322,7 @@ public class ModValidator( { mod = modName, modDependency, - currentVersion = loadedMods[modDependency].Version, + currentVersion = value.Version, requiredVersion, } ) @@ -335,13 +336,12 @@ public class ModValidator( protected bool IsModCompatible(AbstractModMetadata mod, Dictionary loadedMods) { - var incompatbileModsList = mod.Incompatibilities; - if (incompatbileModsList == null) + if (mod.Incompatibilities == null) { return true; } - foreach (var incompatibleModName in incompatbileModsList) + foreach (var incompatibleModName in mod.Incompatibilities) { // Raise dependency version incompatible if any incompatible mod is found if (loadedMods.ContainsKey(incompatibleModName)) @@ -400,16 +400,6 @@ public class ModValidator( return false; } - // Validate mod - var config = mod.ModMetadata; - var issue = false; - - if (!semVer.IsValid(config.Version)) - { - logger.Error(localisationService.GetText("modloader-invalid_version_property", modName)); - issue = true; - } - - return !issue; + return true; } } diff --git a/Testing/TestMod/TestMod.cs b/Testing/TestMod/TestMod.cs index 4605aa5a..3828cc19 100644 --- a/Testing/TestMod/TestMod.cs +++ b/Testing/TestMod/TestMod.cs @@ -2,6 +2,7 @@ using SPTarkov.Server.Core.DI; using SPTarkov.Server.Core.Models.Spt.Mod; using SPTarkov.Server.Core.Models.Utils; +using Version = SemanticVersioning.Version; namespace TestMod; @@ -11,12 +12,12 @@ public record TestModMetadata : AbstractModMetadata public override string Name { get; init; } = "test-mod"; public override string Author { get; init; } = "SPTarkov"; public override List? Contributors { get; set; } - public override string Version { get; init; } = "1.0.0"; - public override string SptVersion { get; init; } = "4.0.0"; + public override Version Version { get; } = new("1.0.0"); + public override Version SptVersion { get; } = new("4.0.0"); public override List? LoadBefore { get; set; } public override List? LoadAfter { get; set; } public override List? Incompatibilities { get; set; } - public override Dictionary? ModDependencies { get; set; } + public override Dictionary? ModDependencies { get; set; } public override string? Url { get; set; } public override bool? IsBundleMod { get; set; } public override string? License { get; init; } = "MIT";