Пример #1
0
        private void serverstatusbtn_Click_1(object sender, EventArgs e)
        {
            var mail = new AllianceMailStreamEntry();

            mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
            mail.SetSenderId(0);
            mail.SetSenderAvatarId(0);
            mail.SetSenderName("System Manager");
            mail.SetIsNew(0);
            mail.SetAllianceId(0);
            mail.SetAllianceBadgeData(1728059989);
            mail.SetAllianceName("Legendary Administrator");
            mail.SetMessage("Latest Server Status:\nConnected Players:" + ResourcesManager.GetConnectedClients().Count +
                            "\nIn Memory Alliances:" + ObjectManager.GetInMemoryAlliances().Count +
                            "\nIn Memory Levels:" + ResourcesManager.GetInMemoryLevels().Count);
            mail.SetSenderLeagueId(22);
            mail.SetSenderLevel(500);

            foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
            {
                var p  = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                pm.SetChatMessage("Our current Server Status is now in your mailbox!");
                pm.SetPlayerId(0);
                pm.SetLeagueId(22);
                pm.SetPlayerName("System Manager");
                p.SetAvatarStreamEntry(mail);
                PacketManager.ProcessOutgoingPacket(p);
                PacketManager.ProcessOutgoingPacket(pm);
            }
            ConsoleWrite("Server Status Sent to Player's.");
        }
        public override async void Execute(Level level)
        {
            if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
            {
                var clanid = level.GetPlayerAvatar().GetAllianceId();
                if (clanid != 0)
                {
                    Alliance _Alliance = await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());

                    foreach (var pl in _Alliance.GetAllianceMembers())
                    {
                        if (pl.GetRole() == 2)
                        {
                            pl.SetRole(4);
                            break;
                        }
                    }
                    level.GetPlayerAvatar().SetAllianceRole(2);
                }
            }
            else
            {
                var p = new GlobalChatLineMessage(level.GetClient());
                p.SetChatMessage("GameOp command failed. Access to Admin GameOP is prohibited.");
                p.SetPlayerId(0);
                p.SetLeagueId(22);
                p.SetPlayerName("UCS Bot");
                PacketProcessor.Send(p);
            }
        }
Пример #3
0
        private void RestartServer_Click(object sender, EventArgs e)
        {
            var mail = new AllianceMailStreamEntry();

            mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
            mail.SetSenderId(0);
            mail.SetSenderAvatarId(0);
            mail.SetSenderName("System Manager");
            mail.SetIsNew(0);
            mail.SetAllianceId(0);
            mail.SetAllianceBadgeData(1728059989);
            mail.SetAllianceName("Legendary Administrator");
            mail.SetMessage("System is about to restart in a few moments.");
            mail.SetSenderLevel(500);
            mail.SetSenderLeagueId(22);
            foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
            {
                var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                var ps = new ShutdownStartedMessage(onlinePlayer.GetClient());
                var p  = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                ps.SetCode(5);
                p.SetAvatarStreamEntry(mail);
                pm.SetChatMessage("System is about to restart in a few moments.");
                pm.SetPlayerId(0);
                pm.SetLeagueId(22);
                pm.SetPlayerName("System Manager");
                PacketManager.ProcessOutgoingPacket(p);
                PacketManager.ProcessOutgoingPacket(ps);
                PacketManager.ProcessOutgoingPacket(pm);
            }
            StatusLabel.Text     = "Status : Restart";
            kServerConsole.Text += Environment.NewLine + "Message Send To Users And Server Is Restarting ...";
            Console.WriteLine("Message Send To Users And Server Is Restarting ...");
            Program.RestartProgram();
        }
Пример #4
0
 private void RMTimer_Tick(object sender, EventArgs e)
 {
     if (MessageNumber == 0)
     {
         foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
         {
             var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
             pm.SetChatMessage(RMessageText1.Text);
             pm.SetPlayerId(0);
             pm.SetLeagueId(22);
             pm.SetPlayerName(RSenderNameTextBox.Text);
             PacketManager.ProcessOutgoingPacket(pm);
         }
         MessageNumber++;
         ConsoleWrite("Auto Message System: Message One Sent.");
     }
     else if (MessageNumber == 1)
     {
         foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
         {
             var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
             pm.SetChatMessage(RMessageText2.Text);
             pm.SetPlayerId(0);
             pm.SetLeagueId(22);
             pm.SetPlayerName(RSenderNameTextBox.Text);
             PacketManager.ProcessOutgoingPacket(pm);
         }
         MessageNumber++;
         ConsoleWrite("Auto Message System: Message Two Sent.");
     }
     else if (MessageNumber == 2)
     {
         foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
         {
             var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
             pm.SetChatMessage(RMessageText3.Text);
             pm.SetPlayerId(0);
             pm.SetLeagueId(22);
             pm.SetPlayerName(RSenderNameTextBox.Text);
             PacketManager.ProcessOutgoingPacket(pm);
         }
         MessageNumber++;
         ConsoleWrite("Auto Message System: Message Three Sent.");
     }
     else if (MessageNumber == 3)
     {
         foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
         {
             var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
             pm.SetChatMessage(RMessageText4.Text);
             pm.SetPlayerId(0);
             pm.SetLeagueId(22);
             pm.SetPlayerName(RSenderNameTextBox.Text);
             PacketManager.ProcessOutgoingPacket(pm);
         }
         MessageNumber = 0;
         ConsoleWrite("Auto Message System: Message Four Sent.");
     }
 }
Пример #5
0
 private void metroButton4_Click(object sender, EventArgs e)
 {
     foreach (var onlineplayer in ResourcesManager.GetOnlinePlayers())
     {
         var p = new GlobalChatLineMessage(onlineplayer.GetClient());
         p.SetChatMessage(metroTextBox8.Text);
         p.SetPlayerId(0);
         p.SetLeagueId(22);
         p.SetPlayerName(metroTextBox7.Text);
         PacketManager.ProcessOutgoingPacket(p);
     }
 }
Пример #6
0
 private void materialRaisedButton9_Click(object sender, EventArgs e)
 {
     foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
     {
         var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
         pm.SetChatMessage(textBox21.Text);
         pm.SetPlayerId(0);
         pm.SetLeagueId(22);
         pm.SetPlayerName(textBox22.Text);
         PacketManager.ProcessOutgoingPacket(pm);
     }
 }
Пример #7
0
 public override void Execute(Level level)
 {
     if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
     {
         var l  = level.GetClient();
         var pm = new GlobalChatLineMessage(l);
         pm.SetPlayerName("System Manager");
         pm.SetLeagueId(22);
         pm.SetChatMessage("Your id: " + level.GetPlayerAvatar().GetId());
         pm.SetPlayerId(0);
         PacketManager.ProcessOutgoingPacket(pm);
     }
 }
Пример #8
0
        private void GlobalChatBtn_Click_1(object sender, EventArgs e)
        {
            var mail = new AllianceMailStreamEntry();

            foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
            {
                var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                pm.SetChatMessage(CMessageTextBox.Text);
                pm.SetPlayerId(0);
                pm.SetLeagueId(22);
                pm.SetPlayerName(MessageSenderNameTextBox.Text);
                PacketManager.ProcessOutgoingPacket(pm);
            }
        }
Пример #9
0
        public override void Execute(Level level)
        {
            if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
            {
                //Use this Command before you restart your server!

                /* Starting saving of players */
                var pm = new GlobalChatLineMessage(level.GetClient());
                pm.SetChatMessage("Starting saving process of every player!");
                pm.SetPlayerId(0);
                pm.SetLeagueId(22);
                pm.SetPlayerName("UCS Bot");
                PacketManager.ProcessOutgoingPacket(pm);
                DatabaseManager.Singelton.Save(ResourcesManager.GetInMemoryLevels());
                var p = new GlobalChatLineMessage(level.GetClient());
                /* Confirmation */
                p.SetChatMessage("All Players are saved!");
                p.SetPlayerId(0);
                p.SetLeagueId(22);
                p.SetPlayerName("UCS Bot");
                PacketManager.ProcessOutgoingPacket(p);
                /* Starting saving of Clans */
                var pmm = new GlobalChatLineMessage(level.GetClient());
                pmm.SetPlayerId(0);
                pmm.SetLeagueId(22);
                pmm.SetPlayerName("UCS Bot");
                pmm.SetChatMessage("Starting with saving of every Clan!");
                PacketManager.ProcessOutgoingPacket(pmm);
                /* Confirmation */
                DatabaseManager.Singelton.Save(ObjectManager.GetInMemoryAlliances());
                var pmp = new GlobalChatLineMessage(level.GetClient());
                pmp.SetPlayerId(0);
                pmp.SetLeagueId(22);
                pmp.SetPlayerName("UCS Bot");
                pmp.SetChatMessage("All Clans are saved!");
                PacketManager.ProcessOutgoingPacket(pmp);
            }
            else
            {
                var p = new GlobalChatLineMessage(level.GetClient());
                p.SetChatMessage("GameOp command failed. Access to Admin GameOP is prohibited.");
                p.SetPlayerId(0);
                p.SetLeagueId(22);
                p.SetPlayerName("UCS Bot");
                PacketManager.ProcessOutgoingPacket(p);
            }
        }
