Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -44,7 +45,7 @@ class InfoCommand extends InventoriesCommand {

@Subcommand("info")
@CommandPermission("multiverse.inventories.info")
@CommandCompletion("@mvworlds")
@CommandCompletion("@mvworlds|@worldGroups")
@Syntax("<world|group>")
@Description("World and Group Information")
void onInfoCommand(
Expand Down Expand Up @@ -81,39 +82,26 @@ void onInfoCommand(
}

private void groupInfo(MVCommandIssuer issuer, WorldGroup worldGroup) {
StringBuilder worldsString = new StringBuilder();
Set<String> 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<WorldGroup> worldGroups = worldGroupManager.getGroupsForWorld(worldProfileContainer.getContainerName());
List<String> 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<String> worlds) {
if (worlds.isEmpty()) {
return "&7N/A";
}
issuer.sendInfo(MVInvi18n.INFO_WORLD_INFO, replace("{groups}").with(groupsString));
return StringFormatter.join(worlds, ", ");
}

@Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/multiverse-inventories_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down