/* this method disconnects and removes client from the clients list. * Also cleans up after him (channels, battles) and notifies other * users of his departure. "reason" is used with LEFT command to * notify other users on same channel of this client's departure * reason (it may be left blank ("") to give no reason). */ public static boolean killClient(Client client, String reason) { int index = clients.indexOf(client); if (index == -1) return false; if (!client.alive) return false; client.disconnect(); clients.remove(index); client.alive = false; if (reason.trim().equals("")) reason = "Quit"; // let's remove client from all channels he is participating in: client.leaveAllChannels(reason); if (client.battleID != -1) { Battle bat = Battles.getBattleByID(client.battleID); if (bat == null) { System.out.println("Serious error occured: Invalid battle ID. Server will now exit!"); TASServer.closeServerAndExit(); } Battles.leaveBattle( client, bat); // automatically checks if client is founder and closes the battle } if (client.account.accessLevel() != Account.NIL_ACCESS) { sendToAllRegisteredUsers("REMOVEUSER " + client.account.user); if (TASServer.DEBUG > 0) System.out.println("Registered user killed: " + client.account.user); } else { if (TASServer.DEBUG > 0) System.out.println("Unregistered user killed"); } if (TASServer.LAN_MODE) { Accounts.removeAccount(client.account); } return true; }