public void AlterServerPropertiesFile() { var propertiesPath = Path.Combine(Options.ServerName, "server.properties"); var properties = new MinecraftServerProperties(propertiesPath); if (!properties.ContainsKey("motd") || (properties.ContainsKey("motd") && properties["motd"] == "A Minecraft Server")) { properties["motd"] = string.Format("Welcome to {0}\\!", Options.ServerName); } else if (properties.ContainsKey("level-name")) { properties["motd"] = properties["motd"].Replace(properties["level-name"], Options.ServerName); } properties["level-name"] = Options.ServerName; if (!string.IsNullOrWhiteSpace(Options.ServerSeed)) { properties["level-seed"] = Options.ServerSeed; } properties.WriteToFile(propertiesPath); }
void CheckOptions() { if (!string.IsNullOrEmpty(Options.ServerPropertiesSource)) { ScheduleBackup(Path.Combine(Options.ServerPropertiesSource, "server.properties"), Options.ServerName); } if (!string.IsNullOrEmpty(Options.WhitelistSource)) { ScheduleBackup(Path.Combine(Options.WhitelistSource, "whitelist.json"), Options.ServerName); } if (!string.IsNullOrEmpty(Options.BanlistSource)) { ScheduleBackup(Path.Combine(Options.BanlistSource, "banned-ips.json"), Options.ServerName); ScheduleBackup(Path.Combine(Options.BanlistSource, "banned-players.json"), Options.ServerName); } if (!string.IsNullOrEmpty(Options.UsercacheSource)) { ScheduleBackup(Path.Combine(Options.UsercacheSource, "usercache.json"), Options.ServerName); } if (!string.IsNullOrEmpty(Options.OperatorsSource)) { ScheduleBackup(Path.Combine(Options.OperatorsSource, "ops.json"), Options.ServerName); } if (!string.IsNullOrEmpty(Options.MapDataSource)) { var levelName = "world"; var sourceProps = new MinecraftServerProperties(Path.Combine(Options.MapDataSource, "server.properties")); if (sourceProps.ContainsKey("level-name")) { levelName = sourceProps["level-name"]; } ScheduleDirectoryBackup(Path.Combine(Options.MapDataSource, levelName), Path.Combine(Options.ServerName, Options.ServerName)); } }