@@ -521,29 +521,41 @@ public void onPlayerListHeaderFooter(ClientboundTabListPacket packet) {
521
521
522
522
@ EventHandler
523
523
public void onPlayerListUpdate (ClientboundPlayerInfoUpdatePacket packet ) {
524
- for (var update : packet .getEntries ()) {
525
- var entry = playerListState .entries ().computeIfAbsent (update .getProfileId (), k -> update );
524
+ if (packet .getActions ().contains (PlayerListEntryAction .ADD_PLAYER )) {
525
+ for (var entry : packet .getEntries ()) {
526
+ playerListState .entries ().putIfAbsent (entry .getProfileId (), entry );
527
+ }
528
+ }
529
+
530
+ for (var newEntry : packet .getEntries ()) {
531
+ var entry = playerListState .entries ().get (newEntry .getProfileId ());
532
+ if (entry == null ) {
533
+ continue ;
534
+ }
535
+
526
536
for (var action : packet .getActions ()) {
527
537
SFHelpers .mustSupply (() -> switch (action ) {
528
- case ADD_PLAYER -> () -> entry .setProfile (update .getProfile ());
538
+ case ADD_PLAYER -> () -> {
539
+ // Don't handle, just like vanilla
540
+ };
529
541
case INITIALIZE_CHAT -> () -> {
530
- entry .setSessionId (update .getSessionId ());
531
- entry .setExpiresAt (update .getExpiresAt ());
532
- entry .setKeySignature (update .getKeySignature ());
533
- entry .setPublicKey (update .getPublicKey ());
542
+ entry .setSessionId (newEntry .getSessionId ());
543
+ entry .setExpiresAt (newEntry .getExpiresAt ());
544
+ entry .setKeySignature (newEntry .getKeySignature ());
545
+ entry .setPublicKey (newEntry .getPublicKey ());
534
546
};
535
547
case UPDATE_GAME_MODE -> () -> {
536
- if (entry .getGameMode () != update .getGameMode () && localPlayer != null && update .getProfileId ().equals (localPlayer .uuid ())) {
537
- localPlayer .onGameModeChanged (update .getGameMode ());
548
+ if (entry .getGameMode () != newEntry .getGameMode () && localPlayer != null && newEntry .getProfileId ().equals (localPlayer .uuid ())) {
549
+ localPlayer .onGameModeChanged (newEntry .getGameMode ());
538
550
}
539
551
540
- entry .setGameMode (update .getGameMode ());
552
+ entry .setGameMode (newEntry .getGameMode ());
541
553
};
542
- case UPDATE_LISTED -> () -> entry .setListed (update .isListed ());
543
- case UPDATE_LATENCY -> () -> entry .setLatency (update .getLatency ());
544
- case UPDATE_DISPLAY_NAME -> () -> entry .setDisplayName (update .getDisplayName ());
545
- case UPDATE_HAT -> () -> entry .setShowHat (update .isShowHat ());
546
- case UPDATE_LIST_ORDER -> () -> entry .setListOrder (update .getListOrder ());
554
+ case UPDATE_LISTED -> () -> entry .setListed (newEntry .isListed ());
555
+ case UPDATE_LATENCY -> () -> entry .setLatency (newEntry .getLatency ());
556
+ case UPDATE_DISPLAY_NAME -> () -> entry .setDisplayName (newEntry .getDisplayName ());
557
+ case UPDATE_HAT -> () -> entry .setShowHat (newEntry .isShowHat ());
558
+ case UPDATE_LIST_ORDER -> () -> entry .setListOrder (newEntry .getListOrder ());
547
559
});
548
560
}
549
561
}
0 commit comments