/**
* Connection Check Class
*
* @author Ryan / Lmctruck30
*
*/
public class Connection {
public static ArrayList<String> bannedIps = new ArrayList<String>();
public static ArrayList<String> bannedNames = new ArrayList<String>();
public static ArrayList<String> mutedIps = new ArrayList<String>();
public static ArrayList<String> mutedNames = new ArrayList<String>();
public static ArrayList<String> loginLimitExceeded = new ArrayList<String>();
/**
* Adds the banned usernames and ips from the text file to the ban list
**/
public static void initialize() {
banUsers();
banIps();
muteUsers();
muteIps();
}
/**
* Adding Name To List
*/
public static void addIpToLoginList(String IP) {
loginLimitExceeded.add(IP);
}
/**
* Remove Ip From List
*/
public static void removeIpFromLoginList(String IP) {
loginLimitExceeded.remove(IP);
}
/**
* Clear Name List
*/
public static void clearLoginList() {
loginLimitExceeded.clear();
}
public static boolean checkLoginList(String IP) {
loginLimitExceeded.add(IP);
int num = 0;
for (String ips : loginLimitExceeded) {
if (IP.equals(ips)) {
num++;
}
}
if (num > 5) {
return true;
}
return false;
}
public static void unMuteUser(String name) {
mutedNames.remove(name);
deleteFromFile("./Data/Bans/UsersMuted.txt", name);
}
public static void unIPMuteUser(String name) {
mutedIps.remove(name);
deleteFromFile("./Data/Bans/IpsMuted.txt", name);
}
/**
* Adding Ban IP
**/
public static void addIpToBanList(String IP) {
bannedIps.add(IP);
}
public static void addIpToMuteList(String IP) {
mutedIps.add(IP);
addIpToMuteFile(IP);
}
/**
* Removing Ban IP
**/
public static void removeIpFromBanList(String IP) {
bannedIps.remove(IP);
}
/**
* Contains Ban IP
**/
public static boolean isIpBanned(String IP) {
if (bannedIps.contains(IP)) {
return true;
}
return false;
}
/**
* Reads all usernames from text file then adds them all to the ban list
**/
public static void banUsers() {
try {
BufferedReader in = new BufferedReader(new FileReader(
"./Data/Bans/UsersBanned.txt"));
String data = null;
try {
while ((data = in.readLine()) != null) {
addNameToBanList(data);
}
} finally {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static void muteUsers() {
try {
BufferedReader in = new BufferedReader(new FileReader(
"./Data/Bans/UsersMuted.txt"));
String data = null;
try {
while ((data = in.readLine()) != null) {
mutedNames.add(data);
}
} finally {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Reads all the Ips from text file then adds them all to ban list
**/
public static void banIps() {
try {
BufferedReader in = new BufferedReader(new FileReader(
"./Data/Bans/IpsBanned.txt"));
String data = null;
try {
while ((data = in.readLine()) != null) {
addIpToBanList(data);
}
} finally {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static void muteIps() {
try {
BufferedReader in = new BufferedReader(new FileReader(
"./Data/Bans/IpsMuted.txt"));
String data = null;
try {
while ((data = in.readLine()) != null) {
mutedIps.add(data);
}
} finally {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Writes the username into the text file - when using the ::ban playername
* command
**/
public static void addNameToFile(String Name) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter(
"./Data/Bans/UsersBanned.txt", true));
try {
out.newLine();
out.write(Name);
} finally {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
scratch that i read it wrong. guys probably has a proxy (allows him to connect through a different ip) allowing him to login again you're just gonna have to keep ipbanning till he has no more proxy ip's to use.