Пример #1
0
        public static void Main(string[] args)
        {
            // Create a server on 0.0.0.0:25565
            minecraftServer = new MinecraftServer(
                new IPEndPoint(IPAddress.Any, 25565));
            minecraftServer.Settings.OnlineMode = false;
            minecraftServer.Settings.EnableEncryption = true;
            // Add a console logger
            LogProvider.RegisterProvider(new ConsoleLogWriter(LogImportance.Medium));
            LogProvider.RegisterProvider(new FileLogWriter("packetLog.txt", LogImportance.Low));
            // Add a flatland world
#if DEBUG
            // Use a fresh world each time
            if (Directory.Exists("world"))
                Directory.Delete("world", true);
#endif
            IWorldGenerator generator = new FlatlandGenerator();
            minecraftServer.AddLevel(new Level(generator, Path.Combine(Directory.GetCurrentDirectory(), "world")));
            minecraftServer.DefaultLevel.GameMode = GameMode.Creative;
            // Register the chat handler
            minecraftServer.ChatMessage += HandleOnChatMessage;
            // Start the server
            minecraftServer.Start();
            Console.WriteLine("Press 'q' key to exit.");
            while (Console.ReadKey(true).Key != ConsoleKey.Q) { }
            // Stop the server
            minecraftServer.Stop();
            minecraftServer.DefaultLevel.Save();
        }
Пример #2
0
 static void Main(string[] args)
 {
     if (Directory.Exists("world"))
         Directory.Delete("world", true);
     level = new Level(new StandardGenerator(), "world");
     level.AddWorld("region");
     level.SaveTo("world");
     var server = new MinecraftServer(level);
     server.ChatMessage += server_ChatMessage;
     server.PlayerLoggedIn += server_PlayerLoggedIn;
     server.Settings.OnlineMode = true;
     server.Start(new IPEndPoint(IPAddress.Any, 25565));
     Console.WriteLine("Press 'q' to exit");
     ConsoleKeyInfo cki;
     do cki = Console.ReadKey(true);
     while (cki.KeyChar != 'q');
     server.Stop();
 }
Пример #3
0
 static void Main(string[] args)
 {
     if (Directory.Exists("world"))
         Directory.Delete("world", true);
     level = new Level(new StandardGenerator(), "world");
     level.AddWorld("region");
     level.AddWorld("test", new FlatlandGenerator());
     level.Worlds[1].GenerateChunk(Coordinates2D.Zero);
     level.SaveTo("world");
     server = new MinecraftServer(level);
     server.ChatMessage += server_ChatMessage;
     server.Settings.OnlineMode = true;
     server.Settings.MotD = "Craft.Net Test Server";
     server.Start(new IPEndPoint(IPAddress.Any, 25565));
     Console.WriteLine("Press 'q' to exit");
     ConsoleKeyInfo cki;
     do cki = Console.ReadKey(true);
     while (cki.KeyChar != 'q');
     server.Stop();
 }
Пример #4
0
        public static void Main(string[] args)
        {
            // Create a server on 0.0.0.0:25565
            minecraftServer = new MinecraftServer(
		        new IPEndPoint(IPAddress.Any, 25565));
            minecraftServer.OnlineMode = false;
            minecraftServer.EncryptionEnabled = false;
            // Add a console logger
            minecraftServer.AddLogProvider(new ConsoleLogWriter(LogImportance.High));
            minecraftServer.AddLogProvider(new FileLogWriter("packetLog.txt", LogImportance.Low));
            // Add a flatland world
            minecraftServer.AddWorld(new World(new DebugGenerator()));
            // Register the chat handler
            minecraftServer.OnChatMessage += HandleOnChatMessage;
            // Start the server
            minecraftServer.Start();
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey(true);
            // Stop the server
            minecraftServer.Stop();
        }