diff --git a/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/commands/MiscCommands.java b/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/commands/MiscCommands.java index 2faf78a..b6f16a1 100644 --- a/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/commands/MiscCommands.java +++ b/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/commands/MiscCommands.java @@ -1,6 +1,5 @@ package tc.oc.commons.bukkit.commands; -import com.google.common.util.concurrent.Futures; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandException; @@ -15,7 +14,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import tc.oc.api.bukkit.users.BukkitUserStore; -import tc.oc.api.docs.User; import tc.oc.api.docs.virtual.UserDoc; import tc.oc.api.users.UserService; import tc.oc.commons.bukkit.chat.Audiences; @@ -91,6 +89,32 @@ public class MiscCommands implements Commands { } } + @Command( + aliases = { "playerlocale", "locale" }, + desc = "Shows statics on what locale players online are in", + flags = "a", + min = 0, + max = 1 + ) + @CommandPermissions("ocn.locale") + public void listPlayerLocales(final CommandContext args, final CommandSender sender) throws CommandException { + Audience audience = audiences.get(sender); + if (args.hasFlag('a')) { + Map playerLocaleMap = userStore.stream().collect(java.util.stream.Collectors.groupingBy(Player::getLocale, java.util.stream.Collectors.counting())); + + audience.sendMessage(new HeaderComponent(new Component(ChatColor.AQUA).translate("list.player.locales.title"))); + for (Map.Entry entry : playerLocaleMap.entrySet()) { + audience.sendMessage(new TranslatableComponent("list.player.locales.message." + (entry.getValue() == 1 ? "singular" : "plural"), + ChatColor.AQUA + entry.getValue().toString(), + ChatColor.AQUA + entry.getKey(), + String.format("%.1f", 100 * entry.getValue() / (double) userStore.count()) + "%")); + } + } else { + Player player = CommandUtils.getPlayerOrSelf(args, sender, 0); + audience.sendMessage(new TranslatableComponent("list.player.locale.singular.message", new PlayerComponent(identityProvider.createIdentity(player)), ChatColor.AQUA + player.getLocale())); + } + } + @Command( aliases = { "coinflip" }, desc = "Flip a Coin", diff --git a/Commons/core/src/main/i18n/templates/commons/Commons.properties b/Commons/core/src/main/i18n/templates/commons/Commons.properties index 1d793c0..1cea472 100644 --- a/Commons/core/src/main/i18n/templates/commons/Commons.properties +++ b/Commons/core/src/main/i18n/templates/commons/Commons.properties @@ -35,6 +35,11 @@ list.player.versions.message.plural = {0} players are using {1} | {2} list.player.versions.message.singular = {0} player is using {1} | {2} list.player.version.singular.message = {0} is using {1} +list.player.locales.title = Player Locales +list.player.locales.message.plural = {0} players are using {1} | {2} +list.player.locales.message.singular = {0} player is using {1} | {2} +list.player.locale.singular.message = {0} is using {1} + time.interval.millisecond = {0} millisecond time.interval.milliseconds = {0} milliseconds time.interval.second = {0} second