diff options
author | Petr Ilin <hevav@hevav.dev> | 2022-12-23 12:26:01 +0300 |
---|---|---|
committer | Petr Ilin <hevav@hevav.dev> | 2022-12-23 12:26:01 +0300 |
commit | 17e5d6160afbf4fd219e0c5a3720c3357b8ba1b3 (patch) | |
tree | 3dcfce4cc558c7e15aabd1709dcb679b317b3316 /src/main/java/net/elytrium | |
parent | 206fedfd8765987da659f4b9ef6bcee78a79f3a2 (diff) | |
download | LimboAuth-17e5d6160afbf4fd219e0c5a3720c3357b8ba1b3.tar.gz LimboAuth-17e5d6160afbf4fd219e0c5a3720c3357b8ba1b3.tar.bz2 LimboAuth-17e5d6160afbf4fd219e0c5a3720c3357b8ba1b3.zip |
Cracked nicknames detection fix
Diffstat (limited to 'src/main/java/net/elytrium')
-rw-r--r-- | src/main/java/net/elytrium/limboauth/LimboAuth.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java index 1a3b6ca..a42322a 100644 --- a/src/main/java/net/elytrium/limboauth/LimboAuth.java +++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java @@ -17,6 +17,7 @@ package net.elytrium.limboauth; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.inject.Inject; @@ -599,8 +600,13 @@ public class LimboAuth { } } - private boolean validateScheme(JsonObject object, List<String> scheme) { + private boolean validateScheme(JsonElement jsonElement, List<String> scheme) { if (!scheme.isEmpty()) { + if (!(jsonElement instanceof JsonObject)) { + return false; + } + + JsonObject object = (JsonObject) jsonElement; for (String field : scheme) { if (!object.has(field)) { return false; @@ -626,15 +632,15 @@ public class LimboAuth { return new PremiumResponse(PremiumState.RATE_LIMIT); } - JsonObject jsonObject = (JsonObject) JsonParser.parseString(response.body()); + JsonElement jsonElement = JsonParser.parseString(response.body()); if (statusCode == Settings.IMP.MAIN.STATUS_CODE_USER_EXISTS - && this.validateScheme(jsonObject, Settings.IMP.MAIN.USER_EXISTS_JSON_VALIDATOR_FIELDS)) { - return new PremiumResponse(PremiumState.PREMIUM, jsonObject.get(Settings.IMP.MAIN.JSON_UUID_FIELD).getAsString()); + && 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()); } if (statusCode == Settings.IMP.MAIN.STATUS_CODE_USER_NOT_EXISTS - && this.validateScheme(jsonObject, Settings.IMP.MAIN.USER_NOT_EXISTS_JSON_VALIDATOR_FIELDS)) { + && this.validateScheme(jsonElement, Settings.IMP.MAIN.USER_NOT_EXISTS_JSON_VALIDATOR_FIELDS)) { return new PremiumResponse(PremiumState.CRACKED); } |