package server.commands.methods;
import java.util.Iterator;
import org.quickserver.net.server.ClientHandler;
import server.protocol.ClientInfo;
import server.protocol.GameRoom;
/**
* The Class CheckForNameInUse. Handles the name-checking.
*/
public class CheckForNameInUse {
private ClientInfo data;
/**
* Check for name in use.
*
* @param name the name that will be checked
* @param room the room that will be checked
* @return true, if successful
*/
public boolean checkForNameInUse(String name, GameRoom room) {
Iterator<ClientHandler> iterator = room.getClients().iterator();
ClientHandler toHandler = null;
while (iterator.hasNext()) {
toHandler = (ClientHandler) iterator.next();
data = (ClientInfo) toHandler.getClientData();
if (name.equals(data.getName()))
return true;
}
return false;
}
}