void (final @NotNull Runnable onFinished) { doDisconnect(); connectIfNeeded(new ServerConnector.ConnectionCallback<>() { @Override public void connected(@NotNull ServerRuntimeInstance<D> serverRuntimeInstance) { onFinished.run(); } @Override public void errorOccurred(@NotNull String errorMessage) { onFinished.run(); } }); }