#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; return false;
} }
/**
* Resets the login count of the given player to 0.
*
* @param name the player's name
*/
public void resetCounts(String name) { public void resetCounts(String name) {
if (isEnabled) { if (isEnabled) {
captchaCodes.remove(name.toLowerCase()); captchaCodes.remove(name.toLowerCase());

View File

@ -73,9 +73,14 @@ public class AsynchronousLogin implements AsynchronousProcess {
private boolean needsCaptcha(Player player) { private boolean needsCaptcha(Player player) {
if (captchaManager.isCaptchaRequired(player.getName())) { final String playerName = player.getName();
service.send(player, MessageKey.USAGE_CAPTCHA, captchaManager.getCaptchaCodeOrGenerateNew(player.getName())); if (captchaManager.isCaptchaRequired(playerName)) {
service.send(player, MessageKey.USAGE_CAPTCHA, captchaManager.getCaptchaCodeOrGenerateNew(playerName));
return true; 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; return false;
} }
@ -199,7 +204,6 @@ public class AsynchronousLogin implements AsynchronousProcess {
if (!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) { if (!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) {
ConsoleLogger.info(player.getName() + " used the wrong password"); ConsoleLogger.info(player.getName() + " used the wrong password");
} }
captchaManager.increaseCount(name);
if (service.getProperty(RestrictionSettings.KICK_ON_WRONG_PASSWORD)) { if (service.getProperty(RestrictionSettings.KICK_ON_WRONG_PASSWORD)) {
bukkitService.scheduleSyncDelayedTask(new Runnable() { bukkitService.scheduleSyncDelayedTask(new Runnable() {
@Override @Override