Example #1
0
        public Gateway()
        {
            try
            {
                IPHostEntry ipHostInfo    = Dns.Resolve(Dns.GetHostName());
                IPAddress   ipAddress     = ipHostInfo.AddressList[0];
                IPEndPoint  localEndPoint = new IPEndPoint(IPAddress.Any, Convert.ToInt32(ConfigurationManager.AppSettings["ServerPort"]));
                Socket      listener      = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                listener.Bind(localEndPoint);
                listener.Listen(100);

                Say();
                Say("TCP Gateway started at " + ipAddress + ":" + localEndPoint.Port);

                UpdateTitle(true);
                while (true)
                {
                    AllDone.Reset();
                    listener.BeginAccept(AcceptCallback, listener);
                    AllDone.WaitOne();
                }
            }
            catch (Exception)
            {
                Error("Gateway failed to start. Restarting");
                Thread.Sleep(5000);
                UCSControl.UCSRestart();
            }
        }
Example #2
0
        public Gateway()
        {
            try
            {
                IPHostEntry ipHostInfo    = Dns.Resolve(Dns.GetHostName());
                IPAddress   ipAddress     = ipHostInfo.AddressList[0];
                IPEndPoint  localEndPoint = new IPEndPoint(IPAddress.Parse(ipAddress.ToString()), Convert.ToInt32(ConfigurationManager.AppSettings["ServerPort"]));
                Socket      _Socket       = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                _Socket.Bind(localEndPoint);
                _Socket.Listen(200);

                Say();
                Say("UCS has been started at " + ipAddress + ":" + localEndPoint.Port + " in " + Program._Stopwatch.ElapsedMilliseconds + " Milliseconds.");
                Program._Stopwatch.Stop();

                while (true)
                {
                    AllDone.Reset();

                    _Socket.BeginAccept(this.AcceptCallback, _Socket);

                    AllDone.WaitOne();
                }
            }
            catch (Exception)
            {
                Error("Gateway failed to start. Restarting...");
                Thread.Sleep(5000);
                UCSControl.UCSRestart();
            }
        }
Example #3
0
        public static void Main(string[] args)
        {
            Thread T = new Thread(() =>
            {
                UCSControl.WelcomeMessage();
                CheckThread.Start();
                MemoryThread.Start();
                NetworkThread.Start();
                ParserThread.Start();
            }); T.Start();

            T.Priority = ThreadPriority.Highest;
        }
Example #4
0
        public long GetMaxPlayerId()
        {
            try
            {
                const string SQL  = "SELECT coalesce(MAX(PlayerId), 0) FROM Player";
                int          Seed = -1;

                MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder()
                {
                    Server          = Utils.ParseConfigString("MysqlIPAddress"),
                    UserID          = Utils.ParseConfigString("MysqlUsername"),
                    Port            = (uint)Utils.ParseConfigInt("MysqlPort"),
                    Pooling         = false,
                    Database        = Utils.ParseConfigString("MysqlDatabase"),
                    MinimumPoolSize = 1
                };

                if (!string.IsNullOrWhiteSpace(Utils.ParseConfigString("MysqlPassword")))
                {
                    builder.Password = Utils.ParseConfigString("MysqlPassword");
                }

                Mysql = builder.ToString();

                using (MySqlConnection Conn = new MySqlConnection(Mysql))
                {
                    Conn.Open();

                    using (MySqlCommand CMD = new MySqlCommand(SQL, Conn))
                    {
                        CMD.Prepare();
                        Seed = Convert.ToInt32(CMD.ExecuteScalar());
                    }
                }

                return(Seed);
            }
            catch (Exception ex)
            {
                Say();
                Error("An exception occured when reconnecting to the MySQL Server.");
                Error("Please check your database configuration!");
                Error(ex.Message);
                Console.ReadKey();
                UCSControl.UCSRestart();
            }
            return(0);
        }
