1
0
mirror of https://e.coding.net/circlecloud/CTZServer.git synced 2024-11-21 11:28:47 +00:00

add new filed...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-09-15 23:08:16 +08:00
parent 3606e61346
commit e8a6448eb6
2 changed files with 9 additions and 9 deletions

View File

@ -8,8 +8,8 @@ public class CTZAuth {
static final String TableName = "ctzserver"; static final String TableName = "ctzserver";
static final String UserField = "player"; static final String UserField = "player";
static final String PWDField = "password"; static final String PWDField = "password";
static final String LoginField = "password"; static final String ISLoginField = "islogin";
static ServerThread serverThread; static final String ALLOWLoginField = "allowlogin";
static SQLHelper sql; static SQLHelper sql;
public static void changePassword(String username, String password) { 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))); return sql.isFieldExists(TableName, new KeyValue(UserField, username).add(PWDField, StringUtil.getMD5Code(password)));
} }
public static void init(ServerThread serverThread) { public static void init(SQLHelper sql) {
CTZAuth.serverThread = serverThread; CTZAuth.sql = sql;
CTZAuth.sql = serverThread.sql;
} }
public static boolean isLogin(String username) { 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")); return (result != null && result.equalsIgnoreCase("1"));
} }
@ -35,7 +34,7 @@ public class CTZAuth {
} }
public static boolean login(String username) { 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) { public static boolean registerPlayer(String username, String password) {

View File

@ -30,7 +30,7 @@ public class ServerThread implements Runnable {
initCommand(); initCommand();
initDatabase(); initDatabase();
initServerInfo(); initServerInfo();
CTZAuth.init(this); CTZAuth.init(sql);
server = new CTZLoginServerSocket(); server = new CTZLoginServerSocket();
server.start(); server.start();
@ -81,7 +81,8 @@ public class ServerThread implements Runnable {
.add("z", "DOUBLE NOT NULL DEFAULT 0") .add("z", "DOUBLE NOT NULL DEFAULT 0")
.add("email", "VARCHAR(50) NOT NULL DEFAULT 'mc@mc.com'") .add("email", "VARCHAR(50) NOT NULL DEFAULT 'mc@mc.com'")
.add("world", "VARCHAR(20) DEFAULT 'world'") .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`)"; String Conditions = "UNIQUE (`player`)";
if (!sql.createTables(dbtable, kv, Conditions)) if (!sql.createTables(dbtable, kv, Conditions))
CTZServer.warn(ChatColor.RED + "数据表 " + dbtable + " 创建失败,请尝试手动创建并重启服务器..."); CTZServer.warn(ChatColor.RED + "数据表 " + dbtable + " 创建失败,请尝试手动创建并重启服务器...");