From 17e5d6160afbf4fd219e0c5a3720c3357b8ba1b3 Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Fri, 23 Dec 2022 12:26:01 +0300 Subject: Cracked nicknames detection fix --- src/main/java/net/elytrium/limboauth/LimboAuth.java | 16 +++++++++++----- 1 file 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 scheme) { + private boolean validateScheme(JsonElement jsonElement, List 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); } -- cgit