From 85591122aa274c640c3980588c948bfdd07eed91 Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Tue, 3 Jan 2023 22:22:14 +0300 Subject: incrementBruteforceAttempts correctly --- build.gradle | 2 +- src/main/java/net/elytrium/limboauth/LimboAuth.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 875dc2f..2090356 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ plugins { } setGroup("net.elytrium") -setVersion("1.0.8") +setVersion("1.0.9-SNAPSHOT") java { setSourceCompatibility(JavaVersion.VERSION_11) diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java index eed58f3..15cc0be 100644 --- a/src/main/java/net/elytrium/limboauth/LimboAuth.java +++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java @@ -834,17 +834,21 @@ public class LimboAuth { } public void incrementBruteforceAttempts(InetAddress address) { - this.bruteforceCache.get(address).incrementAttempts(); + this.getBruteforceUser(address).incrementAttempts(); } public int getBruteforceAttempts(InetAddress address) { + return this.getBruteforceUser(address).getAttempts(); + } + + private CachedBruteforceUser getBruteforceUser(InetAddress address) { CachedBruteforceUser user = this.bruteforceCache.get(address); if (user == null) { user = new CachedBruteforceUser(System.currentTimeMillis()); this.bruteforceCache.put(address, user); } - return user.getAttempts(); + return user; } public void clearBruteforceAttempts(InetAddress address) { -- cgit