From c9be13d487226c9cef61826d190d8b4444b7c40d Mon Sep 17 00:00:00 2001 From: SupremeMortal <6178101+SupremeMortal@users.noreply.github.com> Date: Fri, 13 Sep 2019 15:45:55 +0100 Subject: [PATCH] Fix AIOOBE and remove PlayerSession usage. --- .../network/ConnectorServerEventHandler.java | 1 + .../network/session/GeyserSession.java | 17 +---------------- .../java/world/JavaChunkDataTranslator.java | 2 +- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java b/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java index d89151bc9..2cc317b51 100644 --- a/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java @@ -109,6 +109,7 @@ public class ConnectorServerEventHandler implements BedrockServerEventHandler { Player player = connector.getPlayers().get(bedrockServerSession.getAddress()); if (player != null) { player.disconnect(disconnectReason.name()); + connector.removePlayer(player); } }); bedrockServerSession.setPacketCodec(GeyserConnector.BEDROCK_PACKET_CODEC); 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 8503bb52b..0872c0772 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 @@ -38,8 +38,6 @@ import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; import com.github.steveice10.packetlib.event.session.SessionAdapter; import com.github.steveice10.packetlib.packet.Packet; import com.github.steveice10.packetlib.tcp.TcpSessionFactory; -import com.nukkitx.network.util.DisconnectReason; -import com.nukkitx.protocol.PlayerSession; import com.nukkitx.protocol.bedrock.BedrockServerSession; import com.nukkitx.protocol.bedrock.data.GamePublishSetting; import com.nukkitx.protocol.bedrock.data.GameRule; @@ -64,7 +62,7 @@ import java.net.InetSocketAddress; import java.util.UUID; @Getter -public class GeyserSession implements PlayerSession, Player { +public class GeyserSession implements Player { private final GeyserConnector connector; private final BedrockServerSession upstream; @@ -188,27 +186,14 @@ public class GeyserSession implements PlayerSession, Player { closed = true; } - @Override public boolean isClosed() { return closed; } - @Override public void close() { disconnect("Server closed."); } - @Override - public void onDisconnect(DisconnectReason disconnectReason) { - downstream.getSession().disconnect("Disconnected from server. Reason: " + disconnectReason); - } - - @Override - public void onDisconnect(String reason) { - downstream.getSession().disconnect("Disconnected from server. Reason: " + reason); - connector.removePlayer(this); - } - public void setAuthenticationData(AuthData authData) { authenticationData = authData; } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java index 9313102ca..815d1742f 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java @@ -40,7 +40,7 @@ public class JavaChunkDataTranslator extends PacketTranslator= 0 && sections[sectionCount].isEmpty()) { sectionCount--; } sectionCount++;