-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccountSetRestrictedCommand.java
30 lines (27 loc) · 1.11 KB
/
AccountSetRestrictedCommand.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
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;
public class AccountSetRestrictedCommand extends ServerCommand {
public AccountSetRestrictedCommand() {
super("accountsetrestricted");
}
@Override
public void execute(GlobalServer server, ArgsParser args) {
if (args.remaining() != 2) {
GlobalServer.LOGGER.info("/accountsetrestricted <name> <true/false>");
return;
}
String accountName = args.getNext().toLowerCase().trim();
boolean restricted = args.getNext(false);
ClientConfig account = server.getAccount(accountName);
if (account == null) {
GlobalServer.LOGGER.info("Account " + accountName + " does not exist!");
return;
}
account.setRestricted(restricted);
server.saveConfig();
GlobalServer.LOGGER.info("Account " + accountName + " is now " + (account.isRestricted() ? "" : "un") + "restricted");
}
}