Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("#############################");
            Console.WriteLine("#       SharpMC 1.0.0       #");
            Console.WriteLine("#       Minecraft 1.8       #");
            Console.WriteLine("#     Written by Kennyvv    #");
            Console.WriteLine("#############################");
            ConsoleFunctions.WriteServerLine("Loading important stuf...");

            #region WorldGeneration

            /*
             * We need to have some nice world generation shit here.
             * I have to implement this tho... ;(
             */
            Globals.Generator.GenerateChunk(new Vector2(0, 0));
            #endregion

            ConsoleFunctions.WriteServerLine("Preparing server for connections...");
            Thread serverThread = new Thread(() => new Server().ListenForClients());
            serverThread.Start();
            Globals.updateTitle();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 public void AddLevel(string name, Level lvl)
 {
     ConsoleFunctions.WriteInfoLine("Initiating level: " + name);
     SubLevels.Add(name, lvl);
 }
Esempio n. 4
0
        private static void UnhandledException(object sender, UnhandledExceptionEventArgs args)
        {
            var e = (Exception)args.ExceptionObject;

            ConsoleFunctions.WriteErrorLine("An unhandled exception occured! Error message: " + e.Message);
        }