Differentiate between rate limit and IOExceptions

(Related #698)
This commit is contained in:
games647
2022-01-14 14:22:11 +01:00
parent b351338e0b
commit 3bcc6c2e94

View File

@ -69,26 +69,31 @@ public abstract class BedrockService<B> {
Optional<Profile> premiumUUID = Optional.empty(); Optional<Profile> premiumUUID = Optional.empty();
try { try {
premiumUUID = core.getResolver().findProfile(username); premiumUUID = core.getResolver().findProfile(username);
} catch (IOException | RateLimitException e) { } catch (IOException ioEx) {
core.getPlugin().getLog().error( core.getPlugin().getLog().error(
"Could not check whether Bedrock Player {}'s name conflicts a premium Java player's name.", "Could not check whether Bedrock Player {}'s name conflicts a premium Java player's name.",
username); username);
try {
source.kick("Could not check if your name conflicts an existing premium Java account's name.\n" kickPlayer(source, username, "Could not check if your name conflicts an existing " +
+ "This is usually a serverside error."); "premium Java account's name. This is usually a serverside error.");
} catch (Exception ex) { } catch (RateLimitException rateLimitException) {
core.getPlugin().getLog().error("Could not kick Player {}", username, ex); core.getPlugin().getLog().warn("Mojang API rate limit hit");
} kickPlayer(source, username, "Could not check if your name conflicts an existing premium " +
"Java account's name. Try again in a few minutes");
} }
if (premiumUUID.isPresent()) { if (premiumUUID.isPresent()) {
core.getPlugin().getLog().info("Bedrock Player {}'s name conflicts an existing premium Java account's name", core.getPlugin().getLog().info("Bedrock Player {}'s name conflicts an existing premium Java account's name",
username); username);
try { kickPlayer(source, username, "Your name conflicts an existing premium Java account's name");
source.kick("Your name conflicts an existing premium Java account's name"); }
} catch (Exception ex) { }
core.getPlugin().getLog().error("Could not kick Player {}", username, ex);
} private void kickPlayer(LoginSource source, String username, String message) {
try {
source.kick(message);
} catch (Exception ex) {
core.getPlugin().getLog().error("Could not kick Player {}", username, ex);
} }
} }