13
0
geforkt von Mirrors/Velocity

Add convenience connectWithIndication() method.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-10-21 17:49:51 -04:00
Ursprung 8d97e98920
Commit 3bd48dec99
2 geänderte Dateien mit 16 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -24,6 +24,13 @@ public interface ConnectionRequestBuilder {
*/ */
CompletableFuture<Result> connect(); 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 * Initiates the connection to the remote server without waiting for a result. Velocity will use generic error
* handling code to notify the user. * handling code to notify the user.

Datei anzeigen

@ -467,8 +467,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
} }
@Override @Override
public void fireAndForget() { public CompletableFuture<Boolean> connectWithIndication() {
connect() return connect()
.whenCompleteAsync((status, throwable) -> { .whenCompleteAsync((status, throwable) -> {
if (throwable != null) { if (throwable != null) {
handleConnectionException(server, throwable); 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))); handleConnectionException(server, Disconnect.create(status.getReason().orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR)));
break; break;
} }
}, connection.eventLoop()); }, connection.eventLoop())
.thenApply(Result::isSuccessful);
}
@Override
public void fireAndForget() {
connectWithIndication();
} }
} }
} }