static void Commands() { string command; while (true) { command = Console.ReadLine(); if ((command.ToLower()).StartsWith("/start q".ToLower())) { string[] s = command.ToLower().Split(' '); if (s.Length != 4) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : Please enter - /start q [MatchesPerGame] [Bot Level]"); } else { try { int drawsallowed = Convert.ToInt16(s[2]); if (drawsallowed == 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : Matches Per Game cannot be 0"); } else { int BotLevel = Convert.ToInt16(s[3]); if (BotLevel < 0 || BotLevel > 3) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : Bot Level can only be between 0-3"); } else { if (AllPlayers.Count >= 1) { if (!(BotLevel == 0 && AllPlayers.Count == 1)) { endconnect(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine($"Started quick tournament: {drawsallowed.ToString()} match[es] allowed per game and Bot Level- {BotLevel.ToString()}"); Quick = true; CurrentTournament = new Tournament(); CurrentTournament.StartTournament(drawsallowed, BotLevel); break; } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : not enough players"); } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : not enough players"); } } } } catch { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : Please enter - /start q [MatchesPerGame] [Bot Level]"); } } } else if ((command.ToLower()).StartsWith("/start n".ToLower())) { try { string[] s = command.ToLower().Split(' '); if (s.Length != 3) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : Please enter - /start n [Bot Level]"); } else { int BotLevel = Convert.ToInt16(s[2]); if (BotLevel < 0 || BotLevel > 3) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : Bot Level can only be between 0-3"); } else { if (AllPlayers.Count >= 1) { if (!(BotLevel == 0 && AllPlayers.Count == 1)) { endconnect(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Started normal tournament"); Quick = false; CurrentTournament = new Tournament(); CurrentTournament.StartTournament(0, BotLevel); break; } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : not enough players"); } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : not enough players"); } } } } catch { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : Please enter - /start n [Bot Level]"); } } else if (command.ToLower().StartsWith("/kick")) { string[] s = command.ToLower().Split(' '); if (s.Length != 2) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Can not complete command : /kick [name] (spaces = underscore)"); } else { Found = false; foreach (Player p in AllPlayers) { if (p.Name.ToLower() == s[1].ToLower()) { Found = true; p.Active = false; p.Connected = false; p.Client.Close(); AllPlayers.Remove(p); AllPlayersnames.Remove(p.Name); f1.RemovePlayer(p.Name, "", ""); f1.Add(0, $"{p.Name} has been kicked"); break; } } if (Found == false) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Player not found"); } else { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Kicked " + s[1]); } } } else if (command.ToLower() == "/end".ToLower()) { Environment.Exit(0); } else if (command.ToLower() == "/start".ToLower()) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid Command - start [q/n] [number(if q)] [Bot Level]"); } else if (command.ToLower().StartsWith("/admin add")) { string[] s = command.ToLower().Split(' '); if (s.Length != 3) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid Command - /admin add [name]"); } else { if (!CheckContains(s[2])) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("User does not exist"); } else { if (admins.Contains(s[2])) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("User is already an admin"); } else { admins.Add(Names(s[2])); Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine($"{Names(s[2])} is now an admin"); log($"{s[2]} - make admin"); } } } } else if (command.ToLower().StartsWith("/admin remove")) { string[] s = command.ToLower().Split(' '); if (s.Length != 3) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid Command - /admin remove [name]"); } else { s[2] = Names(s[2]); if (admins.Contains(s[2])) { admins.Remove(s[2]); Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine($"{s[2]} is no longer an admin"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"{s[2]} is not admin"); } } } else if (command.ToLower().StartsWith("/users add")) { string[] s = command.ToLower().Split(' '); if (s.Length != 4) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid Command - /users add [username] [name]"); } else { if (DictNames.ContainsKey(s[2])) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("User already exists - name = " + DictNames[s[2]]); } else { DictNames.Add(s[2].ToLower(), Names(s[3])); Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine($"name-{Names(s[3])} username-{s[2].ToLower()} : added to user dictionary"); log($"{s[2].ToLower()}(username) {Names(s[3])}(name) - Add to dictionary"); } } } else if (command.ToLower() == "/help") { Console.ForegroundColor = ConsoleColor.Yellow; for (int i = 0; i < Lcommands.Count(); i++) { Console.WriteLine(Lcommands[i]); } } else if (command.ToLower() == "/restart") { ServerThreads[0].Abort(); ServerThreads[1].Abort(); VfourServer.Stop(); VsixServer.Stop(); Application.Restart(); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid Command"); } } while (true) { command = Console.ReadLine(); if (command.ToLower() == "/end".ToLower()) { Environment.Exit(0); } else if (command.ToLower() == "/restart") { ServerThreads[0].Abort(); ServerThreads[1].Abort(); VfourServer.Stop(); VsixServer.Stop(); Application.Restart(); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("The tournament has started so only /end or /restart command can be used"); } } }