@@ -179,7 +179,8 @@ private void onEncryptionBegin(PacketEvent packetEvent, Player sender) {
179179 private boolean verifyNonce (Player sender , PacketContainer packet ,
180180 ClientPublicKey clientPublicKey , byte [] expectedToken ) {
181181 try {
182- if (MinecraftVersion .atOrAbove (new MinecraftVersion (1 , 19 , 0 ))) {
182+ if (MinecraftVersion .atOrAbove (new MinecraftVersion (1 , 19 , 0 ))
183+ && !MinecraftVersion .atOrAbove (new MinecraftVersion (1 , 19 , 3 ))) {
183184 Either <byte [], ?> either = packet .getSpecificModifier (Either .class ).read (0 );
184185 if (clientPublicKey == null ) {
185186 Optional <byte []> left = either .left ();
@@ -222,27 +223,34 @@ private void onLoginStart(PacketEvent packetEvent, Player player, String usernam
222223 plugin .removeSession (player .getAddress ());
223224
224225 PacketContainer packet = packetEvent .getPacket ();
225- val profileKey = packet .getOptionals (BukkitConverters .getWrappedPublicKeyDataConverter ())
226- .optionRead (0 );
227-
228- val clientKey = profileKey .flatMap (Function .identity ()).flatMap (data -> {
229- Instant expires = data .getExpireTime ();
230- PublicKey key = data .getKey ();
231- byte [] signature = data .getSignature ();
232- return Optional .of (ClientPublicKey .of (expires , key , signature ));
233- });
234-
235- // start reading from index 1, because 0 is already used by the public key
236- Optional <UUID > sessionUUID = packet .getOptionals (Converters .passthrough (UUID .class )).readSafely (1 );
237- if (verifyClientKeys && sessionUUID .isPresent () && clientKey .isPresent ()
238- && verifyPublicKey (clientKey .get (), sessionUUID .get ())) {
239- // missing or incorrect
240- // expired always not allowed
241- player .kickPlayer (plugin .getCore ().getMessage ("invalid-public-key" ));
242- plugin .getLog ().warn ("Invalid public key from player {}" , username );
243- return ;
226+ Optional <ClientPublicKey > clientKey = Optional .empty ();
227+ if (MinecraftVersion .atOrAbove (new MinecraftVersion (1 , 19 , 3 ))) {
228+ // public key sent separate
229+ clientKey = Optional .empty ();
230+ } else {
231+ val profileKey = packet .getOptionals (BukkitConverters .getWrappedPublicKeyDataConverter ())
232+ .optionRead (0 );
233+
234+ clientKey = profileKey .flatMap (Function .identity ()).flatMap (data -> {
235+ Instant expires = data .getExpireTime ();
236+ PublicKey key = data .getKey ();
237+ byte [] signature = data .getSignature ();
238+ return Optional .of (ClientPublicKey .of (expires , key , signature ));
239+ });
240+
241+ // start reading from index 1, because 0 is already used by the public key
242+ Optional <UUID > sessionUUID = packet .getOptionals (Converters .passthrough (UUID .class )).readSafely (1 );
243+ if (verifyClientKeys && sessionUUID .isPresent () && clientKey .isPresent ()
244+ && verifyPublicKey (clientKey .get (), sessionUUID .get ())) {
245+ // missing or incorrect
246+ // expired always not allowed
247+ player .kickPlayer (plugin .getCore ().getMessage ("invalid-public-key" ));
248+ plugin .getLog ().warn ("Invalid public key from player {}" , username );
249+ return ;
250+ }
244251 }
245252
253+
246254 plugin .getLog ().trace ("GameProfile {} with {} connecting" , sessionKey , username );
247255
248256 packetEvent .getAsyncMarker ().incrementProcessingDelay ();
0 commit comments