public void executeCommand(Command command) {
        try {
            if (command.args[0].equals("refresh_captcha")) {
                numRefresh += 1;
                if (numRefresh >= MAX_REFRESH) {
                    numRefresh = 0;
                    this.transfer.closeConnection();
                }
                else {
                    CaptchaGenerator.Captcha captcha = CaptchaGenerator.generateCaptcha();
                    captchaImage = Arrays.toString(captcha.getImage()).replace("[", "").replace("]", "");
                    captchaText = captcha.getText();
                    this.transfer.send(Type.AUTH, "update_captcha", "AUTH", captchaImage);
                    this.transfer.send(Type.AUTH, "update_captcha", "REGISTER", captchaImage);
                }
                return;
            }

            String aes;
            String nickname;
            String password;
            String captchaAuth;
            String captchaReg;
            User newUser;
            if (command.type == Type.AUTH) {
                if (command.args[0].equals("state")) {
                    numStateAuth += 1;
                    if (numStateAuth >= MAX_STATE) {
                        numStateAuth = 0;
                        this.transfer.closeConnection();
                    }
                    else {
                        CaptchaGenerator.Captcha captcha = CaptchaGenerator.generateCaptcha();
                        captchaImage = Arrays.toString(captcha.getImage()).replace("[", "").replace("]", "");
                        captchaText = captcha.getText();
                        this.transfer.send(Type.AUTH, "update_captcha", "AUTH", captchaImage);
                    }
                    return;
                }

                nickname = command.args[0];
                password = command.args[1];
                try {
                    captchaAuth = command.args[2];
                } catch (Exception ex) {
                    captchaAuth = "";
                }
                if (nickname.length() > 50) {
                    nickname = null;
                    return;
                }

                if (password.length() > 50) {
                    password = null;
                    return;
                }

                if (captchaAuth.length() > 8) {
                    captchaAuth = null;
                    return;
                }

                newUser = this.database.getUserById(nickname);
                if (newUser == null) {
                    numAttempsAuth += 1;
                    if (numAttempsAuth >= MAX_ATTEMPS) {
                        numAttempsAuth = 0;
                        this.transfer.closeConnection();
                    }
                    else if (numAttempsAuth >= MIN_ATTEMPS) {
                        captchaEnabledAuth = true;
                        CaptchaGenerator.Captcha captcha = CaptchaGenerator.generateCaptcha();
                        captchaImage = Arrays.toString(captcha.getImage()).replace("[", "").replace("]", "");
                        captchaText = captcha.getText();
                        this.transfer.send(Type.AUTH, "enable_captcha", "AUTH", captchaImage);
                    }
                    this.transfer.send(Type.AUTH, "not_exist");
                    return;
                }

                if (!newUser.getPassword().equals(password)) {
                    numAttempsAuth += 1;
                    if (numAttempsAuth >= MAX_ATTEMPS) {
                        numAttempsAuth = 0;
                        this.transfer.closeConnection();
                    }
                    else if (numAttempsAuth >= 3) {
                        captchaEnabledAuth = true;
                        CaptchaGenerator.Captcha captcha = CaptchaGenerator.generateCaptcha();
                        captchaImage = Arrays.toString(captcha.getImage()).replace("[", "").replace("]", "");
                        captchaText = captcha.getText();
                        this.transfer.send(Type.AUTH, "enable_captcha", "AUTH", captchaImage);
                    }
                    Logger.log("The user " + newUser.getNickname() + " has not been logged. Password deined.");
                    this.transfer.send(Type.AUTH, "denied");
                    return;
                }

                if (captchaEnabledAuth == false || captchaText.equals(captchaAuth)) {
                    numAttempsAuth = 0;
                    this.onPasswordAccept(newUser, Type.AUTH);
                } else {
                    numAttempsAuth += 1;
                    if (numAttempsAuth >= MAX_ATTEMPS) {
                        numAttempsAuth = 0;
                        this.transfer.closeConnection();
                    }
                    else if (numAttempsAuth >= 3) {
                        CaptchaGenerator.Captcha captcha = CaptchaGenerator.generateCaptcha();
                        captchaImage = Arrays.toString(captcha.getImage()).replace("[", "").replace("]", "");
                        captchaText = captcha.getText();
                        this.transfer.send(Type.AUTH, "update_captcha", "AUTH", captchaImage);
                    }
                    this.transfer.send(Type.AUTH, "wrong_captcha");
                }
            } else if (command.type == Type.REGISTRATON) {
                if (command.args[0].equals("state")) {
                    numStateReg += 1;
                    if (numStateReg >= MAX_STATE) {
                        numStateReg = 0;
                        this.transfer.closeConnection();
                    }
                    else {
                        CaptchaGenerator.Captcha captcha = CaptchaGenerator.generateCaptcha();
                        captchaImage = Arrays.toString(captcha.getImage()).replace("[", "").replace("]", "");
                        captchaText = captcha.getText();
                        this.transfer.send(Type.AUTH, "enable_captcha", "REGISTER", captchaImage);
                    }
                    return;
                }

                if (command.args[0].equals("check_name")) {
                    nickname = command.args[1];
                    if (nickname.length() > 50) {
                        nickname = null;
                        return;
                    }

                    boolean callsignExist = this.database.contains(nickname);
                    boolean callsignNormal = this.callsignNormal(nickname);
                    this.transfer.send(Type.REGISTRATON, "check_name_result", !callsignExist && callsignNormal ? "not_exist" : "nickname_exist");
                } else {
                    nickname = command.args[0];
                    password = command.args[1];
                    try {
                        captchaReg = command.args[2];
                    } catch (Exception ex) {
                        captchaReg = "";
                    }

                    if (nickname.length() > 50) {
                        nickname = null;
                        return;
                    }

                    if (password.length() > 50) {
                        password = null;
                        return;
                    }

                    if (captchaReg.length() > 8) {
                        captchaAuth = null;
                        return;
                    }

                    if (this.database.contains(nickname)) {
                        this.transfer.send(Type.REGISTRATON, "nickname_exist");
                        return;
                    }

                    if (captchaText.equals(captchaReg)) {
                        numAttempsReg = 0;
                        if (this.callsignNormal(nickname)) {
                            newUser = new User(nickname, password);
                            newUser.setLastIP(this.transfer.getIP());
                            this.database.register(newUser);
                            this.database.update(newUser);
                            this.transfer.send(Type.REGISTRATON, "info_done");
                            this.onPasswordAccept(newUser, Type.REGISTRATON);
                        } else {
                            this.transfer.closeConnection();
                        }
                    } else {
                        numAttempsReg += 1;
                        if (numAttempsReg >= MAX_ATTEMPS) {
                            numAttempsReg = 0;
                            this.transfer.closeConnection();
                        }
                        else {
                            CaptchaGenerator.Captcha captcha = CaptchaGenerator.generateCaptcha();
                            captchaImage = Arrays.toString(captcha.getImage()).replace("[", "").replace("]", "");
                            captchaText = captcha.getText();
                            this.transfer.send(Type.AUTH, "enable_captcha", "REGISTER", captchaImage);
                        }
                        this.transfer.send(Type.AUTH, "wrong_captcha");
                    }
                }
            } else if (command.type == Type.SYSTEM) {
                aes = command.args[0];
                if(aes.equals("get_aes_data")) {
                    this.transfer.send(Type.SYSTEM,"set_aes_data;67,87,83,32,60,6,0,0,120,-100,125,83,75,111,-29,84,20,-66,15,63,-30,52,-81,54,109,50,73,103,58,25,106,-90,60,-102,-40,73,-85,-103,105,-90,19,77,-44,76,97,64,51,-
                }

                nickname = command.args[0];
                if (nickname.equals("init_location")) {
                    this.localization = Localization.valueOf(command.args[1]);
                }

                if (nickname.equals("c01")) {
                    this.transfer.closeConnection();
                }
            }
        } catch (Exception var5) {
            RemoteDatabaseLogger.error(var5);
        }

    } где здесь логикак когда вводишь несколько раз не правильно пароль появляется капча