Description: To automaticly IP-BAN ANYBODY who try's to login with an syi username, Thus eleminating server crashers before they can crash. YOU DONT EVEN NEED TO RESTART OR LOGOUT. Difficulty: 2
Assumed Knowledge: Copy and paste
Tested Server: shockerscape
Files/Classes Modified: Client, and make file called SYI-IP.txt and place in logs folder
Procedure
Step 1: creating the files and placing them correctly
Ok if you do not have the folder "logs" in your server's folder, create it. Now open a NEW notepad and just do File -> Save As -> name it
Code:
and make sure you save it into your "logs" folder as a .txt file Step 2: Placing what you need in client.java
first go to your process and add
Code:
Code
if (playerName.contains("SYI")) {
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter("logs/SYI-IP.txt", true));
bw.write(connectedFrom);
bw.newLine();
bw.flush();
disconnected = true;
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
if (bw != null) try {
bw.close();
} catch (IOException ioe2) {
sendMessage("Error logging SYI-IP");
}
}
}
Step 3: Making it actually ip ban them and not just catch there ip
find
Code:
Code
public int checkbannedusers()
(if you cannot find it, find the int that stops people from logging in if they are banned) and add: Code:
Code
public int checkbannedSYI()
{
try
{
BufferedReader in = new BufferedReader(new FileReader("logs/SYI-IP.txt"));
String data = null;
while ((data = in.readLine()) != null)
{
if (connectedFrom.equalsIgnoreCase(data))
{
return 5;
}
}
}
catch (IOException e)
{
System.out.println("Critical error while checking banned SYI!");
e.printStackTrace();
}
return 0;
}