public static bool StartHandleConfigs(string[] args) { Boolean hasServerToStart = false; if (args.Length > 0) { configKey = args[0]; hasServerToStart = true; multiMode = true; multiadminConfig = new MultiAdmin.Config(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "servers" + Path.DirectorySeparatorChar + configKey + Path.DirectorySeparatorChar + "config.txt"); Write("Starting this instance with config directory:" + configKey, ConsoleColor.DarkYellow); // chain the rest string[] newArgs = args.Skip(1).Take(args.Length - 1).ToArray(); configChain = "\"" + string.Join("\" \"", newArgs).Trim() + "\""; } else { // The first check sees if the "servers" directory exists, and if it does, // the second check will see if it is empty. if (Directory.Exists(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "servers") && HasSubdirs(Directory.GetDirectories(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "servers"))) { Write("Using multiple server mode", ConsoleColor.Green); multiMode = true; hasServerToStart = LoadserverFolders(); } else { // Either there is no "servers" folder or it is empty, and starting a normal server multiMode = false; hasServerToStart = true; Write("Using default server mode", ConsoleColor.Green); Write("Server directory not found or it is empty, if you want to use multiple server mode, please make a new directory in the following format:", ConsoleColor.Yellow); Write(Directory.GetCurrentDirectory() + "\\servers\\<Server id>\\config.txt", ConsoleColor.Yellow); } } if (!hasServerToStart) { Write("All servers are set to manual start! you should have at least one config that auto starts", ConsoleColor.Red); } return(hasServerToStart); }
public static bool LoadserverFolders() { bool hasServerToStart = false; bool first = true; String[] dirs = Directory.GetDirectories(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "servers" + Path.DirectorySeparatorChar); foreach (string file in dirs) { String name = new DirectoryInfo(file).Name; if (first) { multiadminConfig = new MultiAdmin.Config(file + Path.DirectorySeparatorChar + "config.txt"); Program.Write(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "servers" + Path.DirectorySeparatorChar + name + Path.DirectorySeparatorChar + "config.txt"); if (multiadminConfig.GetBoolean("MANUAL_START", false)) { Write("Skipping auto start for: " + name, ConsoleColor.DarkYellow); } else { hasServerToStart = true; configKey = name; Write("Starting this instance with config directory: " + name, ConsoleColor.DarkYellow); first = false; } } else { var other_config = new MultiAdmin.Config(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "servers" + Path.DirectorySeparatorChar + name + Path.DirectorySeparatorChar + "config.txt"); Write(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "servers" + Path.DirectorySeparatorChar + name + Path.DirectorySeparatorChar + "config.txt"); if (other_config.GetBoolean("MANUAL_START", false)) { Write("Skipping auto start for: " + name, ConsoleColor.DarkYellow); } else { configChain += "\"" + name + "\" "; } } } return(hasServerToStart); }
public static void Main(string[] args) { AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnExit); FixTypo(); multiadminConfig = new MultiAdmin.Config("scp_multiadmin.cfg"); if (!FindConfig()) { Console.ReadKey(); return; } configChain = ""; if (StartHandleConfigs(args)) { server = new Server(GetServerDirectory(), configKey, multiadminConfig, configLocation, configChain, multiMode); } else { Console.ReadKey(); } }