示例#1
0
        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
        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
        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
 public void AddLevel(string name, Level lvl)
 {
     ConsoleFunctions.WriteInfoLine("Initiating level: " + name);
     SubLevels.Add(name, lvl);
 }