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

complete auth class...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-09-15 20:56:12 +08:00
parent 56ed87cb1a
commit 3606e61346
4 changed files with 16 additions and 11 deletions

View File

@ -1,13 +1,14 @@
package cn.citycraft.CTZServer;
import cn.citycraft.sql.KeyValue;
import cn.citycraft.sql.SQLHelper;
import cn.citycraft.utils.StringUtil;
import cn.citycraft.PluginHelper.sql.KeyValue;
import cn.citycraft.PluginHelper.sql.SQLHelper;
import cn.citycraft.PluginHelper.utils.StringUtil;
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 SQLHelper sql;
@ -25,7 +26,7 @@ public class CTZAuth {
}
public static boolean isLogin(String username) {
String result = sql.dbSelectFirst(TableName, "islogged", new KeyValue(UserField, username));
String result = sql.dbSelectFirst(TableName, LoginField, new KeyValue(UserField, username));
return (result != null && result.equalsIgnoreCase("1"));
}
@ -33,6 +34,10 @@ public class CTZAuth {
return sql.isFieldExists(TableName, new KeyValue(UserField, username));
}
public static boolean login(String username) {
return sql.dbUpdate(TableName, new KeyValue(LoginField, "1"), new KeyValue(UserField, username));
}
public static boolean registerPlayer(String username, String password) {
if (isRegistered(username))
return false;

View File

@ -7,10 +7,10 @@ import java.io.InputStreamReader;
import cn.citycraft.CTZServer.commands.HandlerCommand;
import cn.citycraft.CTZServer.socket.CTZLoginServerSocket;
import cn.citycraft.sql.KeyValue;
import cn.citycraft.sql.MySQLHelper;
import cn.citycraft.sql.SQLHelper;
import cn.citycraft.utils.FileUtil;
import cn.citycraft.PluginHelper.sql.KeyValue;
import cn.citycraft.PluginHelper.sql.MySQLHelper;
import cn.citycraft.PluginHelper.sql.SQLHelper;
import cn.citycraft.PluginHelper.utils.FileUtil;
import net.md_5.bungee.api.ChatColor;
public class ServerThread implements Runnable {

View File

@ -2,8 +2,8 @@ package cn.citycraft.CTZServer.commands;
import cn.citycraft.CTZServer.CTZServer;
import cn.citycraft.CTZServer.ServerThread;
import cn.citycraft.utils.StringUtil;
import cn.citycraft.utils.SystemUtil;
import cn.citycraft.PluginHelper.utils.StringUtil;
import cn.citycraft.PluginHelper.utils.SystemUtil;
import net.md_5.bungee.api.ChatColor;
public class CommandGc extends BaseCommand {

View File

@ -5,7 +5,7 @@ import java.util.List;
import cn.citycraft.CTZServer.CTZServer;
import cn.citycraft.CTZServer.ServerThread;
import cn.citycraft.utils.StringUtil;
import cn.citycraft.PluginHelper.utils.StringUtil;
import net.md_5.bungee.api.ChatColor;
public class HandlerCommand {