2024-02-02 13:59:10 +00:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Reflection ;
2024-02-01 16:43:18 +00:00
using Aki.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-03-11 08:44:50 +00:00
namespace Aki.SinglePlayer.Patches.MainMenu
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]
private static void Prefix ( )
{
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
{
var whitelistedPlugins = new HashSet < string >
{
"com.spt-aki.core" ,
"com.spt-aki.custom" ,
"com.spt-aki.debugging" ,
"com.spt-aki.singleplayer" ,
"com.bepis.bepinex.configurationmanager" ,
"com.terkoiz.freecam" ,
"com.sinai.unityexplorer" ,
"com.cwx.debuggingtool-dxyz" ,
"com.cwx.debuggingtool" ,
"xyz.drakia.botdebug" ,
"com.kobrakon.camunsnap" ,
"RuntimeUnityEditor"
} ;
var disallowedPlugins = Chainloader . PluginInfos . Values . Select ( pi = > pi . Metadata . GUID ) . Except ( whitelistedPlugins ) . ToArray ( ) ;
if ( disallowedPlugins . Any ( ) )
{
2024-03-07 22:10:07 +00:00
logger . LogError ( $"One or more non-whitelisted plugins were detected. Mods are not allowed in BleedingEdge builds of SPT. Illegal plugins:\n{string.Join(" \ n ", disallowedPlugins)}" ) ;
2024-02-02 13:59:10 +00:00
throw new Exception ( "Non-debug client mods have been detected. Mods are not allowed in BleedingEdge builds of SPT - please remove them before playing!" ) ;
}
2024-02-01 16:43:18 +00:00
}
}
}