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 + "...");
|
CTZServer.getLogger().info("数据表不存在,新建表" + dbtable + "...");
|
||||||
HashMap<String, String> fields = new HashMap<String, String>();
|
HashMap<String, String> fields = new HashMap<String, String>();
|
||||||
fields.put("player", "VARCHAR(16) NOT NULL");
|
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`)";
|
String Conditions = "UNIQUE (`player`)";
|
||||||
if (!sql.createTables(dbtable, fields, Conditions))
|
if (!sql.createTables(dbtable, fields, Conditions))
|
||||||
CTZServer.getLogger().warning("数据表" + dbtable + "创建失败,请尝试手动创建并重启服务器...");
|
CTZServer.getLogger().warning("数据表" + dbtable + "创建失败,请尝试手动创建并重启服务器...");
|
||||||
|
@ -10,6 +10,7 @@ import java.net.Socket;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
import cn.citycraft.CTZServer.CTZAuth;
|
||||||
import cn.citycraft.CTZServer.CTZServer;
|
import cn.citycraft.CTZServer.CTZServer;
|
||||||
import cn.citycraft.CTZServer.socket.Response.HttpStates;
|
import cn.citycraft.CTZServer.socket.Response.HttpStates;
|
||||||
|
|
||||||
@ -95,10 +96,10 @@ public class CTZLoginServerSocket extends Thread {
|
|||||||
res.setState(HttpStates.Bad_Request);
|
res.setState(HttpStates.Bad_Request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if (API.isRegistered(username))
|
if (CTZAuth.isRegistered(username))
|
||||||
// res.setHtml("true");
|
res.setHtml("true");
|
||||||
// else
|
else
|
||||||
// res.setHtml("false");
|
res.setHtml("false");
|
||||||
break;
|
break;
|
||||||
case "register":
|
case "register":
|
||||||
username = req.Query("username");
|
username = req.Query("username");
|
||||||
@ -107,11 +108,11 @@ public class CTZLoginServerSocket extends Thread {
|
|||||||
res.setState(HttpStates.Bad_Request);
|
res.setState(HttpStates.Bad_Request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if (API.registerPlayer(username, password)) {
|
if (CTZAuth.registerPlayer(username, password)) {
|
||||||
// res.setHtml("true");
|
res.setHtml("true");
|
||||||
// Bukkit.getConsoleSender().sendMessage("§6玩家: §a" + username + " §d注册成功 IP: " + ip);
|
CTZServer.getLogger().info("§6玩家: §a" + username + " §d注册成功 IP: " + ip);
|
||||||
// } else
|
} else
|
||||||
// res.setHtml("false");
|
res.setHtml("false");
|
||||||
break;
|
break;
|
||||||
case "login":
|
case "login":
|
||||||
username = req.Query("username");
|
username = req.Query("username");
|
||||||
@ -120,15 +121,12 @@ public class CTZLoginServerSocket extends Thread {
|
|||||||
res.setState(HttpStates.Bad_Request);
|
res.setState(HttpStates.Bad_Request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if (API.checkPassword(username, password)) {
|
if (CTZAuth.checkPassword(username, password)) {
|
||||||
// res.setHtml("true");
|
res.setHtml("true");
|
||||||
// if (CTZLoginQueue.isCheckIP())
|
// TODO 是否检查登录IP
|
||||||
// CTZLoginQueue.add(username, ip);
|
CTZServer.getLogger().info("§6玩家: §a" + username + " §3登录成功 IP: " + ip);
|
||||||
// else
|
} else
|
||||||
// CTZLoginQueue.add(username);
|
res.setHtml("false");
|
||||||
// Bukkit.getConsoleSender().sendMessage("§6玩家: §a" + username + " §3登录成功 IP: " + ip);
|
|
||||||
// } else
|
|
||||||
// res.setHtml("false");
|
|
||||||
break;
|
break;
|
||||||
case "islogin":
|
case "islogin":
|
||||||
username = req.Query("username");
|
username = req.Query("username");
|
||||||
@ -148,11 +146,11 @@ public class CTZLoginServerSocket extends Thread {
|
|||||||
res.setState(HttpStates.Bad_Request);
|
res.setState(HttpStates.Bad_Request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if (API.checkPassword(username, password))
|
if (CTZAuth.checkPassword(username, password)) {
|
||||||
// res.setHtml("true");
|
res.setHtml("true");
|
||||||
// // TODO 处理玩家密码修改事件
|
CTZAuth.changePassword(username, password);
|
||||||
// else
|
} else
|
||||||
// res.setHtml("false");
|
res.setHtml("false");
|
||||||
break;
|
break;
|
||||||
case "serverlist":
|
case "serverlist":
|
||||||
res.setState(HttpStates.OK);
|
res.setState(HttpStates.OK);
|
||||||
|
Loading…
Reference in New Issue
Block a user