Пример #1
0
 /// <summary>
 /// Handle the Package data.
 /// </summary>
 /// <param name="p">Package data.</param>
 /// <param name="Player">Player.</param>
 public void Handle(Package p, Player Player = null)
 {
     // Start from the most inner depth Command.
     #region /Update
     if (this.MatchRequiredParam(p,  Functions.CommandParamType.Nothing))
     {
         if (Player != null && this.MatchRequiredPermission(Player))
         {
             using (Updater Updater = new Updater())
             {
                 Updater.Update();
             }
         }
         else if (Player == null)
         {
             using (Updater Updater = new Updater())
             {
                 Updater.Update();
             }
         }
     }
     #endregion /Update
 }
Пример #2
0
        /// <summary>
        /// Server Main Entry Point - Initialize as many things as possible here.
        /// Order is important here, any additional initialization should be place at the bottom.
        /// </summary>
        /// <param name="Directory">Start Directory.</param>
        public static void Start(string Directory)
        {
            try
            {
                // Initialize Setting
                Setting = new Setting(Directory);

                // Initialize Logger.
                Logger = new LoggerCollection();
                Logger.Start();

                if (Setting.Load())
                {
                    Setting.Save();
                }
                else
                {
                    Setting.Save();
                    Environment.Exit(0);
                    return;
                }

                // Initialize Updater
                if (Setting.CheckForUpdate)
                {
                    Updater = new Updater();
                    Updater.Update();
                }

                if (Setting.MainEntryPoint == Setting.MainEntryPointType.jianmingyong_Server)
                {
                    // Initialize Listener.
                    Listener = new Server_Client_Listener.Servers.Listener();
                    Listener.Start();

                    // Initialize RCONListener.
                    if (Setting.RCONEnable)
                    {
                        RCONListener = new RCON_Client_Listener.Servers.Listener();
                        RCONListener.Start();
                    }

                    // Initialize SCONListener.
                    if (Setting.SCONEnable)
                    {
                        SCONListener = new SCON_Client_Listener.Servers.ModuleSCON();
                        SCONListener.Start();
                        //Logger.Log("SCON have been disabled due to incompatible update. Sorry for the inconvience caused.", Server_Client_Listener.Loggers.Logger.LogTypes.Info);
                    }

                    // Initialize Nancy.
                    if (Setting.NancyEnable)
                    {
                        var dataApi = new NancyData();
                        dataApi.Add("online", GetOnlineClients);

                        NancyImpl.SetDataApi(dataApi);
                        NancyImpl.Start(Setting.NancyHost, Setting.NancyPort);
                    }
                }

                // Initialize Command.
                Command = new CommandCollection();
                Command.AddCommand();
            }
            catch (Exception ex)
            {
                ex.CatchError();
            }
        }