mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
Fix level below check and move anti cheat patches
This commit is contained in:
1 parent
51959c2bec
commit
beb670f0d8
6 files changed
+101
-80
No files matched your search
@@ -432,6 +432,13 @@ internal static class NetworkManager
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (netObj is CustomNetworkTransform networkTransform)
|
||||
{
|
||||
if (!PlayerRpc(networkTransform.myPlayer, callId, reader))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,7 @@ using BetterAmongUs.Modules.Support;
|
||||
using BetterAmongUs.Mono;
|
||||
using BetterAmongUs.Network;
|
||||
using BetterAmongUs.Patches.Gameplay.UI.Settings;
|
||||
using HarmonyLib;
|
||||
using Hazel;
|
||||
using InnerNet;
|
||||
|
||||
namespace BetterAmongUs.Modules.AntiCheat;
|
||||
|
||||
@@ -60,73 +58,6 @@ internal static class BetterAntiCheat
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Harmony patch for PlatformSpecificData to detect platform spoofing.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(PlatformSpecificData))]
|
||||
class PlatformSpecificDataPatch
|
||||
{
|
||||
/// <summary>
|
||||
/// Postfix patch to validate platform data after deserialization.
|
||||
/// </summary>
|
||||
[HarmonyPatch(nameof(PlatformSpecificData.Deserialize))]
|
||||
[HarmonyPostfix]
|
||||
internal static void Deserialize_Postfix(PlatformSpecificData __instance)
|
||||
{
|
||||
if (!BAUPlugin.AntiCheat.Value || BAUModdedSupportFlags.HasFlag(BAUModdedSupportFlags.Disable_Anticheat) || !GameState.IsVanillaServer) return;
|
||||
|
||||
if (GameState.IsLobby)
|
||||
{
|
||||
try
|
||||
{
|
||||
LateTask.Schedule(() =>
|
||||
{
|
||||
var player = BAUPlugin.AllPlayerControls.FirstOrDefault(pc => pc.GetClient().PlatformData == __instance);
|
||||
|
||||
if (player != null && __instance?.Platform != null)
|
||||
{
|
||||
if (__instance.Platform is Platforms.StandaloneWin10 or Platforms.Xbox)
|
||||
{
|
||||
if (__instance.XboxPlatformId.ToString().Length is < 10 or > 16)
|
||||
{
|
||||
player.ReportPlayer(ReportReasons.Cheating_Hacking);
|
||||
BetterNotificationManager.NotifyCheat(player,
|
||||
Translator.GetString("AntiCheat.Reason.PlatformSpoofer"),
|
||||
Translator.GetString("AntiCheat.HasBeenDetectedWithCheat")
|
||||
);
|
||||
Logger_.LogCheat($"{player.BetterData().RealName} {Translator.GetString("AntiCheat.PlatformSpoofer")}: {__instance.XboxPlatformId}");
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.Platform is Platforms.Playstation)
|
||||
{
|
||||
if (__instance.PsnPlatformId.ToString().Length is < 14 or > 20)
|
||||
{
|
||||
player.ReportPlayer(ReportReasons.Cheating_Hacking);
|
||||
BetterNotificationManager.NotifyCheat(player,
|
||||
Translator.GetString("AntiCheat.Reason.PlatformSpoofer"),
|
||||
Translator.GetString("AntiCheat.HasBeenDetectedWithCheat")
|
||||
);
|
||||
Logger_.LogCheat($"{player.BetterData().RealName} {Translator.GetString("AntiCheat.PlatformSpoofer")}: {__instance.PsnPlatformId}");
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.Platform is Platforms.Unknown || !Enum.IsDefined(__instance.Platform))
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player,
|
||||
Translator.GetString("AntiCheat.Reason.PlatformSpoofer"),
|
||||
Translator.GetString("AntiCheat.HasBeenDetectedWithCheat")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}, 3.5f, shouldLog: false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles RPCs before anti-cheat detection checks.
|
||||
/// </summary>
|
||||
|
||||
@@ -12,16 +12,6 @@ internal sealed class SetLevelHandler : RPCHandler
|
||||
{
|
||||
internal override byte CallId => (byte)RpcCalls.SetLevel;
|
||||
|
||||
internal override void Handle(PlayerControl? sender, MessageReader reader)
|
||||
{
|
||||
uint level = reader.ReadPackedUInt32() + 1;
|
||||
|
||||
if (level < BetterGameSettings.KickLevelBelow.GetInt())
|
||||
{
|
||||
sender.Kick(setReasonInfo: $" is level {level}, level must be equal or above {BetterGameSettings.KickLevelBelow.GetInt()} to join");
|
||||
}
|
||||
}
|
||||
|
||||
internal override bool HandleAntiCheatCancel(PlayerControl? sender, MessageReader reader)
|
||||
{
|
||||
if (sender.DataIsCollected() == true && sender.BetterData().AntiCheatInfo.HasSetLevel && !GameState.IsLocalGame && GameState.IsVanillaServer)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Patches.Gameplay.UI.Settings;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace BetterAmongUs.Patches.Gameplay.Anticheat;
|
||||
|
||||
[HarmonyPatch]
|
||||
internal class CheckPlayerLevelPatch
|
||||
{
|
||||
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.FixedUpdate))]
|
||||
[HarmonyPostfix]
|
||||
private static void PlayerControl_FixedUpdate_Postfix(PlayerControl __instance)
|
||||
{
|
||||
if (GameState.IsHost)
|
||||
{
|
||||
if (!__instance.IsLocalPlayer() && (__instance.Data.PlayerLevel < BetterGameSettings.KickLevelBelow.GetInt()))
|
||||
{
|
||||
__instance.Kick(setReasonInfo: $" is level {__instance.Data.PlayerLevel}, level must be equal or above {BetterGameSettings.KickLevelBelow.GetInt()} to join");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Modules.Support;
|
||||
using BetterAmongUs.Mono;
|
||||
using HarmonyLib;
|
||||
using InnerNet;
|
||||
|
||||
namespace BetterAmongUs.Patches.Gameplay.Anticheat;
|
||||
|
||||
[HarmonyPatch]
|
||||
internal class PlatformSpoofPatch
|
||||
{
|
||||
[HarmonyPatch(typeof(PlatformSpecificData), nameof(PlatformSpecificData.Deserialize))]
|
||||
[HarmonyPostfix]
|
||||
internal static void PlatformSpecificData_Deserialize_Postfix(PlatformSpecificData __instance)
|
||||
{
|
||||
if (!BAUPlugin.AntiCheat.Value || BAUModdedSupportFlags.HasFlag(BAUModdedSupportFlags.Disable_Anticheat) || !GameState.IsVanillaServer) return;
|
||||
|
||||
if (GameState.IsLobby)
|
||||
{
|
||||
try
|
||||
{
|
||||
LateTask.Schedule(() =>
|
||||
{
|
||||
var player = BAUPlugin.AllPlayerControls.FirstOrDefault(pc => pc.GetClient().PlatformData == __instance);
|
||||
|
||||
if (player != null && __instance?.Platform != null)
|
||||
{
|
||||
if (__instance.Platform is Platforms.StandaloneWin10 or Platforms.Xbox)
|
||||
{
|
||||
if (__instance.XboxPlatformId.ToString().Length is < 10 or > 16)
|
||||
{
|
||||
player.ReportPlayer(ReportReasons.Cheating_Hacking);
|
||||
BetterNotificationManager.NotifyCheat(player,
|
||||
Translator.GetString("AntiCheat.Reason.PlatformSpoofer"),
|
||||
Translator.GetString("AntiCheat.HasBeenDetectedWithCheat")
|
||||
);
|
||||
Logger_.LogCheat($"{player.BetterData().RealName} {Translator.GetString("AntiCheat.PlatformSpoofer")}: {__instance.XboxPlatformId}");
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.Platform is Platforms.Playstation)
|
||||
{
|
||||
if (__instance.PsnPlatformId.ToString().Length is < 14 or > 20)
|
||||
{
|
||||
player.ReportPlayer(ReportReasons.Cheating_Hacking);
|
||||
BetterNotificationManager.NotifyCheat(player,
|
||||
Translator.GetString("AntiCheat.Reason.PlatformSpoofer"),
|
||||
Translator.GetString("AntiCheat.HasBeenDetectedWithCheat")
|
||||
);
|
||||
Logger_.LogCheat($"{player.BetterData().RealName} {Translator.GetString("AntiCheat.PlatformSpoofer")}: {__instance.PsnPlatformId}");
|
||||
}
|
||||
}
|
||||
|
||||
if (__instance.Platform is Platforms.Unknown || !Enum.IsDefined(__instance.Platform))
|
||||
{
|
||||
BetterNotificationManager.NotifyCheat(player,
|
||||
Translator.GetString("AntiCheat.Reason.PlatformSpoofer"),
|
||||
Translator.GetString("AntiCheat.HasBeenDetectedWithCheat")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}, 3.5f, shouldLog: false);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Modules.Support;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace BetterAmongUs.Patches.Gameplay.Systems;
|
||||
namespace BetterAmongUs.Patches.Gameplay.Anticheat;
|
||||
|
||||
[HarmonyPatch]
|
||||
internal static class VoteBanSystemPatch
|
||||
Reference in new issue
Block a user