public static function validatePassword(User $user, $value)
 {
     $length = strlen($value);
     $config = $user->getMain()->getConfig();
     $minLength = $config->getNested("Registration.MinLength", 4);
     if ($length < $minLength) {
         $user->getPlayer()->sendMessage($config->getNested("Messages.Register.PasswordUnderflow", "too short"));
         return false;
     }
     $maxLength = $config->getNested("Registration.MaxLength", -1);
     if ($maxLength !== -1 and $length > $maxLength) {
         $user->getPlayer()->sendMessage($config->getNested("Messages.Register.PasswordOverflow", "too long"));
         return false;
     }
     if ($config->getNested("Registration.BanPureLetters", false) and preg_match('/^[a-z]+$/i', $value)) {
         $user->getPlayer()->sendMessage($config->getNested("Messages.Register.PasswordPureLetters", "only letters"));
         return false;
     }
     if ($config->getNested("Registration.BanPureNumbers", false) and preg_match('/^[0-9]+$/', $value)) {
         $user->getPlayer()->sendMessage($config->getNested("Messages.Register.PasswordPureNumbers", "only numbers"));
         return false;
     }
     if ($config->getNested("Registration.DisallowSlashes", true) and $value[0] === "/") {
         $user->getPlayer()->sendMessage($config->getNested("Messages.Register.PasswordSlashes", "do not start with slashes"));
         return false;
     }
     return true;
 }
 protected function onRun(array $args, User $user)
 {
     if (!isset($args[0])) {
         return "Usage: " . $this->getUsage();
     }
     $password = $args[0];
     $hash = HereAuth::hash($password, $user->getPlayer());
     $firstHash = $user->getChangepwHash();
     if ($firstHash !== null) {
         $user->setChangepwHash(null);
         if ($firstHash === $hash) {
             $user->getAccountInfo()->passwordHash = $hash;
             return $this->getMessage("Commands.ChangePassword.Success", "Your password has been changed.");
         }
         return $this->getMessage("Commands.ChangePassword.DoubleCheckFailure", "Your password is different this time! Aborted.");
     }
     if (!PasswordInputRegistrationStep::validatePassword($user, $password)) {
         return false;
     }
     $user->setChangepwHash($hash);
     return $this->getMessage("Commands.ChangePassword.RequestRepeat", "Please run this command again to confirm.");
 }