add email faild...

Signed-off-by: j502647092 <jtb1@163.com>
master
j502647092 2015-09-20 22:49:45 +08:00
parent ac513ed551
commit c0fef40d73
2 changed files with 56 additions and 54 deletions

View File

@ -15,7 +15,7 @@ public class CommandRegister extends BaseCommand {
@Override @Override
public void execute(String label, String[] args) { public void execute(String label, String[] args) {
if (CTZAuth.registerPlayer(args[0], args[1])) if (CTZAuth.registerPlayer(args[0], args[1], args[2]))
CTZServer.print(ChatColor.GREEN + "账户 " + args[0] + " 注册成功!"); CTZServer.print(ChatColor.GREEN + "账户 " + args[0] + " 注册成功!");
else else
CTZServer.warn(ChatColor.RED + "账户 " + args[0] + " 注册失败!"); CTZServer.warn(ChatColor.RED + "账户 " + args[0] + " 注册失败!");
@ -28,12 +28,12 @@ public class CommandRegister extends BaseCommand {
@Override @Override
public int getMinimumArguments() { public int getMinimumArguments() {
return 2; return 3;
} }
@Override @Override
public String getPossibleArguments() { public String getPossibleArguments() {
return "<账号> <密码>"; return "<账号> <密码> <邮箱>";
} }
} }

View File

@ -14,55 +14,6 @@ import cn.citycraft.CTZServerCommon.CTZServer;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
public class CTZLoginServerSocket extends Thread { public class CTZLoginServerSocket extends Thread {
ServerSocket s = null;
Socket socket = null;
int port = 25580;
/**
*
*/
public CTZLoginServerSocket() {
}
/**
*
*/
public CTZLoginServerSocket(int port) {
this.port = port;
}
@Override
public void run() {
try {
// 设定服务端的端口号
s = new ServerSocket(port);
CTZServer.print(ChatColor.BLUE + "CTZ服务器开始监听 端口:" + s.getLocalPort());
// 等待请求,此方法会一直阻塞,直到获得请求才往下走
while (true) {
socket = s.accept();
new ClientThread(socket).start();
}
} catch (Exception e) {
CTZServer.print(ChatColor.RED + "CTZ服务器崩溃: " + e.getMessage());
} finally {
ShutDown();
}
}
/**
*
*/
public void ShutDown() {
try {
socket.close();
s.close();
} catch (Exception e) {
}
CTZServer.print(ChatColor.RED + "CTZ服务器已关闭...");
System.exit(0);
}
class ClientThread extends Thread { class ClientThread extends Thread {
Socket client = null; Socket client = null;
BufferedReader br = null; BufferedReader br = null;
@ -89,6 +40,7 @@ public class CTZLoginServerSocket extends Thread {
Response res = new Response(); Response res = new Response();
String username = ""; String username = "";
String password = ""; String password = "";
String email = "";
if (req.isSuccess) { if (req.isSuccess) {
switch (req.getPrefix().substring(1)) { switch (req.getPrefix().substring(1)) {
case "isregistered": case "isregistered":
@ -105,11 +57,12 @@ public class CTZLoginServerSocket extends Thread {
case "register": case "register":
username = req.Query("username"); username = req.Query("username");
password = req.Query("password"); password = req.Query("password");
if (username == null || password == null) { email = req.Query("email");
if (username == null || password == null || email == null) {
res.setState(HttpStates.Bad_Request); res.setState(HttpStates.Bad_Request);
break; break;
} }
if (CTZAuth.registerPlayer(username, password)) { if (CTZAuth.registerPlayer(username, password, email)) {
res.setHtml("true"); res.setHtml("true");
CTZServer.print("§6玩家: §a" + username + " §d注册成功 IP: " + ip); CTZServer.print("§6玩家: §a" + username + " §d注册成功 IP: " + ip);
} else } else
@ -176,4 +129,53 @@ public class CTZLoginServerSocket extends Thread {
} }
} }
} }
ServerSocket s = null;
Socket socket = null;
int port = 25580;
/**
*
*/
public CTZLoginServerSocket() {
}
/**
*
*/
public CTZLoginServerSocket(int port) {
this.port = port;
}
@Override
public void run() {
try {
// 设定服务端的端口号
s = new ServerSocket(port);
CTZServer.print(ChatColor.BLUE + "CTZ服务器开始监听 端口:" + s.getLocalPort());
// 等待请求,此方法会一直阻塞,直到获得请求才往下走
while (true) {
socket = s.accept();
new ClientThread(socket).start();
}
} catch (Exception e) {
CTZServer.print(ChatColor.RED + "CTZ服务器崩溃: " + e.getMessage());
} finally {
ShutDown();
}
}
/**
*
*/
public void ShutDown() {
try {
socket.close();
s.close();
} catch (Exception e) {
}
CTZServer.print(ChatColor.RED + "CTZ服务器已关闭...");
System.exit(0);
}
} }