0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.Custom/Patches/PreventClientModsPatch.cs

39 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
2024-05-21 19:10:17 +01:00
using SPT.Reflection.Patching;
using SPT.SinglePlayer.Utils.MainMenu;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using EFT;
using HarmonyLib;
2024-05-21 19:10:17 +01:00
namespace SPT.SinglePlayer.Patches.MainMenu
{
/// <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]
private static void Prefix()
{
CheckForNonWhitelistedPlugins(Logger);
}
private static void CheckForNonWhitelistedPlugins(ManualLogSource logger)
{
if (MenuNotificationManager.disallowedPlugins.Any())
{
logger.LogError($"{MenuNotificationManager.release.illegalPluginsLoadedText}\n{string.Join("\n", MenuNotificationManager.disallowedPlugins)}");
throw new Exception(MenuNotificationManager.release.illegalPluginsExceptionText);
}
}
}
}