2024-02-08 09:10:34 +00:00
|
|
|
using System.Reflection;
|
2024-05-21 19:10:17 +01:00
|
|
|
using SPT.Common.Utils;
|
|
|
|
using SPT.Core.Utils;
|
|
|
|
using SPT.Reflection.Patching;
|
2024-02-08 09:10:34 +00:00
|
|
|
using HarmonyLib;
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
namespace SPT.Core.Patches
|
2024-02-08 09:10:34 +00:00
|
|
|
{
|
|
|
|
public class GameValidationPatch : ModulePatch
|
|
|
|
{
|
2024-05-21 17:46:46 +01:00
|
|
|
private const string PluginName = "SPT.Core";
|
2024-02-08 09:10:34 +00:00
|
|
|
private const string ErrorMessage = "Validation failed";
|
|
|
|
private static BepInEx.Logging.ManualLogSource _logger = null;
|
|
|
|
private static bool _hasRun = false;
|
|
|
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
{
|
|
|
|
return AccessTools.Method(typeof(BattleeyePatchClass), nameof(BattleeyePatchClass.RunValidation));
|
|
|
|
}
|
|
|
|
|
|
|
|
[PatchPostfix]
|
|
|
|
private static void PatchPostfix()
|
|
|
|
{
|
|
|
|
if (ValidationUtil.Validate() || _hasRun)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (_logger == null)
|
|
|
|
_logger = BepInEx.Logging.Logger.CreateLogSource(PluginName);
|
|
|
|
|
|
|
|
_hasRun = true;
|
|
|
|
ServerLog.Warn($"Warning: {PluginName}", ErrorMessage);
|
|
|
|
_logger?.LogWarning(ErrorMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|