Example #5
0
        private void UCSUI_Load(object sender, EventArgs e)
        {
            labelIP.Text               = Convert.ToString(Dns.GetHostEntry(Dns.GetHostName()).AddressList[0]);
            labelPort.Text             = ConfigurationManager.AppSettings["ServerPort"];
            labelOnlinePlayers.Text    = Convert.ToString(ResourcesManager.GetOnlinePlayers().Count);
            labelConnectedPlayers.Text = Convert.ToString(ResourcesManager.GetConnectedClients().Count);
            labelMemoryPlayers.Text    = Convert.ToString(ResourcesManager.GetInMemoryLevels().Count);


            /* materialLabel14.Text = Convert.ToString(ResourcesManager.GetAllPlayerIds()) + Convert.ToString(ResourcesManager.);
             * materialLabel16.Text = Convert.ToString(ResourcesManager.GetAllPlayersFromDB()); */

            // CONFIG EDITOR
            txtStartingGems.Text       = ConfigurationManager.AppSettings["startingGems"];
            txtStartingGold.Text       = ConfigurationManager.AppSettings["startingGold"];
            txtStartingElixir.Text     = ConfigurationManager.AppSettings["startingElixir"];
            txtStartingDarkElixir.Text = ConfigurationManager.AppSettings["startingDarkElixir"];
            txtStartingTrophies.Text   = ConfigurationManager.AppSettings["startingTrophies"];
            txtStartingLevel.Text      = ConfigurationManager.AppSettings["startingLevel"];
            txtUpdateURL.Text          = ConfigurationManager.AppSettings["UpdateUrl"];
            txtUsePatch.Text           = ConfigurationManager.AppSettings["useCustomPatch"];
            txtPatchURL.Text           = ConfigurationManager.AppSettings["patchingServer"];
            txtMintenance.Text         = ConfigurationManager.AppSettings["maintenanceTimeleft"];
            txtDatabaseType.Text       = ConfigurationManager.AppSettings["databaseConnectionName"];
            txtPort.Text          = ConfigurationManager.AppSettings["ServerPort"];
            txtAdminMessage.Text  = ConfigurationManager.AppSettings["AdminMessage"];
            txtLogLevel.Text      = ConfigurationManager.AppSettings["LogLevel"];
            txtClientVersion.Text = ConfigurationManager.AppSettings["ClientVersion"];

            //PLAYER MANAGER
            txtPlayerName.Enabled    = false;
            txtPlayerScore.Enabled   = false;
            txtPlayerGems.Enabled    = false;
            txtTownHallLevel.Enabled = false;
            txtAllianceID.Enabled    = false;

            listView1.Items.Clear();
            foreach (var acc in ResourcesManager.GetOnlinePlayers())
            {
                ListViewItem item = new ListViewItem(acc.GetPlayerAvatar().GetAvatarName());
                item.SubItems.Add(Convert.ToString(acc.GetPlayerAvatar().GetId()));
                item.SubItems.Add(Convert.ToString(acc.GetPlayerAvatar().GetAvatarLevel()));
                item.SubItems.Add(Convert.ToString(acc.GetPlayerAvatar().GetScore()));
                item.SubItems.Add(Convert.ToString(acc.GetAccountPrivileges()));
                listView1.Items.Add(item);
            }
            UCSControl.UpdateGuiStatus();
        }
Example #6
0
        public long GetMaxPlayerId()
        {
            try
            {
                using (ucsdbEntities db = new ucsdbEntities(m_vConnectionString))
                    return((from ep in db.player select(long?) ep.PlayerId ?? 0).DefaultIfEmpty().Max());
            }
            catch (EntityException ex)
            {
                if (ConfigurationManager.AppSettings["databaseConnectionName"] == "mysql")
                {
                    Error("An exception occured when connecting to the MySQL Server.");
                    Error("Please check your database configuration !");
                    Error(Convert.ToString(ex));
                    Console.ReadKey();
                    Environment.Exit(0);
                }
                else
                {
                    Error("An exception occured when connecting to the SQLite database.");
                    Error("Please check your database configuration !");
                    Error(Convert.ToString(ex));
                    Console.ReadKey();
                    Environment.Exit(0);
                }
            }
            catch (MySqlException)
            {
                Say();
                Error("An exception occured when reconnecting to the MySQL Server.");
                Error("Please check your database configuration !");
                //Reason
                //Username is wrong
                //Password is wrong
                //IP Address is unauthorized

                UCSControl.UCSRestart();
            }
            catch (Exception ex)
            {
                Error("An unknown exception occured when trying to connect to the sql server.");
                Error("Please check your database configuration !");
                Error(Convert.ToString(ex));
                Console.ReadKey();
                Environment.Exit(0);
            }
            return(0);
        }
Example #7
0
        public static void Main(string[] args)
        {
            // Print welcome message.
            UCSControl.WelcomeMessage();

            // Check directories and files.
            DirectoryChecker.CheckDirectories();
            DirectoryChecker.CheckFiles();

            // Initialize our stuff.
            CSVManager.Initialize();
            ResourcesManager.Initialize();
            ObjectManager.Initialize();

            Logger.Initialize();
            ExceptionLogger.Initialize();

            WebApi.Initialize();
            Gateway.Initialize();

            // Start listening since we're done initializing.
            Gateway.Listen();

            while (true)
            {
                const int SLEEP_TIME = 5000;

                var numDisc = 0;
                var clients = ResourcesManager.GetConnectedClients();
                for (int i = 0; i < clients.Count; i++)
                {
                    var client = clients[i];
                    if (DateTime.Now > client.NextKeepAlive)
                    {
                        ResourcesManager.DropClient(client.GetSocketHandle());
                        numDisc++;
                    }
                }

                if (numDisc > 0)
                {
                    Logger.Say($"Dropped {numDisc} clients due to keep alive timeouts.");
                }

                Thread.Sleep(SLEEP_TIME);
            }
        }
        static ParserThread()
        {
            T = new Thread(() =>
            {
                while (true)
                {
                    var entry = ReadLine().ToLower();
                    switch (entry)
                    {
                    case "/help":
                        Print("------------------------------------------------------------------------------>");
                        Say("/status            - Shows the actual UCS status.");
                        Say("/clear             - Clears the console screen.");
                        Say("/gui               - Shows the UCS Graphical User Interface.");
                        Say("/restart           - Restarts UCS instantly.");
                        Say("/shutdown          - Shuts UCS down instantly.");
                        //Say("/addpremium        - Add a Premium Player.");
                        Say("/maintenance       - Begin Server Maintenance.");
                        Say("/saveall           - Saves everything to the Database");
                        Say("/dl csv            - Downloads latest CSV Files (if Fingerprint is up to Date).");
                        Say("/info              - Shows the UCS Informations.");
                        Say("/info 'command'    - More Info On a Command. Ex: /info gui");
                        Print("------------------------------------------------------------------------------>");
                        break;

                    case "/info":
                        WriteLine("------------------------------------->");
                        Say($"UCS Version:         {Constants.Version}");
                        Say($"Build:               {Constants.Build}");
                        Say($"CoC Version from SC: {VersionChecker.LatestBBVersion()}");
                        Say("");
                        Say($"©Ultrapowa 2014 - {DateTime.Now.Year}");
                        WriteLine("------------------------------------->");
                        break;

                    case "/dl csv":
                        CSVManager.DownloadLatestCSVFiles();
                        break;

                    case "/saveall":
                        ForegroundColor = ConsoleColor.Yellow;
                        WriteLine("----------------------------------------------------->");
                        Say($"Starting saving of all Players... ({ResourcesManager.m_vInMemoryLevels.Count})");
                        Resources.DatabaseManager.Save(ResourcesManager.m_vInMemoryLevels.Values.ToList()).Wait();
                        Say("Finished saving of all Players!");
                        //Say($"Starting saving of all Alliances... ({ResourcesManager.m_vInMemoryAlliances.Values.Count})");
                        //Resources.DatabaseManager.Save(ResourcesManager.m_vInMemoryAlliances.Values.ToList()).Wait();
                        //Say("Finished saving of all Alliances!");
                        ForegroundColor = ConsoleColor.Yellow;
                        WriteLine("----------------------------------------------------->");
                        ResetColor();
                        break;

                    /*case "/addpremium":
                     *  Print("------------------------------------->");
                     *  Say("Type in now the Player ID: ");
                     *  var id = ReadLine();
                     *  Print("------------------------------------->");
                     *  try
                     *  {
                     *      var l = await ResourcesManager.GetPlayer(long.Parse(id));
                     *      var avatar = l.Avatar;
                     *      var playerID = avatar.GetId();
                     *      var p = avatar.GetPremium();
                     *      Say("Set the Privileges for Player: '" + avatar.AvatarName + "' ID: '" + avatar.GetId() + "' to Premium?");
                     *      Say("Type in 'y':Yes or 'n': Cancel");
                     *      loop:
                     *      var a = ReadLine();
                     *      if (a == "y")
                     *      {
                     *          if (p == true)
                     *          {
                     *              Say("Privileges already set to 'Premium'");
                     *          }
                     *          else if (p == false)
                     *          {
                     *              ResourcesManager.GetPlayer(playerID).Avatar.SetPremium(true);
                     *              Say("Privileges set succesfully for: '" + avatar.AvatarName + "' ID: '" + avatar.GetId() + "'");
                     *              DatabaseManager.Single().Save(ResourcesManager.GetInMemoryLevels());
                     *          }
                     *      }
                     *      else if (a == "n")
                     *      {
                     *          Say("Canceled.");
                     *      }
                     *      else
                     *      {
                     *          Error("Type in 'y':Yes or 'n': Cancel");
                     *          goto loop;
                     *      }
                     *  }
                     *  catch (NullReferenceException)
                     *  {
                     *      Say("Player doesn't exists!");
                     *  }
                     *  break;*/

                    case "/info addpremium":
                        Print("------------------------------------------------------------------------------->");
                        Say("/addpremium > Adds a Premium Player, which will get more Privileges.");
                        Print("------------------------------------------------------------------------------->");
                        break;

                    case "/maintenance":
                        StartMaintenance();
                        break;

                    case "/info maintenance":
                        Print("------------------------------------------------------------------------------>");
                        Say(@"/maintenance > Enables Maintenance which will do the following:");
                        Say(@"     - All Online Users will be notified (Attacks will be disabled),");
                        Say(@"     - All new connections get a Maintenace Message at the Login. ");
                        Say(@"     - After 5min all Players will be kicked.");
                        Say(@"     - After the Maintenance Players will be able to connect again.");
                        Print("------------------------------------------------------------------------------>");
                        break;

                    case "/status":
                        Print("------------------------------------------------------->");
                        Say($"Time:                     {DateTime.Now}");
                        Say($"IP Address:               {Dns.GetHostByName(Dns.GetHostName()).AddressList[0]}");
                        Say($"Online Players:           {ResourcesManager.m_vOnlinePlayers.Count}");
                        Say($"Connected Players:        {ResourcesManager.GetConnectedClients().Count}");
                        Say(
                            $"In Memory Players:        {ResourcesManager.m_vInMemoryLevels.Values.ToList().Count}");
                        //Say($"In Memory Alliances:      {ResourcesManager.m_vInMemoryAlliances.Count}");
                        Say($"Client Version:           {ConfigurationManager.AppSettings["ClientVersion"]}");
                        Print("------------------------------------------------------->");
                        break;

                    case "/info status":
                        Print("----------------------------------------------------------------->");
                        Say(@"/status > Shows current state of server including:");
                        Say(@"     - Online Status");
                        Say(@"     - Server IP Address");
                        Say(@"     - Amount of Online Players");
                        Say(@"     - Amount of Connected Players");
                        Say(@"     - Amount of Players in Memory");
                        Say(@"     - Amount of Alliances in Memory");
                        Say(@"     - Clash of Clans Version.");
                        Print("----------------------------------------------------------------->");
                        break;

                    case "/clear":
                        Clear();
                        break;

                    case "/exit":
                        UCSControl.UCSClose();
                        break;

                    case "/info exit":
                        Print("---------------------------------------------------------------------------->");
                        Say(@"/exit > Shuts Down UCS instantly after doing the following:");
                        Say(@"     - Throws all Players an 'Client Out of Sync Message'");
                        Say(@"     - Disconnects All Players From the Server");
                        Say(@"     - Saves all Players in Database");
                        Say(@"     - Shutsdown UCS.");
                        Print("---------------------------------------------------------------------------->");
                        break;

                    case "/gui":
                        //Application.Run(new UCSUI());
                        break;

                    case "/info gui":
                        Print("------------------------------------------------------------------------------->");
                        Say(@"/gui > Starts the UCS Gui which includes many features listed here:");
                        Say(@"     - Status Controler/Manager");
                        Say(@"     - Player Editor");
                        Say(@"     - Config.UCS editor.");
                        Print("------------------------------------------------------------------------------->");
                        break;

                    case "/restart":
                        UCSControl.UCSRestart();
                        break;

                    case "/info restart":
                        Print("---------------------------------------------------------------------------->");
                        Say(@"/shutdown > Restarts UCS instantly after doing the following:");
                        Say(@"     - Throws all Players an 'Client Out of Sync Message'");
                        Say(@"     - Disconnects All Players From the Server");
                        Say(@"     - Saves all Players in Database");
                        Say(@"     - Restarts UCS.");
                        Print("---------------------------------------------------------------------------->");
                        break;

                    default:
                        Say("Unknown command, type \"/help\" for a list containing all available commands.");
                        break;
                    }
                }
            });
            T.Start();
        }
