From 3e95730c89e9bee11de62394115352e76db437f2 Mon Sep 17 00:00:00 2001 From: cubic Date: Mon, 8 Apr 2024 07:02:03 +0100 Subject: [PATCH] Improve player kicking --- .../MenuRpc/RequestKickPlayerPacketHandler.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/BeatTogether.DedicatedServer.Kernel/PacketHandlers/MultiplayerSession/MenuRpc/RequestKickPlayerPacketHandler.cs b/BeatTogether.DedicatedServer.Kernel/PacketHandlers/MultiplayerSession/MenuRpc/RequestKickPlayerPacketHandler.cs index 9d96db99..a037bdb6 100644 --- a/BeatTogether.DedicatedServer.Kernel/PacketHandlers/MultiplayerSession/MenuRpc/RequestKickPlayerPacketHandler.cs +++ b/BeatTogether.DedicatedServer.Kernel/PacketHandlers/MultiplayerSession/MenuRpc/RequestKickPlayerPacketHandler.cs @@ -1,7 +1,4 @@ -using BeatTogether.DedicatedServer.Ignorance.IgnoranceCore; -using BeatTogether.DedicatedServer.Kernel.Abstractions; -using BeatTogether.DedicatedServer.Messaging.Enums; -using BeatTogether.DedicatedServer.Messaging.Packets; +using BeatTogether.DedicatedServer.Kernel.Abstractions; using BeatTogether.DedicatedServer.Messaging.Packets.MultiplayerSession.MenuRpc; using Serilog; @@ -11,14 +8,17 @@ public sealed class RequestKickPlayerPacketHandler : BasePacketHandler(); public RequestKickPlayerPacketHandler( IPlayerRegistry playerRegistry, - IPacketDispatcher packetDispatcher) + IPacketDispatcher packetDispatcher, + IDedicatedInstance dedicatedInstance) { _playerRegistry = playerRegistry; _packetDispatcher = packetDispatcher; + _instance = dedicatedInstance; } public override void Handle(IPlayer sender, RequestKickPlayerPacket packet) @@ -29,10 +29,7 @@ public override void Handle(IPlayer sender, RequestKickPlayerPacket packet) ); if (sender.CanKickVote) if (_playerRegistry.TryGetPlayer(packet.KickedPlayerId, out var kickedPlayer)) - _packetDispatcher.SendToPlayer(kickedPlayer, new KickPlayerPacket - { - DisconnectedReason = DisconnectedReason.Kicked - }, IgnoranceChannelTypes.Reliable); + _instance.DisconnectPlayer(kickedPlayer); } }