mirror of
https://e.coding.net/circlecloud/CTZServer.git
synced 2024-11-21 11:28:47 +00:00
add new command...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
3606e61346
commit
b5935e9349
@ -42,8 +42,7 @@ public class CTZAuth {
|
||||
if (isRegistered(username))
|
||||
return false;
|
||||
else
|
||||
sql.dbInsert(TableName, new KeyValue(UserField, username).add(PWDField, StringUtil.getMD5Code(password)));
|
||||
return false;
|
||||
return sql.dbInsert(TableName, new KeyValue(UserField, username).add(PWDField, StringUtil.getMD5Code(password)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package cn.citycraft.CTZServer.commands;
|
||||
|
||||
import cn.citycraft.CTZServer.CTZAuth;
|
||||
import cn.citycraft.CTZServer.CTZServer;
|
||||
import cn.citycraft.CTZServer.ServerThread;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class CommandRegister extends BaseCommand {
|
||||
ServerThread serverThread;
|
||||
|
||||
public CommandRegister(ServerThread serverThread) {
|
||||
super("reg", "register");
|
||||
this.serverThread = serverThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String label, String[] args) {
|
||||
if (CTZAuth.registerPlayer(args[0], args[1]))
|
||||
CTZServer.print(ChatColor.GREEN + "账户 " + args[0] + " 注册成功!");
|
||||
else
|
||||
CTZServer.warn(ChatColor.RED + "账户 " + args[0] + " 注册失败!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return ChatColor.GREEN + "注册新账户";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "<账号> <密码>";
|
||||
}
|
||||
|
||||
}
|
@ -24,6 +24,7 @@ public class HandlerCommand {
|
||||
this.serverThread = serverThread;
|
||||
registerCommand(new CommandStop(serverThread));
|
||||
registerCommand(new CommandGc(serverThread));
|
||||
registerCommand(new CommandRegister(serverThread));
|
||||
}
|
||||
|
||||
public boolean execute(String cmd, String[] args) {
|
||||
|
Loading…
Reference in New Issue
Block a user