Пример #10
0
 public override void Execute(Level level)
 {
     if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
     {
         /* Starting saving of players */
         var pm = new GlobalChatLineMessage(level.GetClient());
         pm.SetChatMessage("Starting saving process of every player!");
         pm.SetPlayerId(0);
         pm.SetLeagueId(22);
         pm.SetPlayerName("UCS Bot");
         pm.Send();
         var levels = DatabaseManager.Instance.Save(ResourcesManager.GetInMemoryLevels());
         levels.Wait();
         var p = new GlobalChatLineMessage(level.GetClient());
         /* Confirmation */
         p.SetChatMessage("All Players are saved!");
         p.SetPlayerId(0);
         p.SetLeagueId(22);
         p.SetPlayerName("UCS Bot");
         p.Send();
         /* Starting saving of Clans */
         var pmm = new GlobalChatLineMessage(level.GetClient());
         pmm.SetPlayerId(0);
         pmm.SetLeagueId(22);
         pmm.SetPlayerName("UCS Bot");
         pmm.SetChatMessage("Starting with saving of every Clan!");
         pmm.Send();
         /* Confirmation */
         var clans = DatabaseManager.Instance.Save(ResourcesManager.GetInMemoryAlliances());
         clans.Wait();
         var pmp = new GlobalChatLineMessage(level.GetClient());
         pmp.SetPlayerId(0);
         pmp.SetLeagueId(22);
         pmp.SetPlayerName("UCS Bot");
         pmp.SetChatMessage("All Clans are saved!");
         pmp.Send();
     }
     else
     {
         var p = new GlobalChatLineMessage(level.GetClient());
         p.SetChatMessage("GameOp command failed. Access to Admin GameOP is prohibited.");
         p.SetPlayerId(0);
         p.SetLeagueId(22);
         p.SetPlayerName("UCS Bot");
         p.Send();
     }
 }
Пример #11
0
        private void materialRaisedButton20_Click(object sender, EventArgs e)
        {
            var Name     = textBox1.Text;
            int Interval = Convert.ToInt32(((textBox2.Text + 0) + 0) + 0);
            var Message  = textBox3.Text;

            if (Convert.ToInt32(Interval) < 1)
            {
                MessageBox.Show("The Interval can't be null!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                foreach (Level onlinePlayer in ResourcesManager.GetOnlinePlayers())
                {
                    var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                    pm.SetChatMessage(Message);
                    pm.SetPlayerId(0);
                    pm.SetLeagueId(22);
                    pm.SetPlayerName(Name);
                    PacketProcessor.Send(pm);
                }

                Count++;
                materialLabel13.Text = Convert.ToString(Count);

                T.Interval = Interval;
                T.Elapsed += ((s, o) =>
                {
                    foreach (Level onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        pm.SetChatMessage(Message);
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName(Name);
                        PacketProcessor.Send(pm);
                    }
                    Count++;
                    materialLabel13.Text = Convert.ToString(Count);
                });
                T.Start();
            }
        }
Пример #12
0
 public override void Execute(Level level)
 {
     if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
     {
         DatabaseManager.Singelton.Save(level);
         var p = new GlobalChatLineMessage(level.GetClient());
         p.SetChatMessage("Game Successfuly Saved!");
         p.SetPlayerId(0);
         p.SetLeagueId(22);
         p.SetPlayerName("UCS Bot");
         PacketManager.ProcessOutgoingPacket(p);
     }
     else
     {
         var p = new GlobalChatLineMessage(level.GetClient());
         p.SetChatMessage("GameOp command failed. Access to Admin GameOP is prohibited.");
         p.SetPlayerId(0);
         p.SetLeagueId(22);
         p.SetPlayerName("UCS Bot");
         PacketManager.ProcessOutgoingPacket(p);
     }
 }
Пример #13
0
        public override void Execute(Level level)
        {
            if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
            {
                DatabaseManager.Instance.Save(level);

                var p = new GlobalChatLineMessage(level.GetClient());
                p.SetChatMessage("Game Successful Saved!");
                p.SetPlayerId(0);
                p.SetLeagueId(22);
                p.SetPlayerName("CoM Bot");
                p.Send();
            }
            else
            {
                var p = new GlobalChatLineMessage(level.GetClient());
                p.SetChatMessage("GameOp command failed. Access to Admin GameOP is prohibited.");
                p.SetPlayerId(0);
                p.SetLeagueId(22);
                p.SetPlayerName("CoM Bot");
                p.Send();
            }
        }
Пример #14
0
        public override void Execute(Level level)
        {
            if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
            {
                try
                {
                    if (m_vArgs.Length >= 2)
                    {
                        var senderId   = level.GetPlayerAvatar().GetId();
                        var c          = level.GetClient();
                        var argcount   = m_vArgs.Length;
                        int currentarg = 2;
                        var msg        = "";
                        while (currentarg < m_vArgs.Length)
                        {
                            msg += m_vArgs[currentarg] + " ";
                            currentarg++;
                        }
                        var  message = msg;
                        long id      = Convert.ToInt64(m_vArgs[1]);

                        bool playerexist;
                        try
                        {
                            var l = ResourcesManager.GetPlayer(id);
                            playerexist = true;
                        }
                        catch
                        {
                            playerexist = false;
                        }
                        if (playerexist.Equals(true))
                        {
                            var l              = ResourcesManager.GetPlayer(id);
                            var sendername     = level.GetPlayerAvatar().GetAvatarName();
                            var senderalliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());
                            if (ResourcesManager.IsPlayerOnline(l))
                            {
                                var utmclient = l.GetClient();
                                var pm        = new GlobalChatLineMessage(utmclient);
                                pm.SetChatMessage(Message.FilterString(message));
                                pm.SetPlayerName(sendername + " (Private Message)");
                                pm.SetPlayerId(senderId);
                                pm.SetLeagueId(l.GetPlayerAvatar().GetLeagueId());
                                pm.SetAlliance(senderalliance);
                                PacketManager.ProcessOutgoingPacket(pm);
                                var resp = new GlobalChatLineMessage(c);
                                resp.SetChatMessage("Successfully sent Private Message to: " + l.GetPlayerAvatar().GetAvatarName() + " with the Text: " + Message.FilterString(message));
                                resp.SetPlayerId(senderId);
                                resp.SetAlliance(senderalliance);
                                resp.SetLeagueId(22);
                                PacketManager.ProcessOutgoingPacket(resp);
                            }
                            else
                            {
                                var pm = new GlobalChatLineMessage(c);
                                pm.SetChatMessage("Player is offline or not exist.");
                                pm.SetPlayerId(0);
                                pm.SetPlayerName("System Manager");
                                pm.SetLeagueId(22);
                                PacketManager.ProcessOutgoingPacket(pm);
                            }
                        }
                    }
                    else
                    {
                        var p = new GlobalChatLineMessage(level.GetClient());
                        p.SetChatMessage("Wrong usage,Please use /pm userid text\nTo get your ID use /myid. Save it or tell it to your friends.");
                        p.SetPlayerId(0);
                        p.SetLeagueId(22);
                        p.SetPlayerName("System Manager");
                    }
                }
                catch (Exception e)
                {
                    var p = new GlobalChatLineMessage(level.GetClient());
                    p.SetChatMessage("Wrong usage,Please use /pm userid text\nTo get your ID use /myid. Save it or tell it to your friends.");
                    p.SetPlayerId(0);
                    p.SetLeagueId(22);
                    p.SetPlayerName("System Manager");
                    PacketManager.ProcessOutgoingPacket(p);
                    MainWindow.RemoteWindow.WriteConsoleDebug("Exception on PM caught.: " + e, (int)MainWindow.level.DEBUGFATAL);
                }
            }
            else
            {
                SendCommandFailedMessage(level.GetClient());
            }
        }
