Skip to content

Commit 21954f4

Browse files
authored
Merge pull request #615 from Multiverse/feat/applicable-info
Improve info command output of applicable worlds and shares
2 parents a114094 + d816402 commit 21954f4

3 files changed

Lines changed: 23 additions & 33 deletions

File tree

src/main/java/org/mvplugins/multiverse/inventories/commands/InfoCommand.java

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.mvplugins.multiverse.inventories.profile.group.WorldGroupManager;
2323
import org.mvplugins.multiverse.inventories.util.MVInvi18n;
2424

25+
import java.util.Collection;
2526
import java.util.List;
2627
import 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

src/main/java/org/mvplugins/multiverse/inventories/util/MVInvi18n.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ public enum MVInvi18n implements MessageKeyProvider {
4444
INFO_WORLD_INFO,
4545
INFO_GROUP,
4646
INFO_GROUP_INFO,
47+
INFO_GROUP_APPLICABLEWORLDS,
4748
INFO_GROUP_INFOSHARES,
48-
INFO_GROUP_INFONEGATIVESHARES,
49+
INFO_GROUP_APPLICABLESHARES,
4950
INFO_ZEROARG,
5051

5152
LIST_GROUPS,

src/main/resources/multiverse-inventories_en.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ mv-inventories.conflict.notfound=No group conflicts found!
3232
# Commands
3333
## Info Command
3434
mv-inventories.info.world=&b===[ Info for world: &6{world}&b ]===
35-
mv-inventories.info.world.info=&6Groups:&f {groups}
35+
mv-inventories.info.world.info=&6In Groups:&f {groups}
3636
mv-inventories.info.group=&b===[ Info for group: &6{group}&b ]===
37-
mv-inventories.info.group.info=&6Worlds:&f {worlds}
38-
mv-inventories.info.group.infoshares=&bShares:&f {shares}
39-
mv-inventories.info.group.infonegativeshares=&bNegative Shares:&f {shares}
37+
mv-inventories.info.group.info=&6Config Worlds:&f {worlds}
38+
mv-inventories.info.group.applicableworlds=&6Applicable Worlds:&f {worlds}
39+
mv-inventories.info.group.infoshares=&bConfig Shares:&f {shares}
40+
mv-inventories.info.group.applicableshares=&bApplicable Shares:&f {shares}
4041
mv-inventories.info.zeroarg=You may only use the no argument version of this command in game!
4142

4243
# List Command

0 commit comments

Comments
 (0)