From 509f8f78512a09bc2f20ac493fc9140cf32f12a2 Mon Sep 17 00:00:00 2001 From: themode Date: Sun, 14 Mar 2021 21:34:38 +0100 Subject: [PATCH] Fix player not being directly disconnected after a kick --- src/main/java/net/minestom/server/entity/Player.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index 026a81569..07a31d2d2 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -4,7 +4,6 @@ import com.google.common.collect.Queues; import net.minestom.server.MinecraftServer; import net.minestom.server.advancements.AdvancementTab; import net.minestom.server.attribute.Attribute; -import net.minestom.server.attribute.AttributeInstance; import net.minestom.server.bossbar.BossBar; import net.minestom.server.chat.ChatParser; import net.minestom.server.chat.ColoredText; @@ -1726,8 +1725,13 @@ public class Player extends LivingEntity implements CommandSender { disconnectPacket = new DisconnectPacket(text); } - playerConnection.sendPacket(disconnectPacket); - playerConnection.refreshOnline(false); + if (playerConnection instanceof NettyPlayerConnection) { + ((NettyPlayerConnection) playerConnection).writeAndFlush(disconnectPacket); + playerConnection.disconnect(); + } else { + playerConnection.sendPacket(disconnectPacket); + playerConnection.refreshOnline(false); + } } /**