Пример #1
0
        /// <summary>
        /// Starts MCForge
        /// </summary>
        public static void Start()
        {
            Logger.OnRecieveLog += OnLog;

            //TODO init all the things
            Logger.Init();
            ServerSettings.Init();
            FileUtils.Init();
            Manager.Init();
            ClassicServer = new ClassicServer();
            McServer = new MinecraftClassicServer();

            Logger.Log("Starting MCForge");

            McServer.MaxPlayers = ServerSettings.GetSettingInt("MaxPlayers");
            McServer.MotD = ServerSettings.GetSetting("MOTD");
            McServer.Name = ServerSettings.GetSetting("ServerName");
            McServer.Port = ServerSettings.GetSettingInt("Port");
            McServer.Private = !ServerSettings.GetSettingBoolean("Public");

            Logger.Log(ClassicServer.Start(McServer));
            Console.WriteLine("Testing event system..");
            System.IO.File.WriteAllLines("url.txt", new[] { ClassicServer.ServerUrl });
            if (ServerSettings.GetSettingBoolean("UsingConsole")) {
                Logger.OnRecieveLog -= OnLog;
                MCForgeConsole.Start();
            }
            else {
                //new gui stuff
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            MinecraftClassicServer model = new MinecraftClassicServer();
            model.Port = 25565;
            model.MaxPlayers = 25;
            model.Name = "Test LibMinecraft Classic Server";
            model.Private = false;

            ClassicServer server = new ClassicServer();
            server.OnPlayerConnectionChanged += new EventHandler<PlayerConnectionEventArgs>(server_OnPlayerConnectionChanged);
            Console.WriteLine(server.Start(model));

            while (true)
            {
                string input = Console.ReadLine();
                if (input.StartsWith("motd "))
                    model.MotD = input.Substring(5);
            }
        }
Пример #3
0
        /// <summary>
        /// Starts the server with the provided server model,
        /// on the specified local end point.
        /// </summary>
        /// <param name="Server">The server model to represent this server.</param>
        /// <param name="LocalEndPoint">The local end point.</param>
        /// <returns>The URL to use for connecting to this server via minecraft.net</returns>
        /// <remarks></remarks>
        public string Start(MinecraftClassicServer Server, IPEndPoint LocalEndPoint)
        {
            this.Server = Server;
            ServerSalt = "";
            Clients = new List<RemoteClient>();

            listener = new TcpListener(LocalEndPoint);
            listener.Start();

            DoHeartbeat(null);

            heartBeat = new Timer(new TimerCallback(DoHeartbeat), null, 45000, 45000); // Send heartbeat every 45 seconds
            netWorker = new Timer(new TimerCallback(DoWork), null, 0, Timeout.Infinite);

            return ServerUrl;
        }
Пример #4
0
        /// <summary>
        /// Starts the server with the provided server model.
        /// </summary>
        /// <param name="Server">The server model to represent this server.</param>
        /// <param name="WorldDirectory">The world directory.</param>
        /// <param name="WorldName">Name of the world.</param>
        /// <returns>The URL to use for connecting to this server via minecraft.net</returns>
        /// <remarks>This listens on all available network interfaces.</remarks>
        public string Start(MinecraftClassicServer Server, string WorldDirectory = "levels", string WorldName = "main")
        {
            this.Server = Server;
            ServerSalt = "";
            Clients = new List<RemoteClient>();

            IPEndPoint localEP = new IPEndPoint(IPAddress.Parse("0.0.0.0"), Server.Port); // Listen on all interfaces
            listener = new TcpListener(localEP);
            listener.Start();

            Worlds = new List<World>();
            MainLevel = WorldName;
            this.WorldDirectory = WorldDirectory;
            if (!Directory.Exists(WorldDirectory + "/"))
                Directory.CreateDirectory(WorldDirectory + "/");

            Worlds.Add(new World(MainLevel, 128, 128, 128, new Vector3(64, 128 + 2, 64)));
            try { Worlds[0].LoadFromBinary(WorldDirectory, MainLevel + ".lvl"); } catch { }

            DoHeartbeat(null);

            heartBeat = new Timer(new TimerCallback(DoHeartbeat), null, 45000, 45000); // Send heartbeat every 45 seconds
            netWorker = new Timer(new TimerCallback(DoWork), null, 0, Timeout.Infinite);

            return ServerUrl;
        }