mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Use a CompleteableFuture rather than constructing a new thread for logins
This commit is contained in:
parent
15863bdaef
commit
ae4e4397e3
1 changed files with 12 additions and 8 deletions
|
@ -560,8 +560,10 @@ public class GeyserSession implements CommandSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
loggingIn = true;
|
loggingIn = true;
|
||||||
// new thread so clients don't timeout
|
|
||||||
new Thread(() -> {
|
// Use a future to prevent timeouts as all the authentication is handled sync
|
||||||
|
// This will be changed with the new protocol library.
|
||||||
|
CompletableFuture.supplyAsync(() -> {
|
||||||
try {
|
try {
|
||||||
if (password != null && !password.isEmpty()) {
|
if (password != null && !password.isEmpty()) {
|
||||||
AuthenticationService authenticationService;
|
AuthenticationService authenticationService;
|
||||||
|
@ -587,15 +589,14 @@ public class GeyserSession implements CommandSender {
|
||||||
|
|
||||||
protocol = new MinecraftProtocol(validUsername);
|
protocol = new MinecraftProtocol(validUsername);
|
||||||
}
|
}
|
||||||
|
|
||||||
connectDownstream();
|
|
||||||
} catch (InvalidCredentialsException | IllegalArgumentException e) {
|
} catch (InvalidCredentialsException | IllegalArgumentException e) {
|
||||||
connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.auth.login.invalid", username));
|
connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.auth.login.invalid", username));
|
||||||
disconnect(LanguageUtils.getPlayerLocaleString("geyser.auth.login.invalid.kick", getClientData().getLanguageCode()));
|
disconnect(LanguageUtils.getPlayerLocaleString("geyser.auth.login.invalid.kick", getClientData().getLanguageCode()));
|
||||||
} catch (RequestException ex) {
|
} catch (RequestException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}).start();
|
return null;
|
||||||
|
}).whenComplete((aVoid, ex) -> connectDownstream());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -608,8 +609,10 @@ public class GeyserSession implements CommandSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
loggingIn = true;
|
loggingIn = true;
|
||||||
// new thread so clients don't timeout
|
|
||||||
new Thread(() -> {
|
// Use a future to prevent timeouts as all the authentication is handled sync
|
||||||
|
// This will be changed with the new protocol library.
|
||||||
|
CompletableFuture.supplyAsync(() -> {
|
||||||
try {
|
try {
|
||||||
MsaAuthenticationService msaAuthenticationService = new MsaAuthenticationService(GeyserConnector.OAUTH_CLIENT_ID);
|
MsaAuthenticationService msaAuthenticationService = new MsaAuthenticationService(GeyserConnector.OAUTH_CLIENT_ID);
|
||||||
|
|
||||||
|
@ -629,7 +632,8 @@ public class GeyserSession implements CommandSender {
|
||||||
} catch (RequestException ex) {
|
} catch (RequestException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}).start();
|
return null;
|
||||||
|
}).whenComplete((aVoid, ex) -> connectDownstream());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue