public static void Main(string[] args) { var currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += UnhandledException; Console.Title = Globals.ProtocolName; Config.ConfigFile = "server.properties"; Config.InitialValue = new[] { "#DO NOT REMOVE THIS LINE - SharpMC Config", "Port=25565", "MaxPlayers=10", "LevelType=standard", "WorldName=world", "Debug=false", "Seed=", "Motd=" }; Config.Check(); Console.CancelKeyPress += delegate { ConsoleFunctions.WriteInfoLine("Shutting down..."); Disconnect.Broadcast("§fServer shutting down..."); ConsoleFunctions.WriteInfoLine("Disabling plugins..."); Globals.PluginManager.DisablePlugins(); ConsoleFunctions.WriteInfoLine("Saving chunks..."); Globals.LevelManager.MainLevel.SaveChunks(); }; ConsoleFunctions.WriteInfoLine("Loading config file..."); Globals.MaxPlayers = Config.GetProperty("MaxPlayers", 10); var lvltype = Config.GetProperty("LevelType", "Experimental"); Level lvl; switch (lvltype.ToLower()) { case "flatland": lvl = new FlatLandLevel(Config.GetProperty("WorldName", "world")); break; case "standard": lvl = new StandardLevel(Config.GetProperty("WorldName", "world")); //lvl = new BetterLevel(Config.GetProperty("worldname", "world")); break; case "anvil": lvl = new AnvilLevel(Config.GetProperty("WorldName", "world")); break; default: lvl = new StandardLevel(Config.GetProperty("WorldName", "world")); break; } Globals.LevelManager = new LevelManager(lvl); Globals.LevelManager.AddLevel("nether", new NetherLevel("nether")); //Initiate the 'nether' Globals.Seed = Config.GetProperty("Seed", "SharpieCraft"); Globals.Motd = Config.GetProperty("motd", ""); Globals.Debug = Config.GetProperty("debug", false); ConsoleFunctions.WriteInfoLine("Checking files..."); if (!Directory.Exists(Globals.LevelManager.MainLevel.LvlName)) { Directory.CreateDirectory(Globals.LevelManager.MainLevel.LvlName); } ConsoleFunctions.WriteInfoLine("Setting up some variables..."); Globals.ServerKey = PacketCryptography.GenerateKeyPair(); Globals.Rand = new Random(); #if DEBUG Globals.Debug = true; #else Globals.Debug = false; #endif ConsoleFunctions.WriteInfoLine("Loading plugins..."); Globals.PluginManager = new PluginManager(); Globals.PluginManager.LoadPlugins(); ConsoleFunctions.WriteInfoLine("Enabling plugins..."); Globals.PluginManager.EnablePlugins(Globals.LevelManager); new Thread(() => new BasicListener().ListenForClients()).Start(); }