54 lines
1.3 KiB
Java
54 lines
1.3 KiB
Java
/**
|
|
*
|
|
*/
|
|
package cn.citycraft.CTZLoginServer;
|
|
|
|
import java.util.HashMap;
|
|
|
|
/**
|
|
* 玩家登录队列类
|
|
*
|
|
* @author 蒋天蓓 2015年7月28日下午9:08:23
|
|
*/
|
|
public class CTZLoginQueue {
|
|
protected static boolean checkIP = true;;
|
|
|
|
protected static HashMap<String, String> list = new HashMap<String, String>();
|
|
|
|
public static void add(String player) {
|
|
list.put(player.toLowerCase(), null);
|
|
}
|
|
|
|
public static void add(String player, String IP) {
|
|
list.put(player.toLowerCase(), IP);
|
|
}
|
|
|
|
public static boolean canLogin(String player) {
|
|
return list.containsKey(player.toLowerCase());
|
|
}
|
|
|
|
public static boolean canLogin(String player, String IP) {
|
|
return list.containsKey(player.toLowerCase()) && list.get(player.toLowerCase()).equalsIgnoreCase(IP);
|
|
}
|
|
|
|
public static boolean isCheckIP() {
|
|
return checkIP;
|
|
}
|
|
|
|
public static boolean Login(String player) {
|
|
return list.remove(player.toLowerCase()) != null;
|
|
}
|
|
|
|
public static boolean Login(String player, String IP) {
|
|
if (list.containsKey(player.toLowerCase()) && list.get(player.toLowerCase()).equalsIgnoreCase(IP)) {
|
|
list.remove(player.toLowerCase());
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static void setCheckIP(boolean checkIP) {
|
|
CTZLoginQueue.checkIP = checkIP;
|
|
}
|
|
}
|