6262
6363public class UserInfoCommands extends CommunityCommand {
6464
65+ private static final int MAX_ALTS_PER_MESSAGE = 12 ;
66+
6567 private final UsersFeature users ;
6668 private final ModerationFeature moderation ;
6769 private final FriendshipFeature friends ;
@@ -144,7 +146,7 @@ public void viewAlts(CommandAudience audience, @Argument("target") TargetPlayer
144146 return ;
145147 }
146148
147- Set <Component > altNames = alts .stream ()
149+ List <Component > altNames = alts .stream ()
148150 .map (altId -> {
149151 Component name = users .renderUsername (altId , NameStyle .COLOR ).join ();
150152
@@ -156,20 +158,7 @@ public void viewAlts(CommandAudience audience, @Argument("target") TargetPlayer
156158 .append (name )))
157159 .build ();
158160 })
159- .collect (Collectors .toSet ());
160-
161- Component numberOfAlts = text (alts .size (), NamedTextColor .YELLOW , TextDecoration .BOLD );
162-
163- Component altNameList = text ()
164- .append (targetPlayer )
165- .append (text (" has " ))
166- .append (numberOfAlts )
167- .append (text (" known alternate account" ))
168- .append (text (alts .size () != 1 ? "s" : "" ))
169- .append (text (": " ))
170- .append (TextFormatter .list (altNames , NamedTextColor .GRAY ))
171- .color (NamedTextColor .GRAY )
172- .build ();
161+ .collect (Collectors .toList ());
173162
174163 List <Component > altsWithBans = alts .stream ()
175164 .filter (altId -> moderation .isBanned (altId .toString ()).join ())
@@ -186,22 +175,55 @@ public void viewAlts(CommandAudience audience, @Argument("target") TargetPlayer
186175 })
187176 .collect (Collectors .toList ());
188177
189- Component numberOfBannedAlts =
190- text (altsWithBans .size (), NamedTextColor .YELLOW , TextDecoration .BOLD );
191-
192- Component altBans = text ()
193- .append (numberOfBannedAlts )
194- .append (text (" of these accounts are currently banned: " ))
195- .append (TextFormatter .list (altsWithBans , NamedTextColor .GRAY ))
196- .color (NamedTextColor .GRAY )
197- .build ();
198- audience .sendMessage (altNameList );
178+ sendTargetAltList (audience , targetPlayer , altNames , alts .size ());
199179 if (!altsWithBans .isEmpty ()) {
200- audience . sendMessage ( altBans );
180+ sendTargetBannedAltList ( audience , altsWithBans );
201181 }
202182 });
203183 }
204184
185+ private void sendTargetAltList (
186+ CommandAudience audience , Component targetPlayer , List <Component > altNames , int totalAlts ) {
187+ List <List <Component >> chunks = Lists .partition (altNames , MAX_ALTS_PER_MESSAGE );
188+
189+ Component numberOfAlts = text (totalAlts , NamedTextColor .YELLOW , TextDecoration .BOLD );
190+ audience .sendMessage (text ()
191+ .append (targetPlayer )
192+ .append (text (" has " ))
193+ .append (numberOfAlts )
194+ .append (text (" known alternate account" ))
195+ .append (text (totalAlts != 1 ? "s" : "" ))
196+ .append (text (":" ))
197+ .color (NamedTextColor .GRAY )
198+ .build ());
199+
200+ for (List <Component > chunk : chunks ) {
201+ audience .sendMessage (text ()
202+ .append (TextFormatter .list (chunk , NamedTextColor .GRAY ))
203+ .color (NamedTextColor .GRAY )
204+ .build ());
205+ }
206+ }
207+
208+ private void sendTargetBannedAltList (CommandAudience audience , List <Component > altsWithBans ) {
209+ List <List <Component >> chunks = Lists .partition (altsWithBans , MAX_ALTS_PER_MESSAGE );
210+
211+ Component numberOfBannedAlts =
212+ text (altsWithBans .size (), NamedTextColor .YELLOW , TextDecoration .BOLD );
213+ audience .sendMessage (text ()
214+ .append (numberOfBannedAlts )
215+ .append (text (" of these accounts are currently banned:" ))
216+ .color (NamedTextColor .GRAY )
217+ .build ());
218+
219+ for (List <Component > chunk : chunks ) {
220+ audience .sendMessage (text ()
221+ .append (TextFormatter .list (chunk , NamedTextColor .GRAY ))
222+ .color (NamedTextColor .GRAY )
223+ .build ());
224+ }
225+ }
226+
205227 @ Command ("altscore|altrisk <target> [allSignals] [allAccounts]" )
206228 @ CommandDescription ("Analyze alt-evasion risk for a player" )
207229 @ Permission (CommunityPermissions .LOOKUP_OTHERS )
@@ -244,10 +266,12 @@ public void viewAltScore(
244266
245267 int signalLimit = 3 ;
246268 audience .sendMessage (formatInfoField (allSignals ? "All Signals" : "Top Signals" , empty ()));
247- audience .sendMessage (formatListItems (summary .signals ().stream ()
248- .limit (allSignals ? Long .MAX_VALUE : signalLimit )
249- .map (this ::formatSignal )
250- .collect (Collectors .toList ())));
269+ sendListItems (
270+ audience ,
271+ summary .signals ().stream ()
272+ .limit (allSignals ? Long .MAX_VALUE : signalLimit )
273+ .map (this ::formatSignal )
274+ .collect (Collectors .toList ()));
251275 if (!allSignals && summary .signals ().size () > signalLimit ) {
252276 audience .sendMessage (text ()
253277 .append (text (" " ))
@@ -266,14 +290,16 @@ public void viewAltScore(
266290 int accountLimit = 3 ;
267291 audience .sendMessage (formatInfoField (
268292 allAccounts ? "All Linked Accounts" : "Likely Linked Accounts" , empty ()));
269- audience .sendMessage (formatListItems (summary .linkedAccounts ().stream ()
270- .limit (allAccounts ? Long .MAX_VALUE : accountLimit )
271- .map (account -> formatLinkedAccount (
272- account ,
273- summary .signals ().stream ()
274- .filter (s -> s .linkedAccountId ().equals (account .accountId ()))
275- .collect (Collectors .toList ())))
276- .collect (Collectors .toList ())));
293+ sendListItems (
294+ audience ,
295+ summary .linkedAccounts ().stream ()
296+ .limit (allAccounts ? Long .MAX_VALUE : accountLimit )
297+ .map (account -> formatLinkedAccount (
298+ account ,
299+ summary .signals ().stream ()
300+ .filter (s -> s .linkedAccountId ().equals (account .accountId ()))
301+ .collect (Collectors .toList ())))
302+ .collect (Collectors .toList ()));
277303 if (!allAccounts && summary .linkedAccounts ().size () > accountLimit ) {
278304 audience .sendMessage (text ()
279305 .append (text (" " ))
@@ -384,12 +410,14 @@ private void displayProfile(
384410 viewableIps = viewableIps .subList (0 , Math .min (ips .size (), MAX_VIEWABLE ));
385411 }
386412 audience .sendMessage (knownIPs .append (text ("(" + ips .size () + ")" , NamedTextColor .GRAY )));
387- audience .sendMessage (formatListItems (viewableIps .stream ()
388- .map (ip -> text ()
389- .append (text (" - " , NamedTextColor .YELLOW ))
390- .append (text (ip , NamedTextColor .DARK_AQUA ))
391- .build ())
392- .collect (Collectors .toList ())));
413+ sendListItems (
414+ audience ,
415+ viewableIps .stream ()
416+ .map (ip -> text ()
417+ .append (text (" - " , NamedTextColor .YELLOW ))
418+ .append (text (ip , NamedTextColor .DARK_AQUA ))
419+ .build ())
420+ .collect (Collectors .toList ()));
393421 if (ips .size () > MAX_VIEWABLE && !viewAll ) {
394422 audience .sendMessage (text ()
395423 .append (text (ips .size () - MAX_VIEWABLE , NamedTextColor .YELLOW , TextDecoration .BOLD ))
@@ -478,8 +506,8 @@ private Component formatDateWithHover(Instant pastDate) {
478506 .build ();
479507 }
480508
481- private Component formatListItems ( Collection <Component > components ) {
482- return Component . join ( separator ( newline ()), components );
509+ private void sendListItems ( CommandAudience audience , Collection <Component > components ) {
510+ components . forEach ( audience :: sendMessage );
483511 }
484512
485513 private Component formatInfoField (String field , Component value ) {
0 commit comments