Skip to content

Commit 716f229

Browse files
authored
Support shouldAuthenticate = false (#856)
1 parent e2af5db commit 716f229

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/ClientListener.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.io.IOException;
4646
import java.security.NoSuchAlgorithmException;
4747
import java.util.Collections;
48+
import java.util.Objects;
4849

4950
/**
5051
* Handles making initial login and status requests for clients.
@@ -63,7 +64,7 @@ public void packetReceived(Session session, Packet packet) {
6364
GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY);
6465
String accessToken = session.getFlag(MinecraftConstants.ACCESS_TOKEN_KEY);
6566

66-
if (profile == null || accessToken == null) {
67+
if ((profile == null || accessToken == null) && helloPacket.isShouldAuthenticate()) {
6768
throw new UnexpectedEncryptionException();
6869
}
6970

@@ -81,7 +82,9 @@ public void packetReceived(Session session, Packet packet) {
8182

8283
// TODO: Add generic error, disabled multiplayer and banned from playing online errors
8384
try {
84-
sessionService.joinServer(profile, accessToken, serverId);
85+
if (helloPacket.isShouldAuthenticate()) {
86+
sessionService.joinServer(Objects.requireNonNull(profile, "final shouldAuthenticate changed value?"), accessToken, serverId);
87+
}
8588
} catch (IOException e) {
8689
session.disconnect(Component.translatable("disconnect.loginFailedInfo", Component.text(e.getMessage())), e);
8790
return;

0 commit comments

Comments
 (0)