mirror of
https://e.coding.net/circlecloud/CTZServer.git
synced 2024-11-21 11:28:47 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
e2a2fedf53
@ -8,8 +8,8 @@ public class CTZAuth {
|
||||
static final String TableName = "ctzserver";
|
||||
static final String UserField = "player";
|
||||
static final String PWDField = "password";
|
||||
static final String LoginField = "password";
|
||||
static ServerThread serverThread;
|
||||
static final String ISLoginField = "islogin";
|
||||
static final String ALLOWLoginField = "allowlogin";
|
||||
static SQLHelper sql;
|
||||
|
||||
public static void changePassword(String username, String password) {
|
||||
@ -20,13 +20,12 @@ public class CTZAuth {
|
||||
return sql.isFieldExists(TableName, new KeyValue(UserField, username).add(PWDField, StringUtil.getMD5Code(password)));
|
||||
}
|
||||
|
||||
public static void init(ServerThread serverThread) {
|
||||
CTZAuth.serverThread = serverThread;
|
||||
CTZAuth.sql = serverThread.sql;
|
||||
public static void init(SQLHelper sql) {
|
||||
CTZAuth.sql = sql;
|
||||
}
|
||||
|
||||
public static boolean isLogin(String username) {
|
||||
String result = sql.dbSelectFirst(TableName, LoginField, new KeyValue(UserField, username));
|
||||
String result = sql.dbSelectFirst(TableName, ISLoginField, new KeyValue(UserField, username));
|
||||
return (result != null && result.equalsIgnoreCase("1"));
|
||||
}
|
||||
|
||||
@ -35,7 +34,7 @@ public class CTZAuth {
|
||||
}
|
||||
|
||||
public static boolean login(String username) {
|
||||
return sql.dbUpdate(TableName, new KeyValue(LoginField, "1"), new KeyValue(UserField, username));
|
||||
return sql.dbUpdate(TableName, new KeyValue(ALLOWLoginField, "1"), new KeyValue(UserField, username));
|
||||
}
|
||||
|
||||
public static boolean registerPlayer(String username, String password) {
|
||||
|
@ -30,7 +30,7 @@ public class ServerThread implements Runnable {
|
||||
initCommand();
|
||||
initDatabase();
|
||||
initServerInfo();
|
||||
CTZAuth.init(this);
|
||||
CTZAuth.init(sql);
|
||||
|
||||
server = new CTZLoginServerSocket();
|
||||
server.start();
|
||||
@ -81,7 +81,8 @@ public class ServerThread implements Runnable {
|
||||
.add("z", "DOUBLE NOT NULL DEFAULT 0")
|
||||
.add("email", "VARCHAR(50) NOT NULL DEFAULT 'mc@mc.com'")
|
||||
.add("world", "VARCHAR(20) DEFAULT 'world'")
|
||||
.add("islogged", "SMALLINT(6) NOT NULL DEFAULT 0");
|
||||
.add("islogged", "SMALLINT(6) NOT NULL DEFAULT 0")
|
||||
.add("allowlogin", "SMALLINT(6) NOT NULL DEFAULT 0");
|
||||
String Conditions = "UNIQUE (`player`)";
|
||||
if (!sql.createTables(dbtable, kv, Conditions))
|
||||
CTZServer.warn(ChatColor.RED + "数据表 " + dbtable + " 创建失败,请尝试手动创建并重启服务器...");
|
||||
|
Loading…
Reference in New Issue
Block a user