Example #1
0
        static void Main(string[] args)
        {
            int port = 0;
            if (args.Length == 2)
                port = int.Parse(args[1]);
            string level = args[0];
            if (!Path.IsPathRooted(level))
            {
                level = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                     ".minecraft", "saves", level);
            }
            if (!level.EndsWith(".dat"))
                level = Path.Combine(level, "level.dat");

            ExitReset = new AutoResetEvent(false);

            server = new LocalServer(new IPEndPoint(IPAddress.Loopback, port));
            server.RegisterPluginChannel(new LanPluginChannel());
            server.RegisterPluginChannel(new ExitPluginChannel());
            server.AddLevel(new Level(new FlatlandGenerator(), Path.GetDirectoryName(level))); // TODO: Vanilla generator
            server.PlayerLoggedIn += ServerOnPlayerLoggedIn;
            server.PlayerLoggedOut += ServerOnPlayerLoggedOut; 
            server.Settings.OnlineMode = false;
            server.Start();
            Console.WriteLine(((IPEndPoint)server.Listener.Server.LocalEndPoint).Port);

            ExitReset.WaitOne();
            server.DefaultLevel.Save();
            server.StopLocalServer();
            server.Stop();
        }
Example #2
0
        static void Main(string[] args)
        {
            int port = 0;

            if (args.Length == 2)
            {
                port = int.Parse(args[1]);
            }
            string level = args[0];

            if (!Path.IsPathRooted(level))
            {
                level = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                     ".minecraft", "saves", level);
            }
            if (!level.EndsWith(".dat"))
            {
                level = Path.Combine(level, "level.dat");
            }

            ExitReset = new AutoResetEvent(false);

            server = new LocalServer(new IPEndPoint(IPAddress.Loopback, port));
            server.RegisterPluginChannel(new LanPluginChannel());
            server.RegisterPluginChannel(new ExitPluginChannel());
            server.AddLevel(new Level(new FlatlandGenerator(), Path.GetDirectoryName(level))); // TODO: Vanilla generator
            server.PlayerLoggedIn     += ServerOnPlayerLoggedIn;
            server.PlayerLoggedOut    += ServerOnPlayerLoggedOut;
            server.Settings.OnlineMode = false;
            server.Start();
            Console.WriteLine(((IPEndPoint)server.Listener.Server.LocalEndPoint).Port);

            ExitReset.WaitOne();
            server.DefaultLevel.Save();
            server.StopLocalServer();
            server.Stop();
        }
 public override void ChannelRegistered(MinecraftServer server)
 {
     this.server = (LocalServer)server;
 }
Example #4
0
 public override void ChannelRegistered(MinecraftServer server)
 {
     this.server = (LocalServer)server;
 }