0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.Custom/Patches/PreventClientModsPatch.cs
Cj 73db17ea78 Show mods loaded in cool debug message (!95)
needs merged with: SPT-AKI/Server#258

Shows if mods are loaded in the cool debug message, will show if either server mods or client mods are present.

Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#95
Co-authored-by: Cj <cj@noreply.dev.sp-tarkov.com>
Co-committed-by: Cj <cj@noreply.dev.sp-tarkov.com>
2024-03-11 22:02:45 +00:00

39 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Aki.Reflection.Patching;
using Aki.SinglePlayer.Utils.MainMenu;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using EFT;
using HarmonyLib;
namespace Aki.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);
}
}
}
}