-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccountSetPasswordCommand.java
30 lines (27 loc) · 1.08 KB
/
AccountSetPasswordCommand.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 AccountSetPasswordCommand extends ServerCommand {
public AccountSetPasswordCommand() {
super("accountsetpassword");
}
@Override
public void execute(GlobalServer server, ArgsParser args) {
if (args.remaining() != 1) {
GlobalServer.LOGGER.info("/accountsetpassword <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 password = CreateAccountCommand.createRandomPassword(32);
account.setPassword(password);
server.saveConfig();
GlobalServer.LOGGER.info("Account " + accountName + " now has password: " + password);
}
}