From 8b487df6987f5b374182c49148ba1962d4abb7ff Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sat, 25 Apr 2020 17:53:35 -0500 Subject: [PATCH] Properly remove players from Geyser playerlist (Fixes #421 --- .../geysermc/connector/command/defaults/ReloadCommand.java | 2 +- .../geysermc/connector/network/UpstreamPacketHandler.java | 6 +++--- .../geysermc/connector/network/session/GeyserSession.java | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java index bd8444c79..c38a0c23d 100644 --- a/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java +++ b/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java @@ -48,7 +48,7 @@ public class ReloadCommand extends GeyserCommand { } sender.sendMessage(ChatColor.YELLOW + "Reloading Geyser configurations... all connected bedrock clients will be kicked."); for (GeyserSession session : connector.getPlayers().values()) { - session.getUpstream().disconnect("Geyser has been reloaded... sorry for the inconvenience!"); + session.disconnect("Geyser has been reloaded... sorry for the inconvenience!"); } connector.reload(); } diff --git a/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java b/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java index 4ad4deffa..7e41fca8b 100644 --- a/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java @@ -47,10 +47,10 @@ public class UpstreamPacketHandler extends LoggingPacketHandler { @Override public boolean handle(LoginPacket loginPacket) { if (loginPacket.getProtocolVersion() > GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion()) { - session.getUpstream().disconnect("Outdated Geyser proxy! I'm still on " + GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion()); + session.disconnect("Outdated Geyser proxy! I'm still on " + GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion()); return true; } else if (loginPacket.getProtocolVersion() < GeyserConnector.BEDROCK_PACKET_CODEC.getProtocolVersion()) { - session.getUpstream().disconnect("Outdated Bedrock client! Please use " + GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion()); + session.disconnect("Outdated Bedrock client! Please use " + GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion()); return true; } @@ -80,7 +80,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler { session.getUpstream().sendPacket(stack); break; default: - session.getUpstream().disconnect("disconnectionScreen.resourcePack"); + session.disconnect("disconnectionScreen.resourcePack"); break; } diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 12ae39bfc..fdfc14714 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -330,10 +330,16 @@ public class GeyserSession implements CommandSender { downstream.getSession().disconnect(reason); } if (upstream != null && !upstream.isClosed()) { + connector.getPlayers().remove(this.upstream.getAddress()); upstream.disconnect(reason); } } + this.entityCache.getEntities().clear(); + this.scoreboardCache.removeScoreboard(); + this.inventoryCache.getInventories().clear(); + this.windowCache.getWindows().clear(); + closed = true; }