mirror of
https://e.coding.net/circlecloud/CTZServer.git
synced 2024-11-21 11:28:47 +00:00
add CTZAuth...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
51f5b8431d
commit
652a9d6eb2
24
src/main/java/cn/citycraft/CTZServer/CTZAuth.java
Normal file
24
src/main/java/cn/citycraft/CTZServer/CTZAuth.java
Normal file
@ -0,0 +1,24 @@
|
||||
package cn.citycraft.CTZServer;
|
||||
|
||||
public class CTZAuth {
|
||||
|
||||
public static void changePassword(String username, String password) {
|
||||
// TODO 处理玩家密码修改事件
|
||||
}
|
||||
|
||||
public static boolean checkPassword(String username, String password) {
|
||||
// TODO 检查玩家密码
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isRegistered(String username) {
|
||||
// TODO 检查玩家是否注册
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean registerPlayer(String username, String password) {
|
||||
// TODO 注册玩家
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -74,7 +74,15 @@ public class ServerThread implements Runnable {
|
||||
CTZServer.getLogger().info("数据表不存在,新建表" + dbtable + "...");
|
||||
HashMap<String, String> fields = new HashMap<String, String>();
|
||||
fields.put("player", "VARCHAR(16) NOT NULL");
|
||||
fields.put("prefix", "VARCHAR(600) NOT NULL");
|
||||
fields.put("password", "VARCHAR(50) NOT NULL");
|
||||
fields.put("ip", "varchar(40) NOT NULL");
|
||||
fields.put("lastloginout", "BIGINT(20) NOT NULL");
|
||||
fields.put("x", "DOUBLE NOT NULL");
|
||||
fields.put("y", "DOUBLE NOT NULL");
|
||||
fields.put("z", "DOUBLE NOT NULL");
|
||||
fields.put("email", "VARCHAR(50)");
|
||||
fields.put("world", "SMALLINT(6)");
|
||||
fields.put("islogged", "SMALLINT(6) NOT NULL");
|
||||
String Conditions = "UNIQUE (`player`)";
|
||||
if (!sql.createTables(dbtable, fields, Conditions))
|
||||
CTZServer.getLogger().warning("数据表" + dbtable + "创建失败,请尝试手动创建并重启服务器...");
|
||||
|
@ -10,6 +10,7 @@ import java.net.Socket;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import cn.citycraft.CTZServer.CTZAuth;
|
||||
import cn.citycraft.CTZServer.CTZServer;
|
||||
import cn.citycraft.CTZServer.socket.Response.HttpStates;
|
||||
|
||||
@ -95,10 +96,10 @@ public class CTZLoginServerSocket extends Thread {
|
||||
res.setState(HttpStates.Bad_Request);
|
||||
break;
|
||||
}
|
||||
// if (API.isRegistered(username))
|
||||
// res.setHtml("true");
|
||||
// else
|
||||
// res.setHtml("false");
|
||||
if (CTZAuth.isRegistered(username))
|
||||
res.setHtml("true");
|
||||
else
|
||||
res.setHtml("false");
|
||||
break;
|
||||
case "register":
|
||||
username = req.Query("username");
|
||||
@ -107,11 +108,11 @@ public class CTZLoginServerSocket extends Thread {
|
||||
res.setState(HttpStates.Bad_Request);
|
||||
break;
|
||||
}
|
||||
// if (API.registerPlayer(username, password)) {
|
||||
// res.setHtml("true");
|
||||
// Bukkit.getConsoleSender().sendMessage("§6玩家: §a" + username + " §d注册成功 IP: " + ip);
|
||||
// } else
|
||||
// res.setHtml("false");
|
||||
if (CTZAuth.registerPlayer(username, password)) {
|
||||
res.setHtml("true");
|
||||
CTZServer.getLogger().info("§6玩家: §a" + username + " §d注册成功 IP: " + ip);
|
||||
} else
|
||||
res.setHtml("false");
|
||||
break;
|
||||
case "login":
|
||||
username = req.Query("username");
|
||||
@ -120,15 +121,12 @@ public class CTZLoginServerSocket extends Thread {
|
||||
res.setState(HttpStates.Bad_Request);
|
||||
break;
|
||||
}
|
||||
// if (API.checkPassword(username, password)) {
|
||||
// res.setHtml("true");
|
||||
// if (CTZLoginQueue.isCheckIP())
|
||||
// CTZLoginQueue.add(username, ip);
|
||||
// else
|
||||
// CTZLoginQueue.add(username);
|
||||
// Bukkit.getConsoleSender().sendMessage("§6玩家: §a" + username + " §3登录成功 IP: " + ip);
|
||||
// } else
|
||||
// res.setHtml("false");
|
||||
if (CTZAuth.checkPassword(username, password)) {
|
||||
res.setHtml("true");
|
||||
// TODO 是否检查登录IP
|
||||
CTZServer.getLogger().info("§6玩家: §a" + username + " §3登录成功 IP: " + ip);
|
||||
} else
|
||||
res.setHtml("false");
|
||||
break;
|
||||
case "islogin":
|
||||
username = req.Query("username");
|
||||
@ -148,11 +146,11 @@ public class CTZLoginServerSocket extends Thread {
|
||||
res.setState(HttpStates.Bad_Request);
|
||||
break;
|
||||
}
|
||||
// if (API.checkPassword(username, password))
|
||||
// res.setHtml("true");
|
||||
// // TODO 处理玩家密码修改事件
|
||||
// else
|
||||
// res.setHtml("false");
|
||||
if (CTZAuth.checkPassword(username, password)) {
|
||||
res.setHtml("true");
|
||||
CTZAuth.changePassword(username, password);
|
||||
} else
|
||||
res.setHtml("false");
|
||||
break;
|
||||
case "serverlist":
|
||||
res.setState(HttpStates.OK);
|
||||
|
Loading…
Reference in New Issue
Block a user