@@ -182,8 +182,10 @@ public abstract class AbstractTabOverlayHandler implements PacketHandler, TabOve
182182 protected boolean active ;
183183
184184 private final Either <String , BaseComponent > emptyEither ;
185+ private final Either <String , Team .NameTagVisibility > nameTagVisibilityAlways ;
186+ private final Either <String , Team .CollisionRule > collisionRuleAlways ;
185187
186- public AbstractTabOverlayHandler (Logger logger , Executor eventLoopExecutor , UUID viewerUuid , boolean is18 , boolean is13OrLater , boolean is119OrLater ) {
188+ public AbstractTabOverlayHandler (Logger logger , Executor eventLoopExecutor , UUID viewerUuid , boolean is18 , boolean is13OrLater , boolean is119OrLater , boolean is1215OrLater ) {
187189 this .logger = logger ;
188190 this .eventLoopExecutor = eventLoopExecutor ;
189191 this .viewerUuid = viewerUuid ;
@@ -197,6 +199,13 @@ public AbstractTabOverlayHandler(Logger logger, Executor eventLoopExecutor, UUID
197199 } else {
198200 emptyEither = Either .left ("" );
199201 }
202+ if (is1215OrLater ) {
203+ nameTagVisibilityAlways = Either .right (Team .NameTagVisibility .ALWAYS );
204+ collisionRuleAlways = Either .right (Team .CollisionRule .ALWAYS );
205+ } else {
206+ nameTagVisibilityAlways = Either .left ("always" );
207+ collisionRuleAlways = Either .left ("always" );
208+ }
200209 }
201210
202211 protected abstract void sendPacket (DefinedPacket packet );
@@ -983,7 +992,7 @@ PacketListenerResult onPlayerListPacket(PlayerListItem packet) {
983992 // 2. add player to correct team
984993 sendPacket (createPacketTeamAddPlayers (playerTeamName , new String []{slotUsername [index ]}));
985994 // 3. reset custom slot team
986- sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , Team . NameTagVisibility . ALWAYS , Team . CollisionRule . ALWAYS , is13OrLater ? 21 : 0 , (byte ) 1 ));
995+ sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , nameTagVisibilityAlways , collisionRuleAlways , is13OrLater ? 21 : 0 , (byte ) 1 ));
987996 }
988997 }
989998
@@ -1059,7 +1068,7 @@ void onTeamPacketPreprocess(Team packet) {
10591068 int slot = playerUsernameToSlotMap .getInt (playerName );
10601069 if (slot != -1 ) {
10611070 // reset slot team
1062- sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [slot ], emptyEither , emptyEither , emptyEither , Team . NameTagVisibility . ALWAYS , Team . CollisionRule . ALWAYS , is13OrLater ? 21 : 0 , (byte ) 1 ));
1071+ sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [slot ], emptyEither , emptyEither , emptyEither , nameTagVisibilityAlways , collisionRuleAlways , is13OrLater ? 21 : 0 , (byte ) 1 ));
10631072 }
10641073 }
10651074 }
@@ -1137,7 +1146,7 @@ PacketListenerResult onTeamPacket(Team packet) {
11371146 filteredPlayers [j ++] = playerName ;
11381147 } else {
11391148 // reset slot team
1140- sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [slot ], emptyEither , emptyEither , emptyEither , Team . NameTagVisibility . ALWAYS , Team . CollisionRule . ALWAYS , is13OrLater ? 21 : 0 , (byte ) 1 ));
1149+ sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [slot ], emptyEither , emptyEither , emptyEither , nameTagVisibilityAlways , collisionRuleAlways , is13OrLater ? 21 : 0 , (byte ) 1 ));
11411150 }
11421151 }
11431152 packet .setPlayers (filteredPlayers );
@@ -1211,7 +1220,7 @@ void onServerSwitch() {
12111220 // 1. remove player from team
12121221 sendPacket (createPacketTeamRemovePlayers (CUSTOM_SLOT_TEAMNAME [index ], new String []{slotUsername [index ]}));
12131222 // reset slot team
1214- sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , Team . NameTagVisibility . ALWAYS , Team . CollisionRule . ALWAYS , is13OrLater ? 21 : 0 , (byte ) 1 ));
1223+ sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , nameTagVisibilityAlways , collisionRuleAlways , is13OrLater ? 21 : 0 , (byte ) 1 ));
12151224 }
12161225
12171226 // 2. create new custom slot
@@ -1314,12 +1323,12 @@ private void createTeamsIfNecessary() {
13141323 if (!hasCreatedCustomTeams ) {
13151324 hasCreatedCustomTeams = true ;
13161325
1317- sendPacket (createPacketTeamCreate (CUSTOM_SLOT_TEAMNAME [0 ], emptyEither , emptyEither , emptyEither , Team . NameTagVisibility . ALWAYS , Team . CollisionRule . ALWAYS , is13OrLater ? 21 : 0 , (byte ) 1 , new String []{CUSTOM_SLOT_USERNAME [0 ], CUSTOM_SLOT_USERNAME_SMILEYS [0 ], "" }));
1326+ sendPacket (createPacketTeamCreate (CUSTOM_SLOT_TEAMNAME [0 ], emptyEither , emptyEither , emptyEither , nameTagVisibilityAlways , collisionRuleAlways , is13OrLater ? 21 : 0 , (byte ) 1 , new String []{CUSTOM_SLOT_USERNAME [0 ], CUSTOM_SLOT_USERNAME_SMILEYS [0 ], "" }));
13181327
13191328 for (int i = 1 ; i < 80 ; i ++) {
1320- sendPacket (createPacketTeamCreate (CUSTOM_SLOT_TEAMNAME [i ], emptyEither , emptyEither , emptyEither , Team . NameTagVisibility . ALWAYS , Team . CollisionRule . ALWAYS , is13OrLater ? 21 : 0 , (byte ) 1 , new String []{CUSTOM_SLOT_USERNAME [i ], CUSTOM_SLOT_USERNAME_SMILEYS [i ]}));
1329+ sendPacket (createPacketTeamCreate (CUSTOM_SLOT_TEAMNAME [i ], emptyEither , emptyEither , emptyEither , nameTagVisibilityAlways , collisionRuleAlways , is13OrLater ? 21 : 0 , (byte ) 1 , new String []{CUSTOM_SLOT_USERNAME [i ], CUSTOM_SLOT_USERNAME_SMILEYS [i ]}));
13211330 }
1322- sendPacket (createPacketTeamCreate (CUSTOM_SLOT_TEAMNAME [80 ], emptyEither , emptyEither , emptyEither , Team . NameTagVisibility . ALWAYS , Team . CollisionRule . ALWAYS , is13OrLater ? 21 : 0 , (byte ) 1 , new String []{CUSTOM_SLOT_USERNAME [80 ]}));
1331+ sendPacket (createPacketTeamCreate (CUSTOM_SLOT_TEAMNAME [80 ], emptyEither , emptyEither , emptyEither , nameTagVisibilityAlways , collisionRuleAlways , is13OrLater ? 21 : 0 , (byte ) 1 , new String []{CUSTOM_SLOT_USERNAME [80 ]}));
13231332 }
13241333 }
13251334
@@ -1338,7 +1347,7 @@ void onDeactivated() {
13381347 // 2. add player to correct team
13391348 sendPacket (createPacketTeamAddPlayers (playerTeamName , new String []{slotUsername [index ]}));
13401349 // 3. reset custom slot team
1341- sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , Team . NameTagVisibility . ALWAYS , Team . CollisionRule . ALWAYS , is13OrLater ? 21 : 0 , (byte ) 1 ));
1350+ sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , nameTagVisibilityAlways , collisionRuleAlways , is13OrLater ? 21 : 0 , (byte ) 1 ));
13421351 }
13431352 } else {
13441353 customSlots ++;
@@ -1470,7 +1479,7 @@ void update() {
14701479 // 2. add player to correct team
14711480 sendPacket (createPacketTeamAddPlayers (playerTeamName , new String []{slotUsername [index ]}));
14721481 // 3. reset custom slot team
1473- sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , Team . NameTagVisibility . ALWAYS , Team . CollisionRule . ALWAYS , is13OrLater ? 21 : 0 , (byte ) 1 ));
1482+ sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , nameTagVisibilityAlways , collisionRuleAlways , is13OrLater ? 21 : 0 , (byte ) 1 ));
14741483 } else {
14751484 // 2. add player to overflow team
14761485 sendPacket (createPacketTeamAddPlayers (CUSTOM_SLOT_TEAMNAME [80 ], new String []{slotUsername [index ]}));
@@ -1658,7 +1667,7 @@ void update() {
16581667 playerUsernameToSlotMap .removeInt (slotUsername [index ]);
16591668
16601669 // reset slot team
1661- sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , Team . NameTagVisibility . ALWAYS , Team . CollisionRule . ALWAYS , is13OrLater ? 21 : 0 , (byte ) 1 ));
1670+ sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , nameTagVisibilityAlways , collisionRuleAlways , is13OrLater ? 21 : 0 , (byte ) 1 ));
16621671 }
16631672
16641673 // 2. update slot state
@@ -1679,7 +1688,7 @@ void update() {
16791688 playerUsernameToSlotMap .removeInt (slotUsername [index ]);
16801689
16811690 // reset slot team
1682- sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , Team . NameTagVisibility . ALWAYS , Team . CollisionRule . ALWAYS , is13OrLater ? 21 : 0 , (byte ) 1 ));
1691+ sendPacket (createPacketTeamUpdate (CUSTOM_SLOT_TEAMNAME [index ], emptyEither , emptyEither , emptyEither , nameTagVisibilityAlways , collisionRuleAlways , is13OrLater ? 21 : 0 , (byte ) 1 ));
16831692 }
16841693
16851694 freePlayers .add (slotUuid [index ]);
@@ -2476,7 +2485,7 @@ private static String[][] toPropertiesArray(ProfileProperty textureProperty) {
24762485 }
24772486 }
24782487
2479- private static Team createPacketTeamCreate (String name , Either <String , BaseComponent > displayName , Either <String , BaseComponent > prefix , Either <String , BaseComponent > suffix , Team .NameTagVisibility nameTagVisibility , Team .CollisionRule collisionRule , int color , byte friendlyFire , String [] players ) {
2488+ private static Team createPacketTeamCreate (String name , Either <String , BaseComponent > displayName , Either <String , BaseComponent > prefix , Either <String , BaseComponent > suffix , Either < String , Team .NameTagVisibility > nameTagVisibility , Either < String , Team .CollisionRule > collisionRule , int color , byte friendlyFire , String [] players ) {
24802489 Team team = new Team ();
24812490 team .setName (name );
24822491 team .setMode ((byte ) 0 );
@@ -2498,7 +2507,7 @@ private static Team createPacketTeamRemove(String name) {
24982507 return team ;
24992508 }
25002509
2501- private static Team createPacketTeamUpdate (String name , Either <String , BaseComponent > displayName , Either <String , BaseComponent > prefix , Either <String , BaseComponent > suffix , Team .NameTagVisibility nameTagVisibility , Team .CollisionRule collisionRule , int color , byte friendlyFire ) {
2510+ private static Team createPacketTeamUpdate (String name , Either <String , BaseComponent > displayName , Either <String , BaseComponent > prefix , Either <String , BaseComponent > suffix , Either < String , Team .NameTagVisibility > nameTagVisibility , Either < String , Team .CollisionRule > collisionRule , int color , byte friendlyFire ) {
25022511 Team team = new Team ();
25032512 team .setName (name );
25042513 team .setMode ((byte ) 2 );
@@ -2555,8 +2564,8 @@ static class TeamEntry {
25552564 private Either <String , BaseComponent > prefix ;
25562565 private Either <String , BaseComponent > suffix ;
25572566 private byte friendlyFire ;
2558- private Team .NameTagVisibility nameTagVisibility ;
2559- private Team .CollisionRule collisionRule ;
2567+ private Either < String , Team .NameTagVisibility > nameTagVisibility ;
2568+ private Either < String , Team .CollisionRule > collisionRule ;
25602569 private int color ;
25612570 private Set <String > players = new ObjectOpenHashSet <>();
25622571
0 commit comments