Class ExistingServer
- Namespace
- McServerLauncher.Services
- Assembly
- McServerLauncher.dll
Turns a folder that already holds a server into one the app manages, without touching it.
public static class ExistingServer
- Inheritance
-
ExistingServer
- Inherited Members
Remarks
This is what took the place of the old "Add" button: the create dialog's "use a folder that already exists". What the folder says wins over what the form says — the type and version it was detected as are shown locked — and the form fills in only what could not be told from the files.
Nothing here writes to the folder, with one deliberate exception in
ApplyPort(string, int?, int): no download, no installer, no eula.txt, no run.bat. A
server someone already has is theirs, and "add it to the app" must never turn into "reinstall it
over itself".
Methods
ApplyPort(string, int?, int)
Writes the port into server.properties if, and only if, it is not what the folder already says.
public static bool ApplyPort(string folder, int? detectedPort, int chosenPort)
Parameters
Returns
- bool
Whether anything was written.
Remarks
The one thing the dialog ever writes into an existing server, and only because otherwise the port it shows would be a lie: the server reads its port from that file, not from the app. Only that key is touched; the rest of the file, its comments and its order stay as they were.
Problem(ExistingServerForm, ServerDetection, IEnumerable<string>)
Why this cannot be added, as a resx key; null when it can.
public static string? Problem(ExistingServerForm form, ServerDetection found, IEnumerable<string> registeredFolders)
Parameters
formExistingServerFormfoundServerDetectionregisteredFoldersIEnumerable<string>
Returns
SameFolder(string, string)
Whether two paths name the same folder, however they were typed.
public static bool SameFolder(string a, string b)
Parameters
Returns
ToConfig(ExistingServerForm, ServerDetection)
The config for the app to manage, from what was found and what was chosen.
public static ServerConfig ToConfig(ExistingServerForm form, ServerDetection found)
Parameters
formExistingServerFormfoundServerDetection