2222import org .mvplugins .multiverse .inventories .profile .group .WorldGroupManager ;
2323import org .mvplugins .multiverse .inventories .util .MVInvi18n ;
2424
25+ import java .util .Collection ;
2526import java .util .List ;
2627import java .util .Set ;
2728
@@ -44,7 +45,7 @@ class InfoCommand extends InventoriesCommand {
4445
4546 @ Subcommand ("info" )
4647 @ CommandPermission ("multiverse.inventories.info" )
47- @ CommandCompletion ("@mvworlds" )
48+ @ CommandCompletion ("@mvworlds|@worldGroups " )
4849 @ Syntax ("<world|group>" )
4950 @ Description ("World and Group Information" )
5051 void onInfoCommand (
@@ -81,39 +82,26 @@ void onInfoCommand(
8182 }
8283
8384 private void groupInfo (MVCommandIssuer issuer , WorldGroup worldGroup ) {
84- StringBuilder worldsString = new StringBuilder ();
8585 Set <String > worlds = worldGroup .getConfigWorlds ();
86- if (worlds .isEmpty ()) {
87- worldsString .append ("N/A" );
88- } else {
89- for (String world : worlds ) {
90- if (!worldsString .toString ().isEmpty ()) {
91- worldsString .append (", " );
92- }
93- worldsString .append (world );
94- }
95- }
96- //todo: Better messaging formatting here
97- issuer .sendMessage ("Applicable Worlds: " + StringFormatter .join (worldGroup .getApplicableWorlds (), ", " ));
98- issuer .sendInfo (MVInvi18n .INFO_GROUP_INFO , replace ("{worlds}" ).with (worldsString ));
99- issuer .sendInfo (MVInvi18n .INFO_GROUP_INFOSHARES , replace ("{shares}" ).with (worldGroup .getShares ()));
86+ issuer .sendMessage (MVInvi18n .INFO_GROUP_INFO , replace ("{worlds}" ).with (formatStringList (worlds )));
87+ issuer .sendMessage (MVInvi18n .INFO_GROUP_APPLICABLEWORLDS , replace ("{worlds}" ).with (formatStringList (worldGroup .getApplicableWorlds ())));
88+ issuer .sendMessage (MVInvi18n .INFO_GROUP_INFOSHARES , replace ("{shares}" ).with (worldGroup .getShares ()));
89+ issuer .sendMessage (MVInvi18n .INFO_GROUP_APPLICABLESHARES , replace ("{shares}" ).with (worldGroup .getApplicableShares ()));
10090 }
10191
10292 private void worldInfo (MVCommandIssuer issuer , ProfileContainer worldProfileContainer ) {
103- StringBuilder groupsString = new StringBuilder ();
104- List <WorldGroup > worldGroups = worldGroupManager .getGroupsForWorld (worldProfileContainer .getContainerName ());
93+ List <String > worldGroupNames = worldGroupManager .getGroupsForWorld (worldProfileContainer .getContainerName ())
94+ .stream ()
95+ .map (WorldGroup ::getName )
96+ .toList ();
97+ issuer .sendInfo (MVInvi18n .INFO_WORLD_INFO , replace ("{groups}" ).with (formatStringList (worldGroupNames )));
98+ }
10599
106- if (worldGroups .isEmpty ()) {
107- groupsString .append ("N/A" );
108- } else {
109- for (WorldGroup worldGroup : worldGroups ) {
110- if (!groupsString .toString ().isEmpty ()) {
111- groupsString .append (", " );
112- }
113- groupsString .append (worldGroup .getName ());
114- }
100+ private String formatStringList (Collection <String > worlds ) {
101+ if (worlds .isEmpty ()) {
102+ return "&7N/A" ;
115103 }
116- issuer . sendInfo ( MVInvi18n . INFO_WORLD_INFO , replace ( "{groups}" ). with ( groupsString ) );
104+ return StringFormatter . join ( worlds , ", " );
117105 }
118106
119107 @ Service
0 commit comments