Пример #15
0
        public static void CommandRead(string cmd)
        {
            if (cmd == null)
            {
                if (ConfUCS.IsConsoleMode)
                {
                    ManageConsole();
                }
            }
            try
            {
                switch (cmd.ToLower())
                {
                case "/help":

                    Console.WriteLine("/start                             <-- Start the server");
                    Console.WriteLine("/ban <PlayerID>                    <-- Ban a client");
                    // Console.WriteLine("/banip <PlayerID>                  <-- Ban a client by IP");
                    Console.WriteLine("/unban <PlayerID>                  <-- Unban a client");
                    // Console.WriteLine("/unbanip <PlayerID>                <-- Unban a client");
                    // Console.WriteLine("/tempban <PlayerID> <Seconds>      <-- Temporary ban a client");
                    // Console.WriteLine("/tempbanip <PlayerID> <Seconds>    <-- Temporary ban a client by IP");
                    Console.WriteLine("/kick <PlayerID>                   <-- Kick a client from the server");
                    // Console.WriteLine("/mute <PlayerID>                   <-- Mute a client");
                    // Console.WriteLine("/unmute <PlayerID>                 <-- Unmute a client");
                    // Console.WriteLine("/setlevel <PlayerID> <Level>       <-- Set a level for a player");
                    Console.WriteLine("/update                            <-- Check if update is available");
                    // Console.WriteLine("/say <Text>                        <-- Send a text to all");
                    // Console.WriteLine("/sayplayer <PlayerID> <Text>       <-- Send a text to a player");
                    Console.WriteLine("/stop  or   /shutdown              <-- Stop the server and save data");
                    Console.WriteLine("/forcestop                         <-- Force stop the server");
                    Console.WriteLine("/restart                           <-- Save data and then restart");
                    Console.WriteLine("/send sysinfo                      <-- Send server info to all players");
                    Console.WriteLine("/status                            <-- Get server status");
                    Console.WriteLine("/switch                            <-- Switch to GUI/Console mode");
                    break;

                case "/start":

                    if (!ConfUCS.IsServerOnline)
                    {
                        ConsoleThread CT = new ConsoleThread();
                        CT.Start();
                    }
                    else
                    {
                        Console.WriteLine("Server already online!");
                    }
                    break;

                case "/stop":
                case "/shutdown":

                    Console.WriteLine("Shutting down... Saving all data, wait.");

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        p.SetCode(5);
                        PacketManager.ProcessOutgoingPacket(p);
                    }

                    ConsoleManage.FreeConsole();
                    Environment.Exit(0);
                    break;

                case "/forcestop":

                    Console.WriteLine("Force shutting down... All progress not saved will be lost!");
                    Process.GetCurrentProcess().Kill();
                    break;

                case "/uptime":

                    Console.WriteLine("Up time: " + ControlTimer.ElapsedTime);
                    break;

                case "/restart":

                    Console.WriteLine("System Restarting....");

                    var mail = new AllianceMailStreamEntry();
                    mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail.SetSenderId(0);
                    mail.SetSenderAvatarId(0);
                    mail.SetSenderName("System Manager");
                    mail.SetIsNew(0);
                    mail.SetAllianceId(0);
                    mail.SetAllianceBadgeData(0);
                    mail.SetAllianceName("Legendary Administrator");
                    mail.SetMessage("System is about to restart in a few moments.");
                    mail.SetSenderLevel(500);
                    mail.SetSenderLeagueId(22);

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        var ps = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        var p  = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                        ps.SetCode(5);
                        p.SetAvatarStreamEntry(mail);
                        pm.SetChatMessage("System is about to restart in a few moments.");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        PacketManager.ProcessOutgoingPacket(p);
                        PacketManager.ProcessOutgoingPacket(ps);
                        PacketManager.ProcessOutgoingPacket(pm);
                    }
                    Console.WriteLine("Saving all data...");
                    foreach (var l in ResourcesManager.GetOnlinePlayers())
                    {
                        //DatabaseManager.Singelton.Save(l);
                    }

                    Console.WriteLine("Restarting now");

                    Process.Start(Application.ResourceAssembly.Location);
                    Process.GetCurrentProcess().Kill();
                    break;

                case "/clear":

                    Console.WriteLine("Console cleared");
                    if (ConfUCS.IsConsoleMode)
                    {
                        Console.Clear();
                    }
                    else
                    {
                        MainWindow.RemoteWindow.RTB_Console.Clear();
                    }
                    break;

                case "/status":

                    Console.WriteLine("Server IP: " + ConfUCS.GetIP() + " on port 9339");
                    Console.WriteLine("IP Address (public): " + new WebClient().DownloadString("http://bot.whatismyipaddress.com/"));
                    Console.WriteLine("Online Player: " + ResourcesManager.GetOnlinePlayers().Count);
                    Console.WriteLine("Connected Player: " + ResourcesManager.GetConnectedClients().Count);
                    Console.WriteLine("Starting Gold: " + int.Parse(ConfigurationManager.AppSettings["StartingGold"]));
                    Console.WriteLine("Starting Elixir: " +
                                      int.Parse(ConfigurationManager.AppSettings["StartingElixir"]));
                    Console.WriteLine("Starting Dark Elixir: " +
                                      int.Parse(ConfigurationManager.AppSettings["StartingDarkElixir"]));
                    Console.WriteLine("Starting Gems: " + int.Parse(ConfigurationManager.AppSettings["StartingGems"]));
                    Console.WriteLine("CoC Version: " + ConfigurationManager.AppSettings["ClientVersion"]);
                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
                    {
                        Console.WriteLine("Patch: Active");
                        Console.WriteLine("Patching Server: " + ConfigurationManager.AppSettings["patchingServer"]);
                    }
                    else
                    {
                        Console.WriteLine("Patch: Disable");
                    }
                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceMode"]))
                    {
                        Console.WriteLine("Maintance Mode: Active");
                        Console.WriteLine("Maintance time: " +
                                          Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeleft"]) +
                                          " Seconds");
                    }
                    else
                    {
                        Console.WriteLine("Maintance Mode: Disable");
                    }
                    break;

                case "/send sysinfo":

                    Console.WriteLine("Server Status is now sent to all online players");

                    var mail1 = new AllianceMailStreamEntry();
                    mail1.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail1.SetSenderId(0);
                    mail1.SetSenderAvatarId(0);
                    mail1.SetSenderName("System Manager");
                    mail1.SetIsNew(0);
                    mail1.SetAllianceId(0);
                    mail1.SetAllianceBadgeData(0);
                    mail1.SetAllianceName("Legendary Administrator");
                    mail1.SetMessage("Latest Server Status:\nConnected Players:" +
                                     ResourcesManager.GetConnectedClients().Count + "\nIn Memory Alliances:" +
                                     ObjectManager.GetInMemoryAlliances().Count + "\nIn Memory Levels:" +
                                     ResourcesManager.GetInMemoryLevels().Count);
                    mail1.SetSenderLeagueId(22);
                    mail1.SetSenderLevel(500);

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p  = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        pm.SetChatMessage("Our current Server Status is now sent at your mailbox!");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        p.SetAvatarStreamEntry(mail1);
                        PacketManager.ProcessOutgoingPacket(p);
                        PacketManager.ProcessOutgoingPacket(pm);
                    }
                    break;

                case "/update":
                    UpdateChecker.Check();
                    break;

                case "/kick":
                    var CommGet = cmd.Split(' ');
                    if (CommGet.Length >= 2)
                    {
                        try
                        {
                            var id = Convert.ToInt64(CommGet[1]);
                            var l  = ResourcesManager.GetPlayer(id);
                            if (ResourcesManager.IsPlayerOnline(l))
                            {
                                ResourcesManager.LogPlayerOut(l);
                                var p = new OutOfSyncMessage(l.GetClient());
                                PacketManager.ProcessOutgoingPacket(p);
                            }
                            else
                            {
                                Console.WriteLine("Kick failed: id " + id + " not found");
                            }
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("The given id is not a valid number");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Kick failed with error: " + ex);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Not enough arguments");
                    }
                    break;

                case "/ban":
                    var CommGet1 = cmd.Split(' ');
                    if (CommGet1.Length >= 2)
                    {
                        try
                        {
                            var id = Convert.ToInt64(CommGet1[1]);
                            var l  = ResourcesManager.GetPlayer(id);
                            if (l != null)
                            {
                                l.SetAccountStatus(99);
                                l.SetAccountPrivileges(0);
                                if (ResourcesManager.IsPlayerOnline(l))
                                {
                                    var p = new OutOfSyncMessage(l.GetClient());
                                    PacketManager.ProcessOutgoingPacket(p);
                                }
                            }
                            else
                            {
                                Console.WriteLine("Ban failed: id " + id + " not found");
                            }
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("The given id is not a valid number");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Ban failed with error: " + ex);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Not enough arguments");
                    }
                    break;

                case "/unban":
                    var CommGet2 = cmd.Split(' ');
                    if (CommGet2.Length >= 2)
                    {
                        try
                        {
                            var id = Convert.ToInt64(CommGet2[1]);
                            var l  = ResourcesManager.GetPlayer(id);
                            if (l != null)
                            {
                                l.SetAccountStatus(0);
                            }
                            else
                            {
                                Console.WriteLine("Unban failed: id " + id + " not found");
                            }
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("The given id is not a valid number");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Unban failed with error: " + ex);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Not enough arguments");
                    }
                    break;

                case "/switch":
                    if (ConfUCS.IsConsoleFirst)
                    {
                        Console.WriteLine("Sorry, you need to launch UCS in GUI mode first.");
                    }
                    else
                    {
                        if (ConfUCS.IsConsoleMode)
                        {
                            ConfUCS.IsConsoleMode = false;
                            ConsoleManage.HideConsole();
                            InterfaceThread.Start();
                            Console.WriteLine("Switched to GUI");
                            ControlTimer.SwitchTimer();
                        }
                        else
                        {
                            ConfUCS.IsConsoleMode = true;
                            ConsoleManage.ShowConsole();
                            Console.SetOut(AllocateConsole.StandardConsole);
                            MainWindow.RemoteWindow.Hide();
                            Console.Title = ConfUCS.UnivTitle;
                            Console.WriteLine("Switched to Console");
                            ControlTimer.SwitchTimer();
                            ManageConsole();
                        }
                    }
                    break;

                default:
                    Console.WriteLine("Unknown command. Type \"/help\" for a list containing all available commands.");
                    break;
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Something wrong happens...");
                //throw;
            }


            //else if (cmd.ToLower().StartsWith("/mute"))
            //{
            //    var CommGet = cmd.Split(' ');
            //    if (CommGet.Length >= 2)
            //    {
            //        try
            //        {
            //            var id = Convert.ToInt64(CommGet[1]);
            //            var l = ResourcesManager.GetPlayer(id);
            //            if (ResourcesManager.IsPlayerOnline(l))
            //            {
            //                var p = new BanChatTrigger(l.GetClient());
            //                p.SetCode(999999999);
            //                PacketManager.ProcessOutgoingPacket(p);
            //            }
            //            else
            //            {
            //                Console.WriteLineDebug("Chat Mute failed: id " + id + " not found", CoreWriter.level.DEBUGLOG);
            //            }
            //        }
            //        catch (FormatException)
            //        {
            //            Console.WriteLineDebug("The given id is not a valid number", CoreWriter.level.DEBUGFATAL);
            //        }
            //        catch (Exception ex)
            //        {
            //            Console.WriteLineDebug("Chat Mute failed with error: " + ex, CoreWriter.level.DEBUGFATAL);
            //        }
            //    }
            //    else Console.WriteLineDebug("Not enough arguments", CoreWriter.level.DEBUGFATAL);
            //}


            if (ConfUCS.IsConsoleMode)
            {
                ManageConsole();
            }
        }
