3838import com .faforever .client .preferences .PreferencesService ;
3939import com .faforever .client .remote .FafServerAccessor ;
4040import com .faforever .client .replay .ReplayServer ;
41+ import com .faforever .client .task .TaskService ;
4142import com .faforever .client .theme .UiService ;
4243import com .faforever .client .ui .StageHolder ;
4344import com .faforever .client .util .ConcurrentUtil ;
@@ -118,6 +119,7 @@ public class GameRunner implements InitializingBean {
118119 private final NotificationPrefs notificationPrefs ;
119120 private final FxApplicationThreadExecutor fxApplicationThreadExecutor ;
120121 private final LogAnalyzerService logAnalyzerService ;
122+ private final TaskService taskService ;
121123
122124 private final MaskPatternLayout logMasker = new MaskPatternLayout ();
123125 private final SimpleObjectProperty <Integer > runningGameId = new SimpleObjectProperty <>();
@@ -148,7 +150,7 @@ public void afterPropertiesSet() {
148150
149151 fafServerAccessor .getEvents (NoticeInfo .class )
150152 .filter (notice -> Objects .equals (notice .getStyle (), "kill" ))
151- .doOnNext (notice -> {
153+ .doOnNext (_ -> {
152154 log .info ("Game close requested by server" );
153155 String linksRules = clientProperties .getLinks ().get ("linksRules" );
154156 ImmediateNotification notification = new ImmediateNotification (i18n .get ("game.kicked.title" ),
@@ -163,8 +165,8 @@ public void afterPropertiesSet() {
163165 .subscribe ();
164166
165167
166- fafServerAccessor .connectionStateProperty ().addListener (( observable , oldValue , newValue ) -> {
167- if (isRunning () && newValue == ConnectionState .CONNECTED && oldValue != ConnectionState .CONNECTED ) {
168+ fafServerAccessor .connectionStateProperty ().subscribe (( oldState , newState ) -> {
169+ if (isRunning () && newState == ConnectionState .CONNECTED && oldState != ConnectionState .CONNECTED ) {
168170 fafServerAccessor .restoreGameSession (runningGameId .get ());
169171 }
170172 });
@@ -183,16 +185,16 @@ CompletableFuture<Void> startOnlineGame(GameLaunchResponse gameLaunchResponse) {
183185 String mapFolderName = gameLaunchResponse .getMapName ();
184186 CompletableFuture <Void > downloadMapFuture = mapFolderName == null ? completedFuture (
185187 null ) : mapService .downloadIfNecessary (mapFolderName ).toFuture ();
186- CompletableFuture < League > leagueFuture = hasLeague ? completedFuture ( null ) : getDivisionInfo (
187- leaderboard ).toFuture ();
188- CompletableFuture <Integer > startReplayServerFuture = replayServer .start (uid );
189- CompletableFuture <Integer > startIceAdapterFuture = startIceAdapter (uid );
190-
191- return CompletableFuture .allOf (downloadMapFuture , leagueFuture , startIceAdapterFuture , startReplayServerFuture )
192- .thenApply (_ -> gameMapper .map (gameLaunchResponse , leagueFuture .join ()))
193- .thenApply (parameters -> launchOnlineGame (parameters , startIceAdapterFuture .join (),
194- startReplayServerFuture .join ()))
195- .whenCompleteAsync ((process , throwable ) -> {
188+
189+ CompletableFuture < League > loadLeagueInfoFuture = hasLeague ? completedFuture ( null ) : taskService . submitFutureTask ( "league.loadInfo" , () -> getDivisionInfo ( leaderboard ).toFuture () );
190+ CompletableFuture <Integer > runReplayServerFuture = taskService . submitFutureTask ( " replayServer.connecting" , () -> replayServer . start (uid ) );
191+ CompletableFuture <Integer > runIceAdapterFuture = taskService . submitFutureTask ( "iceAdapter.connecting" , () -> startIceAdapter (uid ) );
192+
193+ return CompletableFuture .allOf (downloadMapFuture , loadLeagueInfoFuture , runReplayServerFuture , runIceAdapterFuture )
194+ .thenApply (_ -> gameMapper .map (gameLaunchResponse , loadLeagueInfoFuture .join ()))
195+ .thenApply (parameters -> launchOnlineGame (parameters , runIceAdapterFuture .join (),
196+ runReplayServerFuture .join ()))
197+ .whenCompleteAsync ((process , _ ) -> {
196198 if (process != null ) {
197199 this .process .set (process );
198200 runningGameId .set (uid );
@@ -483,7 +485,7 @@ private Optional<Parent> getAnalysisButtonIfNecessary(Optional<String> logFileCo
483485 infoIcon .getStyleClass ().add ("info-icon" );
484486 final Button showAnalysisBtn = new Button (i18n .get ("game.log.analysis.solutionBtn" ), infoIcon );
485487 showAnalysisBtn .setDefaultButton (true );
486- showAnalysisBtn .setOnAction (event -> notificationService .addNotification (
488+ showAnalysisBtn .setOnAction (_ -> notificationService .addNotification (
487489 new ImmediateNotification (i18n .get ("game.log.analysis" ), message .toString (), WARN , actions )));
488490
489491 return showAnalysisBtn ;
@@ -509,7 +511,7 @@ public void launchTutorial(MapVersion mapVersion, String technicalMapName) {
509511 }
510512
511513 if (!preferencesService .hasValidGamePath ()) {
512- gamePathHandler .chooseAndValidateGameDirectory ().thenAccept (path -> launchTutorial (mapVersion , technicalMapName ));
514+ gamePathHandler .chooseAndValidateGameDirectory ().thenAccept (_ -> launchTutorial (mapVersion , technicalMapName ));
513515 return ;
514516 }
515517
@@ -547,12 +549,12 @@ public void startOffline() {
547549 }
548550
549551 if (!preferencesService .hasValidGamePath ()) {
550- gamePathHandler .chooseAndValidateGameDirectory ().thenAccept (path -> startOffline ());
552+ gamePathHandler .chooseAndValidateGameDirectory ().thenAccept (_ -> startOffline ());
551553 return ;
552554 }
553555
554556 CompletableFuture .supplyAsync (() -> forgedAllianceLaunchService .launchOfflineGame (null ))
555- .whenCompleteAsync ((process , throwable ) -> {
557+ .whenCompleteAsync ((process , _ ) -> {
556558 if (process != null ) {
557559 this .process .set (process );
558560 }
0 commit comments