/
AccountsCommand.java
33 lines (30 loc) · 1.08 KB
/
AccountsCommand.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package de.cubeside.globalserver.command;
import de.cubeside.globalserver.ClientConfig;
import de.cubeside.globalserver.GlobalServer;
import de.cubeside.globalserver.ServerCommand;
import de.iani.cubesideutils.commands.ArgsParser;
import java.util.ArrayList;
public class AccountsCommand extends ServerCommand {
public AccountsCommand() {
super("accounts");
}
@Override
public void execute(GlobalServer server, ArgsParser args) {
StringBuilder sb = new StringBuilder();
ArrayList<ClientConfig> accounts = new ArrayList<>(server.getAccounts());
accounts.sort((a1, a2) -> a1.getLogin().compareTo(a2.getLogin()));
sb.append("Accounts (").append(accounts.size()).append("): ");
boolean first = true;
for (ClientConfig cc : accounts) {
if (!first) {
sb.append(", ");
}
first = false;
sb.append(cc.getLogin());
if (cc.isRestricted()) {
sb.append(" (restricted)");
}
}
GlobalServer.LOGGER.info(sb.toString());
}
}