Пример #16
0
        public override async void Process(Level level)
        {
            try
            {
                if (Message.Length > 0)
                {
                    if (Message.Length < 101)
                    {
                        if (Message[0] == '/')
                        {
                            if (Message == "/test")
                            {
                                PacketProcessor.Send(new HomeBattleReplayDataMessage(Client));
                            }

                            object obj = GameOpCommandFactory.Parse(Message);
                            if (obj != null)
                            {
                                string player = "";
                                if (level != null)
                                {
                                    player += " (" + level.GetPlayerAvatar().GetId() + ", " +
                                              level.GetPlayerAvatar().GetAvatarName() + ")";
                                }
                                ((GameOpCommand)obj).Execute(level);
                            }
                        }
                        else
                        {
                            long   senderId   = level.GetPlayerAvatar().GetId();
                            string senderName = level.GetPlayerAvatar().GetAvatarName();

                            bool badword = DirectoryChecker.badwords.Any(s => Message.Contains(s));

                            if (badword)
                            {
                                foreach (Level pl in ResourcesManager.GetOnlinePlayers())
                                {
                                    /*if (pl.GetPlayerAvatar().GetUserRegion() == level.GetPlayerAvatar().GetUserRegion())
                                     * {*/
                                    GlobalChatLineMessage p = new GlobalChatLineMessage(pl.GetClient());
                                    string NewMessage       = "";

                                    for (int i = 0; i < Message.Length; i++)
                                    {
                                        NewMessage += "*";
                                    }

                                    p.SetPlayerName(senderName);
                                    p.SetChatMessage(NewMessage);
                                    p.SetPlayerId(senderId);
                                    p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                                    p.SetAlliance(await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));

                                    ChatProcessor.AddMessage(p);
                                    //PacketManager.Send(p);
                                    //}
                                }
                            }
                            else
                            {
                                foreach (Level onlinePlayer in ResourcesManager.GetOnlinePlayers())
                                {
                                    /*if (onlinePlayer.GetPlayerAvatar().GetUserRegion() == level.GetPlayerAvatar().GetUserRegion())
                                     * {*/
                                    GlobalChatLineMessage p = new GlobalChatLineMessage(onlinePlayer.GetClient());
                                    p.SetPlayerName(senderName);
                                    p.SetChatMessage(Message);
                                    p.SetPlayerId(senderId);
                                    p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                                    p.SetAlliance(await ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                                    //PacketManager.Send(p);
                                    ChatProcessor.AddMessage(p);
                                    Logger.Write("Chat Message: '" + Message + "' from '" + senderName + "':'" + senderId + "'");
                                    //}
                                }
                            }
                        }
                    }
                }
            } catch (Exception) { }
        }
Пример #17
0
        private void cmdSubmutBtn_Click(object sender, EventArgs e)
        {
            dpServerConsole.SelectionStart = dpServerConsole.Text.Length;
            dpServerConsole.ScrollToCaret();
            if (EnterCmdTextBox.Text == "/clear")
            {
                dpServerConsole.Clear();
            }
            else if (EnterCmdTextBox.Text == "/restart")
            {
                var mail = new AllianceMailStreamEntry();
                mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                mail.SetSenderId(0);
                mail.SetSenderAvatarId(0);
                mail.SetSenderName("System Manager");
                mail.SetIsNew(0);
                mail.SetAllianceId(0);
                mail.SetAllianceBadgeData(1728059989);
                mail.SetAllianceName("Legendary Administrator");
                mail.SetMessage("System is about to restart in a few moments.");
                mail.SetSenderLevel(500);
                mail.SetSenderLeagueId(22);

                foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                {
                    var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                    var ps = new ShutdownStartedMessage(onlinePlayer.GetClient());
                    var p  = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                    ps.SetCode(5);
                    p.SetAvatarStreamEntry(mail);
                    pm.SetChatMessage("System is about to restart in a few moments.");
                    pm.SetPlayerId(0);
                    pm.SetLeagueId(22);
                    pm.SetPlayerName("System Manager");
                    PacketManager.ProcessOutgoingPacket(p);
                    PacketManager.ProcessOutgoingPacket(ps);
                    PacketManager.ProcessOutgoingPacket(pm);
                }
                dpServerConsole.Text += Environment.NewLine + "Message Sent To Users And Server Is Restarting ...";
                Console.WriteLine("Message Sent To Users And Server Is Restarting ...");
                Program.RestartProgram();
                StatusLabel.Text = "Status : Restart";
            }
            else if (EnterCmdTextBox.Text == "/info")
            {
                dpServerConsole.Text += Environment.NewLine + @"Created By UCS Team
                    Aidid
                    Berkan
                    Iswuefel
                    Moien007
                    Tobiti";
            }
            else if (EnterCmdTextBox.Text == "/quit")
            {
                Environment.Exit(1);
            }
            else
            {
                dpServerConsole.Text += Environment.NewLine + "unknown command = " + EnterCmdTextBox.Text +
                                        Environment.NewLine;
            }
            EnterCmdTextBox.Clear();
        }
