From ed6c339eb81c29acad44c53ceec3124a2b4a5bba Mon Sep 17 00:00:00 2001 From: Bixilon Date: Thu, 3 Sep 2020 18:42:13 +0200 Subject: [PATCH] fix encryption --- .../de/bixilon/minosoft/protocol/network/Network.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/de/bixilon/minosoft/protocol/network/Network.java b/src/main/java/de/bixilon/minosoft/protocol/network/Network.java index 1baaccd52..391a4f03a 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/network/Network.java +++ b/src/main/java/de/bixilon/minosoft/protocol/network/Network.java @@ -17,6 +17,7 @@ import de.bixilon.minosoft.logging.Log; import de.bixilon.minosoft.protocol.packets.ClientboundPacket; import de.bixilon.minosoft.protocol.packets.ServerboundPacket; import de.bixilon.minosoft.protocol.packets.clientbound.interfaces.PacketCompressionInterface; +import de.bixilon.minosoft.protocol.packets.clientbound.login.PacketEncryptionRequest; import de.bixilon.minosoft.protocol.packets.clientbound.login.PacketLoginSuccess; import de.bixilon.minosoft.protocol.packets.serverbound.login.PacketEncryptionResponse; import de.bixilon.minosoft.protocol.protocol.*; @@ -126,6 +127,8 @@ public class Network { // enable encryption secretKey = ((PacketEncryptionResponse) packet).getSecretKey(); enableEncryption(secretKey); + // wake up other thread + socketRThread.interrupt(); } } } catch (IOException | InterruptedException ignored) { @@ -208,6 +211,14 @@ public class Network { connection.setConnectionState(ConnectionStates.PLAY); } else if (packetInstance instanceof PacketCompressionInterface) { compressionThreshold = ((PacketCompressionInterface) packetInstance).getThreshold(); + } else if (packetInstance instanceof PacketEncryptionRequest) { + // wait until response is ready + connection.handle(packetInstance); + try { + Thread.sleep(Integer.MAX_VALUE); + } catch (InterruptedException ignored) { + } + continue; } connection.handle(packetInstance); } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {