1
0
mirror of https://e.coding.net/circlecloud/CTZServer.git synced 2024-12-27 17:18:47 +00:00

add email faild...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
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
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] + " 注册成功!");
else
CTZServer.warn(ChatColor.RED + "账户 " + args[0] + " 注册失败!");
@ -28,12 +28,12 @@ public class CommandRegister extends BaseCommand {
@Override
public int getMinimumArguments() {
return 2;
return 3;
}
@Override
public String getPossibleArguments() {
return "<账号> <密码>";
return "<账号> <密码> <邮箱>";
}
}

View File

@ -14,55 +14,6 @@ import cn.citycraft.CTZServerCommon.CTZServer;
import net.md_5.bungee.api.ChatColor;
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 {
Socket client = null;
BufferedReader br = null;
@ -89,6 +40,7 @@ public class CTZLoginServerSocket extends Thread {
Response res = new Response();
String username = "";
String password = "";
String email = "";
if (req.isSuccess) {
switch (req.getPrefix().substring(1)) {
case "isregistered":
@ -105,11 +57,12 @@ public class CTZLoginServerSocket extends Thread {
case "register":
username = req.Query("username");
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);
break;
}
if (CTZAuth.registerPlayer(username, password)) {
if (CTZAuth.registerPlayer(username, password, email)) {
res.setHtml("true");
CTZServer.print("§6玩家: §a" + username + " §d注册成功 IP: " + ip);
} 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);
}
}