Example #9
0
 //Shutdown UCS Button
 private void materialRaisedButton12_Click(Object sender, EventArgs e)
 {
     Close();
     UCSControl.UCSClose();
 }
Example #10
0
        /* MAIN TAB */

        //Restart Button
        private void materialRaisedButton2_Click(object sender, EventArgs e)
        {
            UCSControl.UCSRestart();
        }
Example #11
0
        public static void Start()
        {
            T = new Thread(() =>
            {
                while (true)
                {
                    string entry = Console.ReadLine()?.ToLower();
                    switch (entry)
                    {
                    case "/help":
                        Print("------------------------------------------------------------------------------>");
                        Say("/status            - Shows the actual UCS status.");
                        Say("/clear             - Clears the console screen.");
                        Say("/gui               - Shows the UCS Graphical User Interface.");
                        Say("/restart           - Restarts UCS instantly.");
                        Say("/shutdown          - Shuts UCS down instantly.");
                        Say("/addpremium        - Add a Premium Player.");
                        Say("/maintenance       - Begin Server Maintenance.");
                        Say("/info 'command'    - More Info On a Command. Ex: /info gui");
                        Print("------------------------------------------------------------------------------>");
                        break;

                    case "/loadalliance":
                        Print("------------------------------------->");
                        Say("Type in now the Alliance ID: ");
                        var allianceid = ReadLine();
                        Print("------------------------------------->");
                        try
                        {
                            ObjectManager.GetAlliance(long.Parse(allianceid));
                        }
                        catch (NullReferenceException)
                        {
                            Say("Alliance doesn't exists!");
                        }
                        break;

                    case "/addpremium":
                        Print("------------------------------------->");
                        Say("Type in now the Player ID: ");
                        var id = ReadLine();
                        Print("------------------------------------->");
                        try
                        {
                            var avatar   = ResourcesManager.GetPlayer(long.Parse(id)).GetPlayerAvatar();
                            var playerID = avatar.GetId();
                            var p        = avatar.GetPremium();
                            Say("Set the Privileges for Player: '" + avatar.GetAvatarName() + "' ID: '" + avatar.GetId() + "' to Premium?");
                            Say("Type in 'y':Yes or 'n': Cancel");
                            loop:
                            var a = ReadLine();
                            if (a == "y")
                            {
                                if (p == true)
                                {
                                    Say("Privileges already set to 'Premium'");
                                }
                                else if (p == false)
                                {
                                    ResourcesManager.GetPlayer(playerID).GetPlayerAvatar().SetPremium(true);
                                    Say("Privileges set succesfully for: '" + avatar.GetAvatarName() + "' ID: '" + avatar.GetId() + "'");
                                    var levels = DatabaseManager.Single().Save(ResourcesManager.GetInMemoryLevels());
                                    levels.Wait();
                                }
                            }
                            else if (a == "n")
                            {
                                Say("Canceled.");
                            }
                            else
                            {
                                Error("Type in 'y':Yes or 'n': Cancel");
                                goto loop;
                            }
                        }
                        catch (NullReferenceException)
                        {
                            Say("Player doesn't exists!");
                        }
                        break;

                    case "/info addpremium":
                        Print("------------------------------------------------------------------------------->");
                        Say("/addpremium > Adds a Premium Player, which will get more Privileges.");
                        Print("------------------------------------------------------------------------------->");
                        break;

                    case "/maintenance":
                        StartMaintenance();
                        break;

                    case "/info maintenance":
                        Print("------------------------------------------------------------------------------>");
                        Say(@"/maintenance > Enables Maintenance which will do the following:");
                        Say(@"     - All Online Users will be notified (Attacks will be disabled),");
                        Say(@"     - All new connections get a Maintenace Message at the Login. ");
                        Say(@"     - After 5min all Players will be kicked.");
                        Say(@"     - After the Maintenance Players will be able to connect again.");
                        Print("------------------------------------------------------------------------------>");
                        break;

                    case "/status":
                        Print("------------------------------------------------------->");
                        Say("Status:                 " + "Online");
                        Say("IP Address:             " +
                            Dns.GetHostByName(Dns.GetHostName()).AddressList[0]);
                        Say("Online players:         " +
                            ResourcesManager.GetOnlinePlayers().Count);
                        Say("Connected players:      " +
                            ResourcesManager.GetConnectedClients().Count);
                        Say("In Memory Players:      " +
                            ResourcesManager.GetInMemoryLevels().Count);
                        Say("Clash Version:          " + ConfigurationManager.AppSettings["ClientVersion"]);
                        Print("------------------------------------------------------->");
                        break;

                    case "/info status":
                        Print("----------------------------------------------------------------->");
                        Say(@"/status > Shows current state of server including:");
                        Say(@"     - Online Status");
                        Say(@"     - Server IP Address");
                        Say(@"     - Amount of Online Players");
                        Say(@"     - Amount of Connected Players");
                        Say(@"     - Amount of Players in Memory");
                        Say(@"     - Clash of Clans Version.");
                        Print("----------------------------------------------------------------->");
                        break;

                    case "/clear":
                        Clear();
                        break;

                    case "/shutdown":
                        UCSControl.UCSClose();
                        break;

                    case "/info shutdown":
                        Print("---------------------------------------------------------------------------->");
                        Say(@"/shutdown > Shuts Down UCS instantly after doing the following:");
                        Say(@"     - Throws all Players an 'Client Out of Sync Message'");
                        Say(@"     - Disconnects All Players From the Server");
                        Say(@"     - Saves all Players in Database");
                        Say(@"     - Shutsdown UCS.");
                        Print("---------------------------------------------------------------------------->");
                        break;

                    case "/gui":
                        Application.Run(new UCSUI());
                        break;

                    case "/info gui":
                        Print("------------------------------------------------------------------------------->");
                        Say(@"/gui > Starts the UCS Gui which includes many features listed here:");
                        Say(@"     - Status Controler/Manager");
                        Say(@"     - Player Editor");
                        Say(@"     - Config.UCS editor.");
                        Print("------------------------------------------------------------------------------->");
                        break;

                    case "/restart":
                        UCSControl.UCSRestart();
                        break;

                    case "/info restart":
                        Print("---------------------------------------------------------------------------->");
                        Say(@"/shutdown > Restarts UCS instantly after doing the following:");
                        Say(@"     - Throws all Players an 'Client Out of Sync Message'");
                        Say(@"     - Disconnects All Players From the Server");
                        Say(@"     - Saves all Players in Database");
                        Say(@"     - Restarts UCS.");
                        Print("---------------------------------------------------------------------------->");
                        break;

                    default:
                        Say("Unknown command, type \"/help\" for a list containing all available commands.");
                        break;
                    }
                }
            }); T.Start();
            T.Priority = ThreadPriority.Normal;
        }