Пример #18
0
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    var obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        var player = "";
                        if (level != null)
                        {
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " +
                                      level.GetPlayerAvatar().GetAvatarName() + ")";
                        }
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else
                {
                    if (File.Exists(@"filter.ucs"))
                    {
                        var senderId   = level.GetPlayerAvatar().GetId();
                        var senderName = level.GetPlayerAvatar().GetAvatarName();

                        var badwords = new List <string>();
                        var r        = new StreamReader(@"filter.ucs");
                        var line     = "";
                        while ((line = r.ReadLine()) != null)
                        {
                            badwords.Add(line);
                        }
                        var badword = badwords.Any(s => Message.Contains(s));

                        if (badword)
                        {
                            var p = new GlobalChatLineMessage(level.GetClient());
                            p.SetPlayerId(0);
                            p.SetPlayerName("Chat Filter System");
                            p.SetLeagueId(22);
                            p.SetChatMessage("DETECTED BAD WORD! PLEASE AVOID USING BAD WORDS!");
                            p.Send();
                            return;
                        }

                        Parallel.ForEach((ResourcesManager.GetOnlinePlayers()), (onlinePlayer, l) =>
                        {
                            var p  = new GlobalChatLineMessage(onlinePlayer.GetClient());
                            var p2 = onlinePlayer.GetPlayerAvatar().GetPremium();
                            if (onlinePlayer.GetAccountPrivileges() > 0)
                            {
                                p.SetPlayerName(senderName + " #" + senderId);
                            }
                            else
                            {
                                p.SetPlayerName(senderName);
                            }
                            p.SetChatMessage(Message);
                            p.SetPlayerId(senderId);
                            p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                            p.SetAlliance(ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                            p.Send();
                            Logger.Write("Chat Message: '" + Message + "' from '" + senderName + "':'" + senderId + "'");
                        });
                    }
                }
            }
        }
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    var cmd = (GameOpCommand)GameOpCommandFactory.Parse(Message);
                    cmd?.Execute(level);
                }
                else
                {
                    var senderId   = level.GetPlayerAvatar().GetId();
                    var senderName = level.GetPlayerAvatar().GetAvatarName();

                    if (File.Exists(@"filter.ucs"))
                    {
                        var messageLower = Message.ToLower();
                        var flagged      = false;
                        for (int i = 0; i < s_bannedWords.Length; i++)
                        {
                            if (messageLower.Contains(s_bannedWords[i]))
                            {
                                flagged = true;
                                break;
                            }
                        }

                        if (flagged)
                        {
                            var message = new GlobalChatLineMessage(level.GetClient());
                            message.SetPlayerId(0);
                            message.SetPlayerName("Chat Filter System");
                            message.SetLeagueId(22);
                            message.SetChatMessage("We've detected banned words in your chat message.");
                            message.Send();
                            return;
                        }
                    }

                    var onlinePlayers = ResourcesManager.GetOnlinePlayers();
                    for (int i = 0; i < onlinePlayers.Count; i++)
                    {
                        var player  = onlinePlayers[i];
                        var message = new GlobalChatLineMessage(player.GetClient());

                        if (player.GetAccountPrivileges() > 0)
                        {
                            message.SetPlayerName(senderName + " #" + senderId);
                        }
                        else
                        {
                            message.SetPlayerName(senderName);
                        }

                        message.SetChatMessage(Message);
                        message.SetPlayerId(senderId);
                        message.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                        message.SetAlliance(ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                        message.Send();
                    }
                }
            }
        }
        public override void Execute(Level level)
        {
            if (level.GetAccountPrivileges() >= GetRequiredAccountPrivileges())
            {
                if (m_vArgs.Length >= 2)
                {
                    try
                    {
                        long  id = Convert.ToInt64(m_vArgs[1]);
                        Level l  = ResourcesManager.GetPlayer(id);
                        if (l != null)
                        {
                            ClientAvatar acc = l.GetPlayerAvatar();
                            Message = "Player Info : \n\n" + "ID = " + id + "\nName = " + acc.GetAvatarName() + "\nCreation Date : " + acc.GetAccountCreationDate() + "\nRegion : " + acc.GetUserRegion() + "\nIP Address : " + l.GetIPAddress();
                            if (acc.GetAllianceId() != 0)
                            {
                                Message = Message + "\nClan Name : " + ObjectManager.GetAlliance(acc.GetAllianceId()).GetAllianceName();
                                switch (acc.GetAllianceRole())
                                {
                                case 1:
                                    Message = Message + "\nClan Role : Member";
                                    break;

                                case 2:
                                    Message = Message + "\nClan Role : Leader";
                                    break;

                                case 3:
                                    Message = Message + "\nClan Role : Elder";
                                    break;

                                case 4:
                                    Message = Message + "\nClan Role : Co-Leader";
                                    break;

                                default:
                                    Message = Message + "\nClan Role : Unknown";
                                    break;
                                }
                            }
                            Message = Message + "\nLevel : " + acc.GetAvatarLevel() + "\nTrophy : " + acc.GetScore() + "\nTown Hall Level : " + (acc.GetTownHallLevel() + 1) + "\nAlliance Castle Level : " + (acc.GetAllianceCastleLevel() + 1);

                            var avatar = level.GetPlayerAvatar();
                            AllianceMailStreamEntry mail = new AllianceMailStreamEntry();
                            mail.SetSenderId(avatar.GetId());
                            mail.SetSenderAvatarId(avatar.GetId());
                            mail.SetSenderName(avatar.GetAvatarName());
                            mail.SetIsNew(2);
                            mail.SetAllianceId(0);
                            mail.SetAllianceBadgeData(1526735450);
                            mail.SetAllianceName("UCS Server Information");
                            mail.SetMessage(Message);
                            mail.SetSenderLevel(avatar.GetAvatarLevel());
                            mail.SetSenderLeagueId(avatar.GetLeagueId());

                            AvatarStreamEntryMessage p = new AvatarStreamEntryMessage(level.GetClient());
                            p.SetAvatarStreamEntry(mail);
                            p.Send();
                        }
                    }
                    catch (Exception)
                    {
                        GlobalChatLineMessage c = new GlobalChatLineMessage(level.GetClient());
                        c.SetChatMessage("Command Failed, Wrong Format Or User Doesn't Exist (/accinfo id).");
                        c.SetPlayerId(level.GetPlayerAvatar().GetId());
                        c.SetLeagueId(22);
                        c.SetPlayerName("Ultrapowa Clash Server");
                        c.Send();
                        return;
                    }
                }
                else
                {
                    GlobalChatLineMessage b = new GlobalChatLineMessage(level.GetClient());
                    b.SetChatMessage("Command Failed, Wrong Format (/accinfo id).");
                    b.SetPlayerId(level.GetPlayerAvatar().GetId());
                    b.SetLeagueId(22);
                    b.SetPlayerName("Ultrapowa Clash Server");
                    b.Send();
                }
            }
        }
