Too lazy to check anything into your own code so here's the one in my source >.< if that might help, it's probably universal ahahaha if it doesn't, reply and i'll get to check, or if doesn't help at all and you really want yours fixed, then tell me. Please use something like notepad++ to put your things in code forms ( with tabs etc)
Code:
if (playerCommand.startsWith("ban") && playerCommand.charAt(3) == ' ') {
try {
String playerToBan = playerCommand.substring(4);
Connection.addNameToBanList(playerToBan);
Connection.addNameToFile(playerToBan);
for(int i = 0; i < Config.MAX_PLAYERS; i++) {
if(PlayerHandler.players[i] != null) {
if(PlayerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
PlayerHandler.players[i].disconnected = true;
Client c2 = (Client)PlayerHandler.players[i];
c2.sendMessage(" " +c2.playerName+ " Got Banned By " + c.playerName+ ".");
}
}
}
} catch(Exception e) {
c.sendMessage("Player Must Be Offline.");
}
}
Connections
Code:
public static void addNameToBanList(String name) {
bannedNames.add(name.toLowerCase());
}
Code:
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();
}
}
Code:
public static boolean isNamedBanned(String name) {
if(bannedNames.contains(name.toLowerCase())) {
return true;
}
return false;
}