#601 Increase captcha count on login start

- Increase login count at start of the login process (as done previously) and not only when login has failed AND player is still online
- Add missing javadoc to CaptchaManager
This commit is contained in:
ljacqu 2016-06-04 10:44:34 +02:00
parent 12703d1613
commit 40ce01f65e
2 changed files with 12 additions and 3 deletions

View File

@ -110,6 +110,11 @@ public class CaptchaManager implements SettingsDependent {
return false;
}
/**
* Resets the login count of the given player to 0.
*
* @param name the player's name
*/
public void resetCounts(String name) {
if (isEnabled) {
captchaCodes.remove(name.toLowerCase());

View File

@ -73,9 +73,14 @@ public class AsynchronousLogin implements AsynchronousProcess {
private boolean needsCaptcha(Player player) {
if (captchaManager.isCaptchaRequired(player.getName())) {
service.send(player, MessageKey.USAGE_CAPTCHA, captchaManager.getCaptchaCodeOrGenerateNew(player.getName()));
final String playerName = player.getName();
if (captchaManager.isCaptchaRequired(playerName)) {
service.send(player, MessageKey.USAGE_CAPTCHA, captchaManager.getCaptchaCodeOrGenerateNew(playerName));
return true;
} else {
// Increase the count here before knowing the result of the login.
// If login is successful, we clear the count for the player
captchaManager.increaseCount(playerName);
}
return false;
}
@ -199,7 +204,6 @@ public class AsynchronousLogin implements AsynchronousProcess {
if (!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) {
ConsoleLogger.info(player.getName() + " used the wrong password");
}
captchaManager.increaseCount(name);
if (service.getProperty(RestrictionSettings.KICK_ON_WRONG_PASSWORD)) {
bukkitService.scheduleSyncDelayedTask(new Runnable() {
@Override