private boolean loginPacket(Packet00Login packet, InetAddress ip, int port) {

        if (packet.getUsername() == null || packet.getUsername().equals("")) {
            Packet03InvalidUser invalid = new Packet03InvalidUser();
            sendData(invalid.getData(), ip, port);
            return false;
        }

        if (connectPlayers.isEmpty()) {
            this.connectPlayers.add(new Tank(posTeam1[0], posTeam1[1], null, ((Packet00Login) packet).getUsername(), ip, port));
            Packet00Login newPacket = new Packet00Login(packet.getUsername(), posTeam1[0], posTeam1[1], 0);
            cont = 1;
            sendData(newPacket.getData(), ip, port);
            return true;
        } else {
            for (Tank t : connectPlayers) {
                if (t.getUsername().equalsIgnoreCase(packet.getUsername())) {
                    Packet03InvalidUser invalid = new Packet03InvalidUser();
                    sendData(invalid.getData(), ip, port);
                    return false;
                }
            }

            for (Tank tank : connectPlayers) {
                Packet00Login p = new Packet00Login(tank.getUsername(), tank.getX(), tank.getY(), tank.getColor());
                sendData(p.getData(), ip, port);
            }
            Packet00Login newPacket = null;
            if ((cont % 2) == 0) {
                Tank tank = new Tank(posTeam1[0], posTeam1[1], null, ((Packet00Login) packet).getUsername(), ip, port);
                newPacket = new Packet00Login(packet.getUsername(), posTeam1[0], posTeam1[1], 0);
                this.connectPlayers.add(tank);
            } else {
                Tank tank = new Tank(posTeam2[0], posTeam2[1], null, ((Packet00Login) packet).getUsername(), ip, port);
                newPacket = new Packet00Login(packet.getUsername(), posTeam2[0], posTeam2[1], 1);
                tank.setColor(1);
                tank.updateImg();
                this.connectPlayers.add(tank);
            }
            if (cont == 0) {
                cont = 1;
            } else {
                cont = 0;
            }
            sendDataToAllClients(newPacket.getData());
            return true;
        }

    }