Add list alias
This commit is contained in:
@@ -233,18 +233,21 @@ public class BotCommand extends CommandInstance {
|
|||||||
public List<String> infoAutofill(CommandSender sender, String[] args) {
|
public List<String> infoAutofill(CommandSender sender, String[] args) {
|
||||||
return args.length == 2 ? manager.fetchNames() : null;
|
return args.length == 2 ? manager.fetchNames() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "count",
|
name = "count",
|
||||||
desc = "Counts the amount of bots on screen by name."
|
desc = "Counts the amount of bots on screen by name.",
|
||||||
|
aliases = {
|
||||||
|
"list"
|
||||||
|
}
|
||||||
)
|
)
|
||||||
public void count(CommandSender sender) {
|
public void count(CommandSender sender) {
|
||||||
List<String> names = manager.fetchNames();
|
List<String> names = manager.fetchNames();
|
||||||
Map<String, Integer> freqMap = names.stream().collect(Collectors.toMap(s -> s, s -> 1, Integer::sum));
|
Map<String, Integer> freqMap = names.stream().collect(Collectors.toMap(s -> s, s -> 1, Integer::sum));
|
||||||
List<Entry<String, Integer>> entries = freqMap.entrySet().stream()
|
List<Entry<String, Integer>> entries = freqMap.entrySet().stream()
|
||||||
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).collect(Collectors.toList());
|
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).collect(Collectors.toList());
|
||||||
|
|
||||||
sender.sendMessage(ChatUtils.LINE);
|
sender.sendMessage(ChatUtils.LINE);
|
||||||
entries.forEach(en -> sender.sendMessage(ChatColor.GREEN + en.getKey()
|
entries.forEach(en -> sender.sendMessage(ChatColor.GREEN + en.getKey()
|
||||||
+ ChatColor.RESET + " - " + ChatColor.BLUE + en.getValue().toString() + ChatColor.RESET));
|
+ ChatColor.RESET + " - " + ChatColor.BLUE + en.getValue().toString() + ChatColor.RESET));
|
||||||
sender.sendMessage("Total bots: " + ChatColor.BLUE + freqMap.values().stream().reduce(0, Integer::sum) + ChatColor.RESET);
|
sender.sendMessage("Total bots: " + ChatColor.BLUE + freqMap.values().stream().reduce(0, Integer::sum) + ChatColor.RESET);
|
||||||
@@ -519,7 +522,7 @@ public class BotCommand extends CommandInstance {
|
|||||||
public void debug(CommandSender sender, @Arg("expression") String expression) {
|
public void debug(CommandSender sender, @Arg("expression") String expression) {
|
||||||
new Debugger(sender).execute(expression);
|
new Debugger(sender).execute(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double parseDoubleOrRelative(String pos, Location loc, int type) {
|
private double parseDoubleOrRelative(String pos, Location loc, int type) {
|
||||||
if (loc == null || pos.length() == 0 || pos.charAt(0) != '~')
|
if (loc == null || pos.length() == 0 || pos.charAt(0) != '~')
|
||||||
return Double.parseDouble(pos);
|
return Double.parseDouble(pos);
|
||||||
|
|||||||
Reference in New Issue
Block a user