public static void OnLeaveGame(Connection connection) { if (easyAntiCheat != null) { Client client = GetClient(connection); easyAntiCheat.UnregisterClient(client); client2connection.Remove(client); connection2client.Remove(connection); connection2status.Remove(connection); } }
private static void HandleClientUpdate(ClientStatusUpdate <EasyAntiCheat.Server.Hydra.Client> clientStatus) { using (TimeWarning.New("AntiCheatKickPlayer", 10)) { EasyAntiCheat.Server.Hydra.Client client = clientStatus.Client; Connection connection = GetConnection(client); if (connection == null) { Debug.LogError("EAC status update for invalid client: " + client.ClientID); } else { if (ShouldIgnore(connection)) { return; } if (clientStatus.RequiresKick) { string text = clientStatus.Message; if (string.IsNullOrEmpty(text)) { text = clientStatus.Status.ToString(); } Debug.Log($"[EAC] Kicking {connection.userid} / {connection.username} ({text})"); connection.authStatus = "eac"; Network.Net.sv.Kick(connection, "EAC: " + text); Interface.CallHook("OnPlayerKicked", connection, text); DateTime?timeBanExpires; if (clientStatus.IsBanned(out timeBanExpires)) { connection.authStatus = "eacbanned"; object[] args = new object[3] { 2, 0, "<color=#fff>SERVER</color> Kicking " + connection.username + " (banned by anticheat)" }; Interface.CallHook("OnPlayerBanned", connection, text); ConsoleNetwork.BroadcastToAllClients("chat.add", args); if (!timeBanExpires.HasValue) { Entity.DeleteBy(connection.userid); } } easyAntiCheat.UnregisterClient(client); client2connection.Remove(client); connection2client.Remove(connection); connection2status.Remove(connection); } else if (clientStatus.Status == ClientStatus.ClientAuthenticatedLocal) { OnAuthenticatedLocal(connection); easyAntiCheat.SetClientNetworkState(client, false); } else if (clientStatus.Status == ClientStatus.ClientAuthenticatedRemote) { OnAuthenticatedRemote(connection); } return; } } }