2424package com .lunarclient .apollo .module .team ;
2525
2626import com .lunarclient .apollo .common .ApolloComponent ;
27+ import com .lunarclient .apollo .common .location .ApolloLocation ;
2728import com .lunarclient .apollo .network .NetworkTypes ;
2829import com .lunarclient .apollo .player .AbstractApolloPlayer ;
2930import com .lunarclient .apollo .recipients .Recipients ;
3031import com .lunarclient .apollo .team .v1 .ResetTeamMembersMessage ;
3132import com .lunarclient .apollo .team .v1 .UpdateTeamMembersMessage ;
33+ import java .awt .Color ;
3234import java .util .List ;
3335import java .util .stream .Collectors ;
3436import lombok .NonNull ;
37+ import net .kyori .adventure .text .Component ;
3538
3639/**
3740 * Provides the teams module.
@@ -43,13 +46,7 @@ public final class TeamModuleImpl extends TeamModule {
4346 @ Override
4447 public void updateTeamMembers (@ NonNull Recipients recipients , @ NonNull List <TeamMember > teamMembers ) {
4548 List <com .lunarclient .apollo .team .v1 .TeamMember > teamMembersProto = teamMembers .stream ()
46- .map (teamMember -> com .lunarclient .apollo .team .v1 .TeamMember .newBuilder ()
47- .setPlayerUuid (NetworkTypes .toProtobuf (teamMember .getPlayerUuid ()))
48- .setAdventureJsonPlayerName (ApolloComponent .toJson (teamMember .getDisplayName ()))
49- .setLocation (NetworkTypes .toProtobuf (teamMember .getLocation ()))
50- .setMarkerColor (NetworkTypes .toProtobuf (teamMember .getMarkerColor ()))
51- .build ()
52- )
49+ .map (this ::toProtobuf )
5350 .collect (Collectors .toList ());
5451
5552 UpdateTeamMembersMessage message = UpdateTeamMembersMessage .newBuilder ()
@@ -65,4 +62,26 @@ public void resetTeamMembers(@NonNull Recipients recipients) {
6562 recipients .forEach (player -> ((AbstractApolloPlayer ) player ).sendPacket (message ));
6663 }
6764
65+ private com .lunarclient .apollo .team .v1 .TeamMember toProtobuf (TeamMember member ) {
66+ com .lunarclient .apollo .team .v1 .TeamMember .Builder builder = com .lunarclient .apollo .team .v1 .TeamMember .newBuilder ()
67+ .setPlayerUuid (NetworkTypes .toProtobuf (member .getPlayerUuid ()));
68+
69+ Component displayName = member .getDisplayName ();
70+ if (displayName != null ) {
71+ builder .setAdventureJsonPlayerName (ApolloComponent .toJson (displayName ));
72+ }
73+
74+ Color markerColor = member .getMarkerColor ();
75+ if (markerColor != null ) {
76+ builder .setMarkerColor (NetworkTypes .toProtobuf (markerColor ));
77+ }
78+
79+ ApolloLocation location = member .getLocation ();
80+ if (location != null ) {
81+ builder .setLocation (NetworkTypes .toProtobuf (location ));
82+ }
83+
84+ return builder .build ();
85+ }
86+
6887}
0 commit comments