Пример #21
0
        public static void CommandRead(string cmd)
        {
            if (cmd == null)
            {
                if (ConfUCS.IsConsoleMode)
                {
                    ManageConsole();
                }
            }
            try
            {
                switch (cmd.ToLower())
                {
                case "/help":
                    Console.WriteLine("/start                             <-- Inicia el servidor");
                    Console.WriteLine("/ban <PlayerID>                    <-- Banear un jugador");

                    Console.WriteLine("/banip <PlayerID>                  <-- Banear un jugador mediante IP");
                    Console.WriteLine("/unban <PlayerID>                  <-- Unbanear un jugador");

                    Console.WriteLine("/unbanip <PlayerID>                <-- Unbanear un jugador");
                    Console.WriteLine("/tempban <PlayerID> <Seconds>      <-- Banea un jugador temporalmente");
                    Console.WriteLine("/tempbanip <PlayerID> <Seconds>    <-- Banea temporalmente un jugador mediante IP");
                    Console.WriteLine("/kick <PlayerID>                   <-- Expulsa un jugador del servidor");

                    Console.WriteLine("/mute <PlayerID>                   <-- Silencia a un jugador");
                    Console.WriteLine("/unmute <PlayerID>                 <-- Quita silencio a jugador");
                    Console.WriteLine("/setlevel <PlayerID> <Level>       <-- Fija un level a un jugador");
                    Console.WriteLine("/update                            <-- Comprueba si hay actualizaciónes disponibles");

                    Console.WriteLine("/say <Text>                        <-- Envia un mensaje a todos los jugadores");
                    Console.WriteLine("/sayplayer <PlayerID> <Text>       <-- Envia un mensaje al jugador especificado");
                    Console.WriteLine("/stop  or   /shutdown              <-- Detiene el servidor y guarda todos los datos");
                    Console.WriteLine("/forcestop                         <-- Fuerza el cierre del servidor !! ATENCION SE PIERDEN LOS DATOS!!");
                    Console.WriteLine("/restart                           <-- Guarda los datos y reinicia el servidor");
                    Console.WriteLine("/send sysinfo                      <-- Envia la información del servidor a los jugadores conectados");
                    Console.WriteLine("/status                            <-- Obtiene el estado el servidor");
                    Console.WriteLine("/uptime                            <-- Obtiene el tiempo activo del servidor");
                    Console.WriteLine("/switch                            <-- Cambiar modo GUI/Console");
                    Console.WriteLine("/clear                             <-- Limpia todos los mensajes de a consola");
                    break;

                case "/start":

                    if (!ConfUCS.IsServerOnline)
                    {
                        ConsoleThread CT = new ConsoleThread();
                        CT.Start();
                    }
                    else
                    {
                        Core.Debug.Write("El servidor esta activo!");
                    }
                    break;

                case "/stop":
                case "/shutdown":

                    Core.Debug.Write("Apagando servidor... Guardando datos, esperare...");

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        p.SetCode(5);
                        p.Send();
                    }

                    ConsoleManage.FreeConsole();
                    Environment.Exit(0);
                    break;

                case "/forcestop":

                    Core.Debug.Write("Terminado proceso del servidor... los ultimos datos se perderan!");
                    Process.GetCurrentProcess().Kill();
                    break;

                case "/uptime":

                    Core.Debug.Write("Tiempo servidor iniciado: " + ControlTimer.ElapsedTime);
                    break;

                case "/restart":

                    Core.Debug.Write("Reiniciando servidor....");

                    var mail = new AllianceMailStreamEntry();
                    mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail.SetSenderId(0);
                    mail.SetSenderAvatarId(0);
                    mail.SetSenderName("System Manager");
                    mail.SetIsNew(0);
                    mail.SetAllianceId(0);
                    mail.SetAllianceBadgeData(0);
                    mail.SetAllianceName("JJBreaker Administrador");
                    mail.SetMessage("El servidor se reiniciará en breve.");
                    mail.SetSenderLevel(500);
                    mail.SetSenderLeagueId(22);

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        var ps = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        var p  = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                        ps.SetCode(5);
                        p.SetAvatarStreamEntry(mail);
                        pm.SetChatMessage("El servidor se reiniciará en breve.");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        p.Send();
                        ps.Send();
                        pm.Send();
                    }
                    Console.WriteLine("Guaradndo datos...");

                    DatabaseManager.Save(ResourcesManager.GetInMemoryLevels());

                    Console.WriteLine("Restarting now");

                    Process.Start(Application.ResourceAssembly.Location);
                    Process.GetCurrentProcess().Kill();
                    break;

                case "/clear":

                    Core.Debug.Write("Consola limpiada");
                    if (ConfUCS.IsConsoleMode)
                    {
                        Console.Clear();
                    }
                    else
                    {
                        MainWindow.RemoteWindow.RTB_Console.Clear();
                    }
                    break;

                case "/status":

                    Console.WriteLine("Server IP: " + ConfUCS.GetIP() + " on port 9339");
                    Console.WriteLine("IP Address (public): "
                                      + new WebClient().DownloadString("http://bot.whatismyipaddress.com/"));
                    Console.WriteLine("Online Player: " + ResourcesManager.GetOnlinePlayers().Count);
                    Console.WriteLine("Connected Player: " + ResourcesManager.GetConnectedClients().Count);
                    Console.WriteLine("Starting Gold: " + Settings.StartingGold);
                    Console.WriteLine("Starting Gems: " + Settings.StartingGems);
                    var versionData = FingerPrint.version.Split('.');
                    Console.WriteLine("CRS Version: " + versionData[0] + "." + versionData[1] + "." + versionData[2]);
                    if (Convert.ToBoolean(Constants.Patching))
                    {
                        Console.WriteLine("Patch: Active");
                        Console.WriteLine("Patching Server: " + Constants.PatchURL);
                    }
                    else
                    {
                        Console.WriteLine("Patch: Disable");
                    }

                    if (Convert.ToBoolean(Settings.Maintenance))
                    {
                        Console.WriteLine("Maintance Mode: Active");
                        Console.WriteLine("Maintance time: " + Convert.ToInt32(Settings.MaintenanceDuration)
                                          + " Seconds");
                    }
                    else
                    {
                        Core.Debug.Write("Maintance Mode: Disable");
                    }

                    break;

                case "/send sysinfo":

                    Console.WriteLine("Server Status is now sent to all online players");

                    var mail1 = new AllianceMailStreamEntry();
                    mail1.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail1.SetSenderId(0);
                    mail1.SetSenderAvatarId(0);
                    mail1.SetSenderName("System Manager");
                    mail1.SetIsNew(0);
                    mail1.SetAllianceId(0);
                    mail1.SetAllianceBadgeData(0);
                    mail1.SetAllianceName("Legendary Administrator");
                    mail1.SetMessage("Latest Server Status:\nConnected Players:" +
                                     ResourcesManager.GetConnectedClients().Count + "\nIn Memory Alliances:" +
                                     ObjectManager.GetInMemoryAlliances().Count + "\nIn Memory Levels:" +
                                     ResourcesManager.GetInMemoryLevels().Count);
                    mail1.SetSenderLeagueId(22);
                    mail1.SetSenderLevel(500);

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p  = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        pm.SetChatMessage("Our current Server Status is now sent at your mailbox!");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        p.SetAvatarStreamEntry(mail1);
                        p.Send();
                        pm.Send();
                    }
                    break;

                case "/update":
                    UpdateChecker.Check();
                    break;

                case "/kick":
                    var CommGet = cmd.Split(' ');
                    if (CommGet.Length >= 2)
                    {
                        try
                        {
                            var id = Convert.ToInt64(CommGet[1]);
                            var l  = ResourcesManager.GetPlayer(id);
                            if (ResourcesManager.IsPlayerOnline(l))
                            {
                                ResourcesManager.LogPlayerOut(l);
                                var p = new OutOfSyncMessage(l.GetClient());
                                p.Send();
                            }
                            else
                            {
                                Console.WriteLine("Kick failed: id " + id + " not found");
                            }
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("The given id is not a valid number");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Kick failed with error: " + ex);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Not enough arguments");
                    }
                    break;

                case "/ban":
                    var CommGet1 = cmd.Split(' ');
                    if (CommGet1.Length >= 2)
                    {
                        try
                        {
                            var id = Convert.ToInt64(CommGet1[1]);
                            var l  = ResourcesManager.GetPlayer(id);
                            if (l != null)
                            {
                                l.SetAccountStatus(99);
                                l.SetAccountPrivileges(0);
                                if (ResourcesManager.IsPlayerOnline(l))
                                {
                                    new OutOfSyncMessage(l.GetClient()).Send();
                                }
                            }
                            else
                            {
                                Console.WriteLine("Ban failed: id " + id + " not found");
                            }
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("The given id is not a valid number");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Ban failed with error: " + ex);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Not enough arguments");
                    }
                    break;

                case "/unban":
                    var CommGet2 = cmd.Split(' ');
                    if (CommGet2.Length >= 2)
                    {
                        try
                        {
                            var id = Convert.ToInt64(CommGet2[1]);
                            var l  = ResourcesManager.GetPlayer(id);
                            if (l != null)
                            {
                                l.SetAccountStatus(0);
                            }
                            else
                            {
                                Core.Debug.Write("Unban failed: id " + id + " not found");
                            }
                        }
                        catch (FormatException)
                        {
                            Core.Debug.Write("The given id is not a valid number");
                        }
                        catch (Exception ex)
                        {
                            Core.Debug.Write("Unban failed with error: " + ex);
                        }
                    }
                    else
                    {
                        Core.Debug.Write("Not enough arguments");
                    }
                    break;

                case "/switch":
                    if (ConfUCS.IsConsoleFirst)
                    {
                        Core.Debug.Write("Sorry, you need to launch UCS in GUI mode first.");
                    }
                    else
                    {
                        if (ConfUCS.IsConsoleMode)
                        {
                            ConfUCS.IsConsoleMode = false;
                            ConsoleManage.HideConsole();
                            InterfaceThread.Start();
                            Core.Debug.Write("Switched to GUI");
                            ControlTimer.SwitchTimer();
                        }
                        else
                        {
                            ConfUCS.IsConsoleMode = true;
                            ConsoleManage.ShowConsole();
                            Console.SetOut(AllocateConsole.StandardConsole);
                            MainWindow.RemoteWindow.Hide();
                            Console.Title = ConfUCS.UnivTitle;
                            Core.Debug.Write("Switched to Console");
                            ControlTimer.SwitchTimer();
                            ManageConsole();
                        }
                    }

                    break;

                default:
                    Core.Debug.Write("Unknown command ( " + cmd + " ). Type \"/help\" for a list containing all available commands.");
                    break;
                }
            }
            catch (Exception)
            {
                Core.Debug.Write("Something wrong happens...");

                // throw;
            }

            // else if (cmd.ToLower().StartsWith("/mute"))
            // {
            // var CommGet = cmd.Split(' ');
            // if (CommGet.Length >= 2)
            // {
            // try
            // {
            // var id = Convert.ToInt64(CommGet[1]);
            // var l = ResourcesManager.GetPlayer(id);
            // if (ResourcesManager.IsPlayerOnline(l))
            // {
            // var p = new BanChatTrigger(l.GetClient());
            // p.SetCode(999999999);
            // PacketManager.ProcessOutgoingPacket(p);
            // }
            // else
            // {
            // Console.WriteLineDebug("Chat Mute failed: id " + id + " not found", CoreWriter.level.DEBUGLOG);
            // }
            // }
            // catch (FormatException)
            // {
            // Console.WriteLineDebug("The given id is not a valid number", CoreWriter.level.DEBUGFATAL);
            // }
            // catch (Exception ex)
            // {
            // Console.WriteLineDebug("Chat Mute failed with error: " + ex, CoreWriter.level.DEBUGFATAL);
            // }
            // }
            // else Console.WriteLineDebug("Not enough arguments", CoreWriter.level.DEBUGFATAL);
            // }

            if (ConfUCS.IsConsoleMode)
            {
                ManageConsole();
            }
        }
