2024-02-02 13:59:10 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
2024-02-02 13:59:10 +00:00
|
|
|
|
using BepInEx.Bootstrap;
|
2024-03-07 22:10:07 +00:00
|
|
|
|
using BepInEx.Logging;
|
2024-02-01 16:43:18 +00:00
|
|
|
|
using EFT;
|
|
|
|
|
using HarmonyLib;
|
2024-07-12 15:20:47 +01:00
|
|
|
|
using SPT.Custom.Utils;
|
2024-02-01 16:43:18 +00:00
|
|
|
|
|
2024-07-12 15:20:47 +01:00
|
|
|
|
namespace SPT.Custom.Patches
|
2024-02-01 16:43:18 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Prevents loading of non-whitelisted client mods to minimize the amount of false issue reports being made during the public BE phase
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class PreventClientModsPatch : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
|
|
|
|
return AccessTools.Method(typeof(TarkovApplication), nameof(TarkovApplication.method_20));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPrefix]
|
2024-08-02 16:57:59 +01:00
|
|
|
|
public static void PatchPrefix()
|
2024-02-01 16:43:18 +00:00
|
|
|
|
{
|
2024-03-07 22:10:07 +00:00
|
|
|
|
CheckForNonWhitelistedPlugins(Logger);
|
2024-02-02 13:59:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-07 22:10:07 +00:00
|
|
|
|
private static void CheckForNonWhitelistedPlugins(ManualLogSource logger)
|
2024-02-02 13:59:10 +00:00
|
|
|
|
{
|
2024-03-11 22:02:45 +00:00
|
|
|
|
if (MenuNotificationManager.disallowedPlugins.Any())
|
2024-02-02 13:59:10 +00:00
|
|
|
|
{
|
2024-03-11 22:02:45 +00:00
|
|
|
|
logger.LogError($"{MenuNotificationManager.release.illegalPluginsLoadedText}\n{string.Join("\n", MenuNotificationManager.disallowedPlugins)}");
|
|
|
|
|
throw new Exception(MenuNotificationManager.release.illegalPluginsExceptionText);
|
2024-02-02 13:59:10 +00:00
|
|
|
|
}
|
2024-02-01 16:43:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|