Fix 1.19.3 compat of removed public key on login

Fixes #951
This commit is contained in:
games647
2022-12-18 14:04:43 +01:00
parent ca17c3f377
commit 1038453469

View File

@ -179,7 +179,8 @@ public class ProtocolLibListener extends PacketAdapter {
private boolean verifyNonce(Player sender, PacketContainer packet,
ClientPublicKey clientPublicKey, byte[] expectedToken) {
try {
if (MinecraftVersion.atOrAbove(new MinecraftVersion(1, 19, 0))) {
if (MinecraftVersion.atOrAbove(new MinecraftVersion(1, 19, 0))
&& !MinecraftVersion.atOrAbove(new MinecraftVersion(1, 19, 3))) {
Either<byte[], ?> either = packet.getSpecificModifier(Either.class).read(0);
if (clientPublicKey == null) {
Optional<byte[]> left = either.left();
@ -222,10 +223,15 @@ public class ProtocolLibListener extends PacketAdapter {
plugin.removeSession(player.getAddress());
PacketContainer packet = packetEvent.getPacket();
Optional<ClientPublicKey> clientKey = Optional.empty();
if (MinecraftVersion.atOrAbove(new MinecraftVersion(1, 19, 3))) {
// public key sent separate
clientKey = Optional.empty();
} else {
val profileKey = packet.getOptionals(BukkitConverters.getWrappedPublicKeyDataConverter())
.optionRead(0);
val clientKey = profileKey.flatMap(Function.identity()).flatMap(data -> {
clientKey = profileKey.flatMap(Function.identity()).flatMap(data -> {
Instant expires = data.getExpireTime();
PublicKey key = data.getKey();
byte[] signature = data.getSignature();
@ -242,6 +248,8 @@ public class ProtocolLibListener extends PacketAdapter {
plugin.getLog().warn("Invalid public key from player {}", username);
return;
}
}
plugin.getLog().trace("GameProfile {} with {} connecting", sessionKey, username);