Example #12
0
        static ParserThread()
        {
            T = new Thread((ThreadStart)(() =>
            {
                while (true)
                {
                    string entry = Console.ReadLine().ToLower();
                    switch (entry)
                    {
                    case "/help":
                        Print("------------------------------------------------------------------------------>");
                        Say("/status            - Shows the actual UCS status.");
                        Say("/clear             - Clears the console screen.");
                        Say("/gui               - Shows the UCS Graphical User Interface.");
                        Say("/restart           - Restarts UCS instantly.");
                        Say("/shutdown          - Shuts UCS down instantly.");
                        Say("/banned            - Writes all Banned IP's into the Console.");
                        Say("/addip             - Add an IP to the Blacklist");
                        Say("/maintenance       - Begin Server Maintenance.");
                        Say("/saveall           - Saves everything in memory to the Database");
                        Say("/dl csv            - Downloads latest CSV Files (if Fingerprint is up to Date).");
                        Say("/info              - Shows the UCS Informations.");
                        Say("/info 'command'    - More Info On a Command. Ex: /info gui");
                        Print("------------------------------------------------------------------------------>");
                        break;

                    case "/info":
                        Console.WriteLine("------------------------------------->");
                        Say($"UCS Version:         {Constants.Version}");
                        Say($"Build:               {Constants.Build}");
                        Say($"LicenseID:           {Constants.LicensePlanID}");
                        Say($"CoC Version from SC: {VersionChecker.LatestCoCVersion()}");
                        Say($"Ultrapower  - {DateTime.Now.Year}");
                        Console.WriteLine("------------------------------------->");
                        break;

                    case "/dl csv":
                        CSVManager.DownloadLatestCSVFiles();
                        break;

                    case "/info dl csv":
                        Print("------------------------------------------------------------------------------>");
                        Say(@"/dl csv > Downloads COC Assets such as CSVs and if enabled:");
                        Say(@"     - Logic,");
                        Say(@"     - Sound Files ");
                        Say(@"     - SCs");
                        Print("------------------------------------------------------------------------------>");
                        break;

                    case "/banned":
                        Console.WriteLine("------------------------------------->");
                        Say("Banned IP Addresses:");
                        ConnectionBlocker.GetBannedIPs();
                        Console.WriteLine("------------------------------------->");
                        break;

                    case "/addip":
                        Console.WriteLine("------------------------------------->");
                        Console.Write("IP: ");
                        string s = Console.ReadLine();
                        ConnectionBlocker.AddNewIpToBlackList(s);
                        Console.WriteLine("------------------------------------->");
                        break;

                    case "/saveall":
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("----------------------------------------------------->");
                        Say($"Starting saving of all Players... ({ResourcesManager.m_vInMemoryLevels.Count})");
                        Resources.DatabaseManager.Save(ResourcesManager.m_vInMemoryLevels.Values.ToList()).Wait();
                        Say("Finished saving of all Players!");
                        Say($"Starting saving of all Alliances... ({ResourcesManager.GetInMemoryAlliances().Count})");
                        Resources.DatabaseManager.Save(ResourcesManager.GetInMemoryAlliances()).Wait();
                        Say("Finished saving of all Alliances!");
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("----------------------------------------------------->");
                        Console.ResetColor();
                        break;



                    case "/maintenance":
                        StartMaintenance();
                        break;

                    case "/info maintenance":
                        Print("------------------------------------------------------------------------------>");
                        Say(@"/maintenance > Enables Maintenance which will do the following:");
                        Say(@"     - All Online Users will be notified (Attacks will be disabled),");
                        Say(@"     - All new connections get a Maintenace Message at the Login. ");
                        Say(@"     - After 5min all Players will be kicked.");
                        Say(@"     - After the Maintenance Players will be able to connect again.");
                        Print("------------------------------------------------------------------------------>");
                        break;

                    case "/status":
                        Say($"Please wait retrieving Ultrapower Server status");
                        ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_PerfFormattedData_PerfOS_Processor");
                        var cpuTimes = searcher.Get()
                                       .Cast <ManagementObject>()
                                       .Select(mo => new
                        {
                            Name = mo["Name"],
                            Usage = mo["PercentProcessorTime"]
                        }
                                               )
                                       .ToList();
                        var query = cpuTimes.Where(x => x.Name.ToString() == "_Total").Select(x => x.Usage);
                        var CPUParcentage = query.SingleOrDefault();
                        Print("------------------------------------------------------->");
                        Say($"CPU Usage:                {CPUParcentage}%");
                        Say($"RAM Usage:                {Performances.GetUsedMemory()}%");
                        Say($"Time:                     {DateTime.Now}");
                        Say($"IP Address:               {Dns.GetHostByName(Dns.GetHostName()).AddressList[0]}");
                        Say($"Online Players:           {ResourcesManager.m_vOnlinePlayers.Count}");
                        Say($"Connected Players:        {ResourcesManager.GetConnectedClients().Count}");
                        Say($"In Memory Players:        {ResourcesManager.m_vInMemoryLevels.Values.ToList().Count}");
                        Say($"In Memory Alliances:      {ResourcesManager.GetInMemoryAlliances().Count}");
                        Say($"Client Version:           {ConfigurationManager.AppSettings["ClientVersion"]}");
                        Print("------------------------------------------------------->");
                        break;

                    case "/info status":
                        Print("----------------------------------------------------------------->");
                        Say(@"/status > Shows current state of server including:");
                        Say(@"     - Online Status");
                        Say(@"     - Server IP Address");
                        Say(@"     - Amount of Online Players");
                        Say(@"     - Amount of Connected Players");
                        Say(@"     - Amount of Players in Memory");
                        Say(@"     - Amount of Alliances in Memory");
                        Say(@"     - Clash of Clans Version.");
                        Print("----------------------------------------------------------------->");
                        break;

                    case "/clear":
                        Clear();
                        break;

                    case "/info shutdown":
                        Print("---------------------------------------------------------------------------->");
                        Say(@"/shutdown > Shuts Down UCS instantly after doing the following:");
                        Say(@"     - Throws all Players an 'Client Out of Sync Message'");
                        Say(@"     - Disconnects All Players From the Server");
                        Say(@"     - Saves all Players in Database");
                        Say(@"     - Shutsdown UCS.");
                        Print("---------------------------------------------------------------------------->");
                        break;

                    case "/gui":
                        Application.Run(new UCSUI());
                        break;

                    case "/info gui":
                        Print("------------------------------------------------------------------------------->");
                        Say(@"/gui > Starts the UCS Gui which includes many features listed here:");
                        Say(@"     - Status Controler/Manager");
                        Say(@"     - Player Editor");
                        Say(@"     - Config.UCS editor.");
                        Print("------------------------------------------------------------------------------->");
                        break;

                    case "/restart":
                        UCSControl.UCSRestart();
                        break;

                    case "/shutdown":
                        UCSControl.UCSClose();
                        break;

                    case "/info restart":
                        Print("---------------------------------------------------------------------------->");
                        Say(@"/restart > Restarts UCS instantly after doing the following:");
                        Say(@"     - Throws all Players an 'Client Out of Sync Message'");
                        Say(@"     - Disconnects All Players From the Server");
                        Say(@"     - Saves all Players in Database");
                        Say(@"     - Restarts UCS.");
                        Print("---------------------------------------------------------------------------->");
                        break;

                    default:
                        Say("Unknown command, type \"/help\" for a list containing all available commands.");
                        break;
                    }
                }
            }));
            T.Start();
        }