Skip to content

Commit 3bcc6c2

Browse files
author
games647
committed
Differentiate between rate limit and IOExceptions
(Related #698)
1 parent b351338 commit 3bcc6c2

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

core/src/main/java/com/github/games647/fastlogin/core/hooks/bedrock/BedrockService.java

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,31 @@ protected void checkNameConflict(String username, LoginSource source) {
6969
Optional<Profile> premiumUUID = Optional.empty();
7070
try {
7171
premiumUUID = core.getResolver().findProfile(username);
72-
} catch (IOException | RateLimitException e) {
72+
} catch (IOException ioEx) {
7373
core.getPlugin().getLog().error(
74-
"Could not check whether Bedrock Player {}'s name conflicts a premium Java player's name.",
75-
username);
76-
try {
77-
source.kick("Could not check if your name conflicts an existing premium Java account's name.\n"
78-
+ "This is usually a serverside error.");
79-
} catch (Exception ex) {
80-
core.getPlugin().getLog().error("Could not kick Player {}", username, ex);
81-
}
74+
"Could not check whether Bedrock Player {}'s name conflicts a premium Java player's name.",
75+
username);
76+
77+
kickPlayer(source, username, "Could not check if your name conflicts an existing " +
78+
"premium Java account's name. This is usually a serverside error.");
79+
} catch (RateLimitException rateLimitException) {
80+
core.getPlugin().getLog().warn("Mojang API rate limit hit");
81+
kickPlayer(source, username, "Could not check if your name conflicts an existing premium " +
82+
"Java account's name. Try again in a few minutes");
8283
}
8384

8485
if (premiumUUID.isPresent()) {
8586
core.getPlugin().getLog().info("Bedrock Player {}'s name conflicts an existing premium Java account's name",
8687
username);
87-
try {
88-
source.kick("Your name conflicts an existing premium Java account's name");
89-
} catch (Exception ex) {
90-
core.getPlugin().getLog().error("Could not kick Player {}", username, ex);
91-
}
88+
kickPlayer(source, username, "Your name conflicts an existing premium Java account's name");
89+
}
90+
}
91+
92+
private void kickPlayer(LoginSource source, String username, String message) {
93+
try {
94+
source.kick(message);
95+
} catch (Exception ex) {
96+
core.getPlugin().getLog().error("Could not kick Player {}", username, ex);
9297
}
9398
}
9499

0 commit comments

Comments
 (0)