mirror of
https://github.com/PaperMC/Velocity.git
synced 2024-11-27 06:30:35 +08:00
Add convenience connectWithIndication() method.
This commit is contained in:
parent
8d97e98920
commit
3bd48dec99
@ -24,6 +24,13 @@ public interface ConnectionRequestBuilder {
|
||||
*/
|
||||
CompletableFuture<Result> connect();
|
||||
|
||||
/**
|
||||
* Initiates the connection to the remote server and emits a result on the {@link CompletableFuture} after the user
|
||||
* has logged on. Velocity's own built-in handling will be used to provide errors to the client.
|
||||
* @return a {@link CompletableFuture} representing the status of this connection
|
||||
*/
|
||||
CompletableFuture<Boolean> connectWithIndication();
|
||||
|
||||
/**
|
||||
* Initiates the connection to the remote server without waiting for a result. Velocity will use generic error
|
||||
* handling code to notify the user.
|
||||
|
@ -467,8 +467,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireAndForget() {
|
||||
connect()
|
||||
public CompletableFuture<Boolean> connectWithIndication() {
|
||||
return connect()
|
||||
.whenCompleteAsync((status, throwable) -> {
|
||||
if (throwable != null) {
|
||||
handleConnectionException(server, throwable);
|
||||
@ -489,7 +489,13 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
handleConnectionException(server, Disconnect.create(status.getReason().orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR)));
|
||||
break;
|
||||
}
|
||||
}, connection.eventLoop());
|
||||
}, connection.eventLoop())
|
||||
.thenApply(Result::isSuccessful);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireAndForget() {
|
||||
connectWithIndication();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user