-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccountInfoCommand.java
58 lines (54 loc) · 2.03 KB
/
AccountInfoCommand.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package de.cubeside.globalserver.command;
import de.cubeside.globalserver.ArgsParser;
import de.cubeside.globalserver.ClientConfig;
import de.cubeside.globalserver.GlobalServer;
import de.cubeside.globalserver.ServerCommand;
import java.util.ArrayList;
import java.util.Collection;
public class AccountInfoCommand extends ServerCommand {
public AccountInfoCommand() {
super("accountinfo");
}
@Override
public void execute(GlobalServer server, ArgsParser args) {
if (args.remaining() != 1) {
GlobalServer.LOGGER.info("/accountinfo <name>");
return;
}
String accountName = args.getNext().toLowerCase().trim();
ClientConfig account = server.getAccount(accountName);
if (account == null) {
GlobalServer.LOGGER.info("Account " + accountName + " does not exist!");
return;
}
String s = "Account " + account.getLogin();
GlobalServer.LOGGER.info(s);
StringBuilder sb = new StringBuilder();
for (int i = s.length(); i > 0; i--) {
sb.append("=");
}
GlobalServer.LOGGER.info(sb.toString());
GlobalServer.LOGGER.info(" Password: " + account.getPassword());
GlobalServer.LOGGER.info(" Restricted: " + account.isRestricted());
if (account.isRestricted()) {
GlobalServer.LOGGER.info(" Allowed Channels:");
for (String s2 : account.getAllowedChannels()) {
GlobalServer.LOGGER.info(" " + s2);
}
if (account.getAllowedChannels().isEmpty()) {
GlobalServer.LOGGER.info(" " + "(none)");
}
}
}
@Override
public Collection<String> tabComplete(GlobalServer server, ArgsParser argsParser) {
if (argsParser.remaining() == 1) {
ArrayList<String> result = new ArrayList<>();
for (ClientConfig e : server.getAccounts()) {
result.add(e.getLogin());
}
return result;
}
return null;
}
}