diff options
author | Petr Ilin <hevav@hevav.dev> | 2022-12-30 16:56:13 +0300 |
---|---|---|
committer | Petr Ilin <hevav@hevav.dev> | 2022-12-30 16:56:13 +0300 |
commit | 492aa9818fbbb0c6e0472c5433c54e02e95a229d (patch) | |
tree | d193453aec736ea277def2b0d57e17e84af111da /src/main/java/net/elytrium | |
parent | 8886cacd0db218e09aebfe5f44bcfb97e20b914a (diff) | |
download | LimboAuth-492aa9818fbbb0c6e0472c5433c54e02e95a229d.tar.gz LimboAuth-492aa9818fbbb0c6e0472c5433c54e02e95a229d.tar.bz2 LimboAuth-492aa9818fbbb0c6e0472c5433c54e02e95a229d.zip |
More correct premium detection
Diffstat (limited to 'src/main/java/net/elytrium')
-rw-r--r-- | src/main/java/net/elytrium/limboauth/LimboAuth.java | 33 | ||||
-rw-r--r-- | src/main/java/net/elytrium/limboauth/command/PremiumCommand.java | 2 |
2 files changed, 20 insertions, 15 deletions
diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java index dd4bdd8..215e9c8 100644 --- a/src/main/java/net/elytrium/limboauth/LimboAuth.java +++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java @@ -681,7 +681,7 @@ public class LimboAuth { if (statusCode == Settings.IMP.MAIN.STATUS_CODE_USER_EXISTS && this.validateScheme(jsonElement, Settings.IMP.MAIN.USER_EXISTS_JSON_VALIDATOR_FIELDS)) { - return new PremiumResponse(PremiumState.PREMIUM, ((JsonObject) jsonElement).get(Settings.IMP.MAIN.JSON_UUID_FIELD).getAsString()); + return new PremiumResponse(PremiumState.PREMIUM_USERNAME, ((JsonObject) jsonElement).get(Settings.IMP.MAIN.JSON_UUID_FIELD).getAsString()); } if (statusCode == Settings.IMP.MAIN.STATUS_CODE_USER_NOT_EXISTS @@ -768,6 +768,10 @@ public class LimboAuth { return false; } case PREMIUM: { + this.premiumCache.put(lowercaseNickname, new CachedPremiumUser(System.currentTimeMillis(), true)); + return true; + } + case PREMIUM_USERNAME: { premium = true; break; } @@ -787,14 +791,6 @@ public class LimboAuth { } } - if (wasRateLimited && unknown || wasRateLimited && wasError) { - return Settings.IMP.MAIN.ON_RATE_LIMIT_PREMIUM; - } - - if (wasError && unknown || !premium) { - return Settings.IMP.MAIN.ON_SERVER_ERROR_PREMIUM; - } - if (unknown) { if (uuid != null && this.isPremiumUuid(uuid)) { this.premiumCache.put(lowercaseNickname, new CachedPremiumUser(System.currentTimeMillis(), true)); @@ -806,6 +802,14 @@ public class LimboAuth { } } + if (wasRateLimited && unknown || wasRateLimited && wasError) { + return Settings.IMP.MAIN.ON_RATE_LIMIT_PREMIUM; + } + + if (wasError && unknown || !premium) { + return Settings.IMP.MAIN.ON_SERVER_ERROR_PREMIUM; + } + this.premiumCache.put(lowercaseNickname, new CachedPremiumUser(System.currentTimeMillis(), true)); return true; } @@ -984,10 +988,11 @@ public class LimboAuth { } public enum PremiumState { - PREMIUM(), - CRACKED(), - UNKNOWN(), - RATE_LIMIT(), - ERROR() + PREMIUM, + PREMIUM_USERNAME, + CRACKED, + UNKNOWN, + RATE_LIMIT, + ERROR } } diff --git a/src/main/java/net/elytrium/limboauth/command/PremiumCommand.java b/src/main/java/net/elytrium/limboauth/command/PremiumCommand.java index f4063d7..53cce89 100644 --- a/src/main/java/net/elytrium/limboauth/command/PremiumCommand.java +++ b/src/main/java/net/elytrium/limboauth/command/PremiumCommand.java @@ -77,7 +77,7 @@ public class PremiumCommand implements SimpleCommand { } else if (player.getHash().isEmpty()) { source.sendMessage(this.alreadyPremium); } else if (AuthSessionHandler.checkPassword(args[0], player, this.playerDao)) { - if (this.plugin.isPremiumExternal(username.toLowerCase(Locale.ROOT)).getState() == LimboAuth.PremiumState.PREMIUM) { + if (this.plugin.isPremiumExternal(username.toLowerCase(Locale.ROOT)).getState() == LimboAuth.PremiumState.PREMIUM_USERNAME) { try { player.setHash(""); this.playerDao.update(player); |