Пример #22
0
        public Menu()
        {
            while (true)
            {
                Console.WriteLine("");
                var line = Console.ReadLine();
                if (line == "/startx")
                {
                    //Application.Run(new UCSManager());
                }
                else if (line == "/reloadfilter")
                {
                    Console.WriteLine("Filter Has Been Reload");
                    Message.ReloadChatFilterList();
                }
                else if (line == "/shutdown")
                {
                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        p.SetCode(5);
                        PacketManager.ProcessOutgoingPacket(p);
                    }
                    Console.WriteLine("Message has been send to the user");
                }
                else if (line == "/clear")
                {
                    Console.Clear();
                }
                else if (line == "/restart")
                {
                    var mail = new AllianceMailStreamEntry();
                    mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail.SetSenderId(0);
                    mail.SetSenderAvatarId(0);
                    mail.SetSenderName("System Manager");
                    mail.SetIsNew(0);
                    mail.SetAllianceId(0);
                    mail.SetAllianceBadgeData(0);
                    mail.SetAllianceName("Legendary Administrator");
                    mail.SetMessage("System is about to restart in a few moments.");
                    mail.SetSenderLevel(500);
                    mail.SetSenderLeagueId(22);

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        var ps = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        var p  = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                        ps.SetCode(5);
                        p.SetAvatarStreamEntry(mail);
                        pm.SetChatMessage("System is about to restart in a few moments.");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        PacketManager.ProcessOutgoingPacket(p);
                        PacketManager.ProcessOutgoingPacket(ps);
                        PacketManager.ProcessOutgoingPacket(pm);
                    }
                    Console.WriteLine("System Restarting....");
                    Program.RestartProgram();
                }
                else if (line == "/update")
                {
                    var           downloadUrl = "";
                    Version       newVersion  = null;
                    var           aboutUpdate = "";
                    var           xmlUrl      = "https://www.flamewall.net/ucs/system.xml";
                    XmlTextReader reader      = null;
                    try
                    {
                        reader = new XmlTextReader(xmlUrl);
                        reader.MoveToContent();
                        var elementName = "";
                        if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "appinfo"))
                        {
                            while (reader.Read())
                            {
                                if (reader.NodeType == XmlNodeType.Element)
                                {
                                    elementName = reader.Name;
                                }
                                else
                                {
                                    if ((reader.NodeType == XmlNodeType.Text) && reader.HasValue)
                                    {
                                        switch (elementName)
                                        {
                                        case "version":
                                            newVersion = new Version(reader.Value);
                                            break;

                                        case "url":
                                            downloadUrl = reader.Value;
                                            break;

                                        case "about":
                                            aboutUpdate = reader.Value;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        if (reader != null)
                        {
                            reader.Close();
                        }
                    }
                    var applicationVersion = Assembly.GetExecutingAssembly().GetName().Version;
                    if (applicationVersion.CompareTo(newVersion) < 0)
                    {
                        var str =
                            string.Format(
                                "New version found!\nYour version: {0}.\nNewest version: {1}. \nAdded in this version: {2}. ",
                                applicationVersion, newVersion, aboutUpdate);
                        if (DialogResult.No !=
                            MessageBox.Show(str + "\nWould you like to download this update?", "Check for updates",
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                        {
                            try
                            {
                                Process.Start(downloadUrl);
                            }
                            catch
                            {
                            }
                            return;
                        }
                        ;
                    }
                    else
                    {
                        MessageBox.Show("Your version: " + applicationVersion + "  is up to date.", "Check for Updates",
                                        MessageBoxButtons.OK, MessageBoxIcon.None);
                    }
                }
                else if (line == "/status")
                {
                    var IPM = MainWindow.RemoteWindow.GetIP();
                    Console.WriteLine("Server IP : " + IPM + " on port 9339");
                    Console.WriteLine("Online Player : " + ResourcesManager.GetOnlinePlayers().Count);
                    Console.WriteLine("Connected Player : " + ResourcesManager.GetConnectedClients().Count);
                    Console.WriteLine("Starting Gold : " + int.Parse(ConfigurationManager.AppSettings["StartingGold"]));
                    Console.WriteLine("Starting Elixir : " +
                                      int.Parse(ConfigurationManager.AppSettings["StartingElixir"]));
                    Console.WriteLine("Starting Dark Elixir : " +
                                      int.Parse(ConfigurationManager.AppSettings["StartingDarkElixir"]));
                    Console.WriteLine("Starting Gems : " + int.Parse(ConfigurationManager.AppSettings["StartingGems"]));
                    Console.WriteLine("CoC Version : " + ConfigurationManager.AppSettings["ClientVersion"]);
                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
                    {
                        Console.WriteLine("Patch : Active");
                        Console.WriteLine("Patching Server : " + ConfigurationManager.AppSettings["patchingServer"]);
                    }
                    else
                    {
                        Console.WriteLine("Patch : Disable");
                    }
                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceMode"]))
                    {
                        Console.WriteLine("Maintance Mode : Active");
                        Console.WriteLine("Maintance time : " +
                                          Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeleft"]) +
                                          " Seconds");
                    }
                    else
                    {
                        Console.WriteLine("Maintance Mode : Disable");
                    }
                }
                else if (line == "/sysinfo")
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Server Status is now sent to all online players");
                    var mail = new AllianceMailStreamEntry();
                    mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail.SetSenderId(0);
                    mail.SetSenderAvatarId(0);
                    mail.SetSenderName("System Manager");
                    mail.SetIsNew(0);
                    mail.SetAllianceId(0);
                    mail.SetAllianceBadgeData(0);
                    mail.SetAllianceName("Legendary Administrator");
                    mail.SetMessage("Latest Server Status:\nConnected Players:" +
                                    ResourcesManager.GetConnectedClients().Count + "\nIn Memory Alliances:" +
                                    ObjectManager.GetInMemoryAlliances().Count + "\nIn Memory Levels:" +
                                    ResourcesManager.GetInMemoryLevels().Count);
                    mail.SetSenderLeagueId(22);
                    mail.SetSenderLevel(500);

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p  = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        pm.SetChatMessage("Our current Server Status is now sent at your mailbox!");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        p.SetAvatarStreamEntry(mail);
                        PacketManager.ProcessOutgoingPacket(p);
                        PacketManager.ProcessOutgoingPacket(pm);
                    }
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else if (line == "/help")
                {
                    Console.WriteLine("");
                    Console.WriteLine("Available commands :");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/startx - This commands start the server Gui");
                    Console.WriteLine("");
                    Console.WriteLine("/restart - This commands restart server and sending online player info about it.");
                    Console.WriteLine("");
                    Console.WriteLine("/update - This commands check for new UCS update");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine(
                        "/shutdown - This commands fully close the server with message after five minutes.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/status - This commands show informations about the server.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("/clear - Clean the emulator screen");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("/help - This commands show a list of available commands.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(
                        "/sysinfo - This command will send the current Server Status to all online players.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("/reloadfilter - This commands reload in memory filtered texts");
                    Console.ResetColor();
                }
                else
                {
                    Console.WriteLine("");
                    Console.WriteLine("Available commands :");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/startx - This commands start the server Gui");
                    Console.WriteLine("");
                    Console.WriteLine("/restart - This commands restart server and sending online player info about it.");
                    Console.WriteLine("");
                    Console.WriteLine("/update - This commands check for new UCS update");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine(
                        "/shutdown - This commands fully close the server with message after five minutes.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/status - This commands show informations about the server.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("/clear - Clean the emulator screen");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("/help - This commands show a list of available commands.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(
                        "/sysinfo - This command will send the current Server Status to all online players.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("/reloadfilter - This commands reload in memory filtered texts");
                    Console.ResetColor();
                }
            }
        }
Пример #23
0
        public override void Process(Level level)
        {
            if (Message.Length > 0)
            {
                if (Message[0] == '/')
                {
                    var obj = GameOpCommandFactory.Parse(Message);
                    if (obj != null)
                    {
                        var player = "";
                        if (level != null)
                        {
                            player += " (" + level.GetPlayerAvatar().GetId() + ", " +
                                      level.GetPlayerAvatar().GetAvatarName() + ")";
                        }
                        ((GameOpCommand)obj).Execute(level);
                    }
                }
                else
                {
                    if (File.Exists(@"filter.ucs"))
                    {
                        var senderId   = level.GetPlayerAvatar().GetId();
                        var senderName = level.GetPlayerAvatar().GetAvatarName();

                        var badwords = new List <string>();
                        var r        = new StreamReader(@"filter.ucs");
                        var line     = "";
                        while ((line = r.ReadLine()) != null)
                        {
                            badwords.Add(line);
                        }
                        var badword = badwords.Any(s => Message.Contains(s));

                        if (badword)
                        {
                            var p = new GlobalChatLineMessage(level.GetClient());
                            p.SetPlayerId(0);
                            p.SetPlayerName("UCS Chat Filter System");
                            p.SetLeagueId(22);
                            p.SetChatMessage("DETECTED BAD WORD! PLEASE AVOID USING BAD WORDS!");
                            PacketManager.ProcessOutgoingPacket(p);
                            return;
                        }

                        foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                        {
                            var p = new GlobalChatLineMessage(onlinePlayer.GetClient());
                            if (onlinePlayer.GetAccountPrivileges() > 0)
                            {
                                p.SetPlayerName(senderName + " #" + senderId);
                            }
                            else
                            {
                                p.SetPlayerName(senderName);
                            }

                            p.SetChatMessage(Message);
                            p.SetPlayerId(senderId);
                            p.SetLeagueId(level.GetPlayerAvatar().GetLeagueId());
                            p.SetAlliance(ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId()));
                            PacketManager.ProcessOutgoingPacket(p);
                        }
                    }
                    else
                    {
                        var p = new GlobalChatLineMessage(level.GetClient());
                        p.SetPlayerId(0);
                        p.SetPlayerName("UCS Chat System");
                        p.SetChatMessage(
                            "The Global Chat is currently disabled. Please try again later! For more Informations, check the Server Status!");
                        PacketManager.ProcessOutgoingPacket(p);
                    }
                }
            }
        }
Пример #24
0
        public Menu()
        {
            while (true)
            {
                Console.WriteLine("");
                string line = Console.ReadLine();
                if (line == "/shutdown")
                {
                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        p.SetCode(5);
                        PacketManager.ProcessOutgoingPacket(p);
                    }
                    Console.WriteLine("Message has been send to the user");
                }
                else if (line == "/clear")
                {
                    Console.Clear();
                }
                else if (line == "/restart")
                {
                    AllianceMailStreamEntry mail = new AllianceMailStreamEntry();
                    mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail.SetSenderId(0);
                    mail.SetSenderAvatarId(0);
                    mail.SetSenderName("System Manager");
                    mail.SetIsNew(0);
                    mail.SetAllianceId(0);
                    mail.SetAllianceBadgeData(0);
                    mail.SetAllianceName("Legendary Administrator");
                    mail.SetMessage("System is about to restart in a few moments.");
                    mail.SetSenderLevel(500);
                    mail.SetSenderLeagueId(22);

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        var ps = new ShutdownStartedMessage(onlinePlayer.GetClient());
                        var p  = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                        ps.SetCode(5);
                        p.SetAvatarStreamEntry(mail);
                        pm.SetChatMessage("System is about to restart in a few moments.");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        PacketManager.ProcessOutgoingPacket(p);
                        PacketManager.ProcessOutgoingPacket(ps);
                        PacketManager.ProcessOutgoingPacket(pm);
                    }
                    Console.WriteLine("System Restarting....");
                    System.Diagnostics.Process.Start(@"tools\ucs-restart.bat");
                }
                else if (line == "/status")
                {
                    string hostName = Dns.GetHostName();
                    string IPM      = Dns.GetHostByName(hostName).AddressList[0].ToString();
                    Console.WriteLine("Server IP : " + IPM + " on port 9339");
                    Console.WriteLine("Players Online : " + ResourcesManager.GetOnlinePlayers().Count);
                    Console.WriteLine("Starting Gold : " + Int32.Parse(ConfigurationManager.AppSettings["StartingGold"]));
                    Console.WriteLine("Starting Elixir : " + Int32.Parse(ConfigurationManager.AppSettings["StartingElixir"]));
                    Console.WriteLine("Starting Dark Elixir : " + Int32.Parse(ConfigurationManager.AppSettings["StartingDarkElixir"]));
                    Console.WriteLine("Starting Gems : " + Int32.Parse(ConfigurationManager.AppSettings["StartingGems"]));
                    Console.WriteLine("CoC Version : " + ConfigurationManager.AppSettings["ClientVersion"]);
                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
                    {
                        Console.WriteLine("Patch : Active");
                        Console.WriteLine("Patching Server : " + ConfigurationManager.AppSettings["patchingServer"]);
                    }
                    else
                    {
                        Console.WriteLine("Patch : Disable");
                    }
                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceMode"]))
                    {
                        Console.WriteLine("Maintance Mode : Active");
                        Console.WriteLine("Maintance time : " + (Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeleft"])) + " Seconds");
                    }
                    else
                    {
                        Console.WriteLine("Maintance Mode : Disable");
                    }
                }
                else if (line == "/sysinfo")
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Server Status is now sent to all online players");
                    AllianceMailStreamEntry mail = new AllianceMailStreamEntry();
                    mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail.SetSenderId(0);
                    mail.SetSenderAvatarId(0);
                    mail.SetSenderName("System Manager");
                    mail.SetIsNew(0);
                    mail.SetAllianceId(0);
                    mail.SetAllianceBadgeData(0);
                    mail.SetAllianceName("Legendary Administrator");
                    mail.SetMessage("Latest Server Status:\nConnected Players:" + ResourcesManager.GetConnectedClients().Count + "\nIn Memory Alliances:" + ObjectManager.GetInMemoryAlliances().Count + "\nIn Memory Levels:" + ResourcesManager.GetInMemoryLevels().Count);
                    mail.SetSenderLeagueId(22);
                    mail.SetSenderLevel(500);

                    foreach (var onlinePlayer in ResourcesManager.GetOnlinePlayers())
                    {
                        var p  = new AvatarStreamEntryMessage(onlinePlayer.GetClient());
                        var pm = new GlobalChatLineMessage(onlinePlayer.GetClient());
                        pm.SetChatMessage("Our current Server Status is now sent at your mailbox!");
                        pm.SetPlayerId(0);
                        pm.SetLeagueId(22);
                        pm.SetPlayerName("System Manager");
                        p.SetAvatarStreamEntry(mail);
                        PacketManager.ProcessOutgoingPacket(p);
                        PacketManager.ProcessOutgoingPacket(pm);
                    }
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else if (line == "/help")
                {
                    Console.WriteLine("");
                    Console.WriteLine("Available commands :");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/restart - This commands restart server and sending online player info about it.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("/shutdown - This commands fully close the server with message after five minutes.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/status - This commands show informations about the server.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("/clear - Clean the emulator screen");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("/help - This commands show a list of available commands.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/sysinfo - This command will send the current Server Status to all online players.");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Console.WriteLine("");
                    Console.WriteLine("Available commands :");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/restart - This commands restart server and sending online player info about it.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("/shutdown - This commands fully close the server with message after five minutes.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/status - This commands show informations about the server.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("/clear - Clean the emulator screen");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("/help - This commands show a list of available commands.");
                    Console.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("/sysinfo - This command will send the current Server Status to all online players.");
                    Console.ForegroundColor = ConsoleColor.White;
                }
            }
        }