コード例 #1
0
ファイル: SharpMCServer.cs プロジェクト: wickedlizerd/SharpMC
        public void StartServer()
        {
            if (!_initiated)
            {
                throw new Exception("Server not initated!");
            }

            ConsoleFunctions.WriteInfoLine("Enabling plugins...");
            EnablePlugins();

            Console.CancelKeyPress += ConsoleOnCancelKeyPress;

            try
            {
                new Thread(() => Globals.ServerListener.ListenForClients()).Start();
                new Thread(() => new ConsoleCommandHandler().WaitForCommand()).Start();
            }
            catch (Exception ex)
            {
                UnhandledException(this, new UnhandledExceptionEventArgs(ex, false));
            }
        }
コード例 #2
0
ファイル: Globals.cs プロジェクト: wickedlizerd/SharpMC
        public static void StopServer(string stopMsg = "Shutting down server...")
        {
            ConsoleFunctions.WriteInfoLine("Shutting down...");
            Disconnect d = new Disconnect(null);

            d.Reason = new McChatMessage("§f" + stopMsg);
            BroadcastPacket(d);
            ConsoleFunctions.WriteInfoLine("Saving all player data...");
            foreach (var player in LevelManager.GetAllPlayers())
            {
                player.SavePlayer();
            }
            OperatorLoader.SaveOperators();
            ConsoleFunctions.WriteInfoLine("Disabling plugins...");
            PluginManager.DisablePlugins();
            ConsoleFunctions.WriteInfoLine("Saving config file...");
            Config.SaveConfig();
            ConsoleFunctions.WriteInfoLine("Saving chunks...");
            LevelManager.SaveAllChunks();
            ServerListener.StopListenening();
            Environment.Exit(0);
        }
コード例 #3
0
ファイル: SharpMCServer.cs プロジェクト: wickedlizerd/SharpMC
        public SharpMcServer()
        {
            ConsoleFunctions.WriteInfoLine(string.Format("Initiating {0}", Globals.ProtocolName));

            ConsoleFunctions.WriteInfoLine("Enabling global error handling...");
            var currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += UnhandledException;

            ConsoleFunctions.WriteInfoLine("Loading settings...");
            LoadSettings();

            ConsoleFunctions.WriteInfoLine("Loading variables...");
            InitiateVariables();

            ConsoleFunctions.WriteInfoLine("Checking files and directories...");
            CheckDirectoriesAndFiles();

            ConsoleFunctions.WriteInfoLine("Loading plugins...");
            LoadPlugins();

            _initiated = true;
        }
コード例 #4
0
ファイル: SharpMCServer.cs プロジェクト: wickedlizerd/SharpMC
        private static void UnhandledException(object sender, UnhandledExceptionEventArgs args)
        {
            var e = (Exception)args.ExceptionObject;

            ConsoleFunctions.WriteErrorLine("An unhandled exception occured! Error message: " + e.Message);
        }
コード例 #5
0
 public void AddLevel(string name, Level lvl)
 {
     ConsoleFunctions.WriteInfoLine("Initiating level: " + name);
     SubLevels.Add(name, lvl);
 }