1
0
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:
502647092 2015-09-16 09:06:12 +08:00
parent 3606e61346
commit b5935e9349
3 changed files with 41 additions and 2 deletions

View File

@ -42,8 +42,7 @@ public class CTZAuth {
if (isRegistered(username)) if (isRegistered(username))
return false; return false;
else else
sql.dbInsert(TableName, new KeyValue(UserField, username).add(PWDField, StringUtil.getMD5Code(password))); return sql.dbInsert(TableName, new KeyValue(UserField, username).add(PWDField, StringUtil.getMD5Code(password)));
return false;
} }
} }

View File

@ -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 "<账号> <密码>";
}
}

View File

@ -24,6 +24,7 @@ public class HandlerCommand {
this.serverThread = serverThread; this.serverThread = serverThread;
registerCommand(new CommandStop(serverThread)); registerCommand(new CommandStop(serverThread));
registerCommand(new CommandGc(serverThread)); registerCommand(new CommandGc(serverThread));
registerCommand(new CommandRegister(serverThread));
} }
public boolean execute(String cmd, String[] args) { public boolean execute(String cmd, String[] args) {