Table of Contents

Class StartPreflight

Namespace
McServerLauncher.ViewModels
Assembly
McServerLauncher.dll

Everything that is checked, and offered to fix, before a server's JVM is launched: that the port is free, that the path is one the server accepts, that its mods have what they need, and that the Java is the one its version requires.

public sealed class StartPreflight
Inheritance
StartPreflight
Inherited Members

Remarks

Each check either lets the start go ahead or says why not in the console, and the ones that ask a question never ask during an unattended start (an auto-restart after a crash, a wake on demand): a modal nobody is there to answer would leave the server down, which is precisely what those features exist to prevent.

It was part of ServerViewModel, three hundred lines of it. The view model still decides the order the checks run in, and what to do when one refuses; this class only knows how to perform each.

Constructors

StartPreflight(ServerConfig, PreflightHost, JavaService, PortService, ServerPropertiesService)

public StartPreflight(ServerConfig config, PreflightHost host, JavaService java, PortService ports, ServerPropertiesService properties)

Parameters

config ServerConfig
host PreflightHost
java JavaService
ports PortService
properties ServerPropertiesService

Methods

CheckContentDependenciesAsync(bool)

Checks that every installed mod and plugin has what it needs, and asks what to do if not.

public Task<bool> CheckContentDependenciesAsync(bool isAutoRestart)

Parameters

isAutoRestart bool

Returns

Task<bool>

Remarks

Read from the jars, so it costs a handful of zip opens and no network at all. That is not only about speed: the store calls that could answer this swallow every error and return nothing, so a check built on them would report "all good" whenever the connection was down, on the one screen where being wrong means the server does not come up.

Never blocks an automatic start. An auto-restart after a crash and a wake-on-demand both happen with nobody in front of the app, and a modal waiting for an answer would leave the server down until somebody came back — which is precisely what those two features exist to prevent. Same guard the other two pre-flight dialogs use.

Returns true when the start should go ahead.

EnsureCompatibleJavaAsync()

Checks that the configured Java works for this server's version (read from the jar). If not, installs/uses the correct Java and saves it in the config.

public Task EnsureCompatibleJavaAsync()

Returns

Task

PortIsFreeAsync(bool)

Whether the server's port is free to start on, offering to close whatever holds it.

public Task<bool> PortIsFreeAsync(bool isAutoRestart)

Parameters

isAutoRestart bool

Returns

Task<bool>

Remarks

Skipped during an unattended auto-restart: nobody would be there to answer the confirmation dialog, so a busy port is reported and the start is given up.

TryFixRejectedPathAsync(bool)

Stops a start that would fail on the path, offering to rename the folder when it can.

public Task<bool> TryFixRejectedPathAsync(bool isAutoRestart)

Parameters

isAutoRestart bool

Returns

Task<bool>

Remarks

Renaming is offered only when the offending character is in the server's own folder name. When it sits in a parent, renaming that folder would move everything else under it as well, which is not the app's to decide — so it says which character and where, and stops.

Skipped during an unattended auto-restart for the same reason the busy-port check is: there is nobody there to answer a dialog.