diff --git a/src/main/java/org/mvplugins/multiverse/inventories/commands/InfoCommand.java b/src/main/java/org/mvplugins/multiverse/inventories/commands/InfoCommand.java index 287817c5..2f672926 100644 --- a/src/main/java/org/mvplugins/multiverse/inventories/commands/InfoCommand.java +++ b/src/main/java/org/mvplugins/multiverse/inventories/commands/InfoCommand.java @@ -22,6 +22,7 @@ import org.mvplugins.multiverse.inventories.profile.group.WorldGroupManager; import org.mvplugins.multiverse.inventories.util.MVInvi18n; +import java.util.Collection; import java.util.List; import java.util.Set; @@ -44,7 +45,7 @@ class InfoCommand extends InventoriesCommand { @Subcommand("info") @CommandPermission("multiverse.inventories.info") - @CommandCompletion("@mvworlds") + @CommandCompletion("@mvworlds|@worldGroups") @Syntax("") @Description("World and Group Information") void onInfoCommand( @@ -81,39 +82,26 @@ void onInfoCommand( } private void groupInfo(MVCommandIssuer issuer, WorldGroup worldGroup) { - StringBuilder worldsString = new StringBuilder(); Set worlds = worldGroup.getConfigWorlds(); - if (worlds.isEmpty()) { - worldsString.append("N/A"); - } else { - for (String world : worlds) { - if (!worldsString.toString().isEmpty()) { - worldsString.append(", "); - } - worldsString.append(world); - } - } - //todo: Better messaging formatting here - issuer.sendMessage("Applicable Worlds: " + StringFormatter.join(worldGroup.getApplicableWorlds(), ", ")); - issuer.sendInfo(MVInvi18n.INFO_GROUP_INFO, replace("{worlds}").with(worldsString)); - issuer.sendInfo(MVInvi18n.INFO_GROUP_INFOSHARES, replace("{shares}").with(worldGroup.getShares())); + issuer.sendMessage(MVInvi18n.INFO_GROUP_INFO, replace("{worlds}").with(formatStringList(worlds))); + issuer.sendMessage(MVInvi18n.INFO_GROUP_APPLICABLEWORLDS, replace("{worlds}").with(formatStringList(worldGroup.getApplicableWorlds()))); + issuer.sendMessage(MVInvi18n.INFO_GROUP_INFOSHARES, replace("{shares}").with(worldGroup.getShares())); + issuer.sendMessage(MVInvi18n.INFO_GROUP_APPLICABLESHARES, replace("{shares}").with(worldGroup.getApplicableShares())); } private void worldInfo(MVCommandIssuer issuer, ProfileContainer worldProfileContainer) { - StringBuilder groupsString = new StringBuilder(); - List worldGroups = worldGroupManager.getGroupsForWorld(worldProfileContainer.getContainerName()); + List worldGroupNames = worldGroupManager.getGroupsForWorld(worldProfileContainer.getContainerName()) + .stream() + .map(WorldGroup::getName) + .toList(); + issuer.sendInfo(MVInvi18n.INFO_WORLD_INFO, replace("{groups}").with(formatStringList(worldGroupNames))); + } - if (worldGroups.isEmpty()) { - groupsString.append("N/A"); - } else { - for (WorldGroup worldGroup : worldGroups) { - if (!groupsString.toString().isEmpty()) { - groupsString.append(", "); - } - groupsString.append(worldGroup.getName()); - } + private String formatStringList(Collection worlds) { + if (worlds.isEmpty()) { + return "&7N/A"; } - issuer.sendInfo(MVInvi18n.INFO_WORLD_INFO, replace("{groups}").with(groupsString)); + return StringFormatter.join(worlds, ", "); } @Service diff --git a/src/main/java/org/mvplugins/multiverse/inventories/util/MVInvi18n.java b/src/main/java/org/mvplugins/multiverse/inventories/util/MVInvi18n.java index 9610242d..a72e00ea 100644 --- a/src/main/java/org/mvplugins/multiverse/inventories/util/MVInvi18n.java +++ b/src/main/java/org/mvplugins/multiverse/inventories/util/MVInvi18n.java @@ -44,8 +44,9 @@ public enum MVInvi18n implements MessageKeyProvider { INFO_WORLD_INFO, INFO_GROUP, INFO_GROUP_INFO, + INFO_GROUP_APPLICABLEWORLDS, INFO_GROUP_INFOSHARES, - INFO_GROUP_INFONEGATIVESHARES, + INFO_GROUP_APPLICABLESHARES, INFO_ZEROARG, LIST_GROUPS, diff --git a/src/main/resources/multiverse-inventories_en.properties b/src/main/resources/multiverse-inventories_en.properties index a2f4553f..43febf6d 100644 --- a/src/main/resources/multiverse-inventories_en.properties +++ b/src/main/resources/multiverse-inventories_en.properties @@ -32,11 +32,12 @@ mv-inventories.conflict.notfound=No group conflicts found! # Commands ## Info Command mv-inventories.info.world=&b===[ Info for world: &6{world}&b ]=== -mv-inventories.info.world.info=&6Groups:&f {groups} +mv-inventories.info.world.info=&6In Groups:&f {groups} mv-inventories.info.group=&b===[ Info for group: &6{group}&b ]=== -mv-inventories.info.group.info=&6Worlds:&f {worlds} -mv-inventories.info.group.infoshares=&bShares:&f {shares} -mv-inventories.info.group.infonegativeshares=&bNegative Shares:&f {shares} +mv-inventories.info.group.info=&6Config Worlds:&f {worlds} +mv-inventories.info.group.applicableworlds=&6Applicable Worlds:&f {worlds} +mv-inventories.info.group.infoshares=&bConfig Shares:&f {shares} +mv-inventories.info.group.applicableshares=&bApplicable Shares:&f {shares} mv-inventories.info.zeroarg=You may only use the no argument version of this command in game! # List Command