mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-12 22:50:44 -05:00
Preparing for public BE release - temporarily preventing client mod loading (!74)
Co-authored-by: Terkoiz <terkoiz@spt.dev> Reviewed-on: SPT-AKI/Modules#74 Co-authored-by: Terkoiz <terkoiz@noreply.dev.sp-tarkov.com> Co-committed-by: Terkoiz <terkoiz@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
eb443aaa5e
commit
9f158b6db3
@ -1,15 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Aki.Common;
|
||||
using Aki.Core.Patches;
|
||||
using BepInEx;
|
||||
using BepInEx.Bootstrap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Aki.Core
|
||||
{
|
||||
[BepInPlugin("com.spt-aki.core", "AKI.Core", AkiPluginInfo.PLUGIN_VERSION)]
|
||||
class AkiCorePlugin : BaseUnityPlugin
|
||||
{
|
||||
// Temp static logger field, remove along with plugin whitelisting before release
|
||||
private static BepInEx.Logging.ManualLogSource _logger;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
_logger = Logger;
|
||||
|
||||
Logger.LogInfo("Loading: Aki.Core");
|
||||
|
||||
try
|
||||
@ -21,6 +31,7 @@ namespace Aki.Core
|
||||
new UnityWebRequestPatch().Enable();
|
||||
new WebSocketPatch().Enable();
|
||||
new TransportPrefixPatch().Enable();
|
||||
new PreventClientModsPatch().Enable();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -31,5 +42,41 @@ namespace Aki.Core
|
||||
|
||||
Logger.LogInfo("Completed: Aki.Core");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="PreventClientModsPatch"/> for explanation on why this is needed.
|
||||
/// Yes, I know this is jank but it's temporary and will be removed before release :)
|
||||
/// </summary>
|
||||
internal static void CheckForNonWhitelistedPlugins()
|
||||
{
|
||||
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())
|
||||
{
|
||||
_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)}");
|
||||
|
||||
// Delay game shutdown by a little bit, since logging sometimes doesn't have enough time to write to file
|
||||
Task.Run(() =>
|
||||
{
|
||||
Task.Delay(500);
|
||||
Application.Quit(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
24
project/Aki.Core/Patches/PreventClientModsPatch.cs
Normal file
24
project/Aki.Core/Patches/PreventClientModsPatch.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Reflection;
|
||||
using Aki.Reflection.Patching;
|
||||
using EFT;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace Aki.Core.Patches
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
AkiCorePlugin.CheckForNonWhitelistedPlugins();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user