mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
integrate content rights validation into the main program
This commit is contained in:
parent
f648f42742
commit
eb9e6500c9
@ -46,6 +46,8 @@ namespace Wabbajack.Common
|
||||
public static HashSet<string> GameESMs = new HashSet<string>
|
||||
{"Skyrim.esm", "Update.esm", "Dawnguard.esm", "HearthFires.esm", "Dragonborn.esm"};
|
||||
|
||||
public static string ModPermissionsURL = "https://raw.githubusercontent.com/wabbajack-tools/opt-out-lists/master/NexusModPermissions.yml";
|
||||
public static string ServerWhitelistURL = "https://raw.githubusercontent.com/wabbajack-tools/opt-out-lists/master/ServerWhitelist.yml";
|
||||
|
||||
public static string UserAgent
|
||||
{
|
||||
|
@ -228,6 +228,12 @@ namespace Wabbajack.Test
|
||||
Assert.AreEqual(errors.Count(), 0);
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CanLoadFromGithub()
|
||||
{
|
||||
new ValidateModlist().LoadListsFromGithub();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,12 +31,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wabbajack.Test", "Wabbajack
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OMODExtractorDLL", "OMOD-Extractor\OMODExtractorDLL\OMODExtractorDLL.csproj", "{EB003D18-DFFB-49C7-B054-FB375345AE26}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Content Control Lists", "Content Control Lists", "{9CF13B36-1015-4065-B326-F2632E3C892D}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
NexusModPermissions.yml = NexusModPermissions.yml
|
||||
ServerWhitelist.yml = ServerWhitelist.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug (no commandargs)|Any CPU = Debug (no commandargs)|Any CPU
|
||||
@ -171,9 +165,6 @@ Global
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{9CF13B36-1015-4065-B326-F2632E3C892D} = {4EDEF6CC-2F5C-439B-BEAF-9D03895099F1}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {5CF408D5-8BF2-40C2-907C-694DBACFF01B}
|
||||
EndGlobalSection
|
||||
|
@ -17,6 +17,7 @@ using Newtonsoft.Json;
|
||||
using VFS;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.NexusApi;
|
||||
using Wabbajack.Validation;
|
||||
using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;
|
||||
@ -238,6 +239,7 @@ namespace Wabbajack
|
||||
|
||||
ModList = new ModList
|
||||
{
|
||||
GameType = GameRegistry.Games.Values.First(f => f.MO2Name == MO2Ini.General.gameName).Game,
|
||||
Archives = SelectedArchives,
|
||||
Directives = InstallDirectives,
|
||||
Name = MO2Profile
|
||||
@ -247,6 +249,7 @@ namespace Wabbajack
|
||||
ExportModlist();
|
||||
|
||||
ResetMembers();
|
||||
ValidateModlist.RunValidation(ModList);
|
||||
|
||||
ShowReport();
|
||||
|
||||
|
@ -15,6 +15,7 @@ using K4os.Compression.LZ4.Streams;
|
||||
using VFS;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.NexusApi;
|
||||
using Wabbajack.Validation;
|
||||
using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;
|
||||
@ -71,6 +72,9 @@ namespace Wabbajack
|
||||
|
||||
public void Install()
|
||||
{
|
||||
|
||||
ValidateModlist.RunValidation(ModList);
|
||||
|
||||
VirtualFileSystem.Clean();
|
||||
Directory.CreateDirectory(Outputfolder);
|
||||
Directory.CreateDirectory(DownloadFolder);
|
||||
|
@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Wabbajack.Common;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace Wabbajack.Validation
|
||||
{
|
||||
|
@ -1,13 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Wabbajack.Common;
|
||||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Serialization.NamingConventions;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
|
||||
namespace Wabbajack.Validation
|
||||
{
|
||||
@ -36,6 +38,36 @@ namespace Wabbajack.Validation
|
||||
ServerWhitelist = d.Deserialize<ServerWhitelist>(s);
|
||||
}
|
||||
|
||||
public void LoadListsFromGithub()
|
||||
{
|
||||
var d = new DeserializerBuilder()
|
||||
.WithNamingConvention(new PascalCaseNamingConvention())
|
||||
.Build();
|
||||
var client = new HttpClient();
|
||||
Utils.Log("Loading Nexus Mod Permissions");
|
||||
using (var result = new StringReader(client.GetStringSync(Consts.ModPermissionsURL)))
|
||||
{
|
||||
AuthorPermissions = d.Deserialize<Dictionary<string, Author>>(result);
|
||||
}
|
||||
|
||||
Utils.Log("Loading Server Whitelist");
|
||||
using (var result = new StringReader(client.GetStringSync(Consts.ServerWhitelistURL)))
|
||||
{
|
||||
ServerWhitelist = d.Deserialize<ServerWhitelist>(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void RunValidation(ModList modlist)
|
||||
{
|
||||
var validator = new ValidateModlist();
|
||||
validator.LoadListsFromGithub();
|
||||
|
||||
var errors = validator.Validate(modlist);
|
||||
errors.Do(e => Utils.Log(e));
|
||||
Utils.Log($"{errors.Count()} validation errors found, cannot continue.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Takes all the permissions for a given Nexus mods and merges them down to a single permissions record
|
||||
/// the more specific record having precedence in each field.
|
||||
@ -109,8 +141,16 @@ namespace Wabbajack.Validation
|
||||
|
||||
modlist.Archives
|
||||
.OfType<NexusMod>()
|
||||
.Where(m => m.GameName.ToLower() != nexus)
|
||||
.Do(m => ValidationErrors.Push($"The modlist is for {nexus} but {m.Name} is for game type {m.GameName} and is not allowed to be converted to other game types"));
|
||||
.Where(m => NexusApi.NexusApiUtils.ConvertGameName(m.GameName) != nexus)
|
||||
.Do(m =>
|
||||
{
|
||||
var permissions = FilePermissions(m);
|
||||
if (!(permissions.CanUseInOtherGames ?? true))
|
||||
{
|
||||
ValidationErrors.Push(
|
||||
$"The modlist is for {nexus} but {m.Name} is for game type {m.GameName} and is not allowed to be converted to other game types");
|
||||
}
|
||||
});
|
||||
|
||||
modlist.Archives
|
||||
.OfType<GoogleDriveMod>()
|
||||
|
Loading…
Reference in New Issue
Block a user