Don't forget server.properties

This commit is contained in:
UnknownShadow200 2025-03-07 21:46:25 +11:00
parent ec10970dbd
commit 1e4f389eed
3 changed files with 7 additions and 10 deletions

View File

@ -93,14 +93,6 @@ namespace MCGalaxy
} }
} }
public static void SerialiseSimple(ConfigElement[] elements, string path, object instance) {
using (StreamWriter w = FileIO.CreateGuarded(path))
{
w.WriteLine("#Settings file");
SerialiseElements(elements, w, instance);
}
}
public static void SerialiseElements(ConfigElement[] elements, TextWriter w, object instance) { public static void SerialiseElements(ConfigElement[] elements, TextWriter w, object instance) {
foreach (ConfigElement elem in elements) foreach (ConfigElement elem in elements)
{ {

View File

@ -38,7 +38,12 @@ namespace MCGalaxy.Games
protected void SaveTo(ConfigElement[] cfg, string propsDir, string map) { protected void SaveTo(ConfigElement[] cfg, string propsDir, string map) {
string path = propsDir + map + ".properties"; string path = propsDir + map + ".properties";
if (!Directory.Exists(propsDir)) Directory.CreateDirectory(propsDir); if (!Directory.Exists(propsDir)) Directory.CreateDirectory(propsDir);
ConfigElement.SerialiseSimple(cfg, path, this);
using (StreamWriter w = FileIO.CreateGuarded(path))
{
w.WriteLine("#Game settings file");
ConfigElement.SerialiseElements(cfg, w, this);
}
} }
/// <summary> Saves this configuration to disc. </summary> /// <summary> Saves this configuration to disc. </summary>

View File

@ -121,7 +121,7 @@ namespace MCGalaxy
public static void Save() { public static void Save() {
try { try {
lock (saveLock) { lock (saveLock) {
using (StreamWriter w = new StreamWriter(Paths.ServerPropsFile)) using (StreamWriter w = FileIO.CreateGuarded(Paths.ServerPropsFile))
SaveProps(w); SaveProps(w);
} }
} catch (Exception ex) { } catch (Exception ex) {