2011-03-19 23:39:51 +01:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2013-10-16 21:59:39 +02:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
2013-08-21 00:39:34 +02:00
|
|
|
import com.earth2me.essentials.PlayerList;
|
2011-03-19 23:39:51 +01:00
|
|
|
import com.earth2me.essentials.User;
|
2011-11-18 18:42:26 +01:00
|
|
|
import org.bukkit.Server;
|
2011-03-19 23:39:51 +01:00
|
|
|
|
2020-10-03 19:46:05 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2015-04-15 06:06:16 +02:00
|
|
|
|
|
|
|
public class Commandlist extends EssentialsCommand {
|
|
|
|
public Commandlist() {
|
|
|
|
super("list");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
boolean showHidden = true;
|
|
|
|
User user = null;
|
|
|
|
if (sender.isPlayer()) {
|
|
|
|
user = ess.getUser(sender.getPlayer());
|
|
|
|
showHidden = user.isAuthorized("essentials.list.hidden") || user.canInteractVanished();
|
|
|
|
}
|
|
|
|
sender.sendMessage(PlayerList.listSummary(ess, user, showHidden));
|
|
|
|
final Map<String, List<User>> playerList = PlayerList.getPlayerLists(ess, user, showHidden);
|
|
|
|
|
|
|
|
if (args.length > 0) {
|
|
|
|
sender.sendMessage(PlayerList.listGroupUsers(ess, playerList, args[0].toLowerCase()));
|
|
|
|
} else {
|
|
|
|
sendGroupedList(sender, commandLabel, playerList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Output the standard /list output, when no group is specified
|
2020-10-03 19:46:05 +02:00
|
|
|
private void sendGroupedList(final CommandSource sender, final String commandLabel, final Map<String, List<User>> playerList) {
|
2021-07-01 15:43:35 +02:00
|
|
|
for (final String str : PlayerList.prepareGroupedList(ess, commandLabel, playerList)) {
|
|
|
|
sender.sendMessage(str);
|
2015-04-15 06:06:16 +02:00
|
|
|
}
|
|
|
|
}
|
2017-06-11 02:17:43 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
|
|
|
if (args.length == 1) {
|
2021-03-06 20:42:59 +01:00
|
|
|
return new ArrayList<>(PlayerList.getPlayerLists(ess, sender.getUser(ess), false).keySet());
|
2017-06-11 02:17:43 +02:00
|
|
|
} else {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
2011-03-19 23:39:51 +01:00
|
|
|
}
|