mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using BetterAmongUs.Helpers;
|
|
using BetterAmongUs.Items.Attributes;
|
|
using BetterAmongUs.Managers;
|
|
using Hazel;
|
|
|
|
namespace BetterAmongUs.Modules.AntiCheat;
|
|
|
|
[RegisterRPCHandler]
|
|
internal sealed class CheckNameHandler : RPCHandler
|
|
{
|
|
internal override byte CallId => (byte)RpcCalls.CheckName;
|
|
|
|
internal override bool HandleAntiCheatCancel(PlayerControl? sender, MessageReader reader)
|
|
{
|
|
if (!GameState.IsHost) return false;
|
|
|
|
var name = reader.ReadString();
|
|
|
|
if (sender.DataIsCollected() == true && sender.BetterData().AntiCheatInfo.HasSetName && !GameState.IsLocalGame && GameState.IsVanillaServer)
|
|
{
|
|
if (BetterNotificationManager.NotifyCheat(sender, GetFormatSetText()))
|
|
{
|
|
Utils.AddChatPrivate($"{sender.GetPlayerNameAndColor()} Has tried to change their name to '{name}' but has been undone!");
|
|
Logger.LogCheat($"{sender.BetterData().RealName} Has tried to change their name to '{name}' but has been undone!");
|
|
LogRpcInfo($"{sender.DataIsCollected() == true} && {!GameState.IsLocalGame} && {GameState.IsVanillaServer}");
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
sender.BetterData().AntiCheatInfo.HasSetName = true;
|
|
|
|
return true;
|
|
}
|
|
}
|