예제 #1
0
        static void Main(string[] args) {
            var MinecraftServer = new MinecraftClient(args[0], int.Parse(args[1]), "USERNAME HERE", "PASSWORD HERE", true);
            MinecraftServer.ServerState = 2;

            MinecraftServer.Message += (sender, message, name) => {
                Console.WriteLine("<" + name + "> " + message);
            };

            //MinecraftServer.DebugMessage += (sender, message) => {
            //    Console.WriteLine("[DEBUG][" + sender.ToString() + "] " + message);
            //};

            MinecraftServer.LoginFailure += (sender, message) => {
                Console.WriteLine("Login Error: " + message);
            };

            MinecraftServer.ErrorMessage += (sender, message) => {
                Console.WriteLine("[ERROR][" + sender.ToString() + "] " + message);
            };

            MinecraftServer.InfoMessage += (sender, message) => {
                Console.WriteLine("[INFO][" + sender.ToString() + "] " + message);
            };

            MinecraftServer.PlayerRespawned += () => {
                Console.WriteLine("[Info] You respawned!");
            };

            if (MinecraftServer.VerifyNames)
                MinecraftServer.Login();

            MinecraftServer.Connect();

            string command;

            do {
                command = Console.ReadLine();

                if (command.StartsWith("say ")) 
                    MinecraftServer.SendChat(command.Substring(4));

                if (command.StartsWith("respawn")) {
                    MinecraftServer.Respawn();
                }
            } while (command != "quit");

            MinecraftServer.Disconnect();

            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args) {
			string serverIp = "127.0.0.1";
			int serverPort = 25565;
			string userName = "******";
			string userPassword = null;

			OptionSet p = new OptionSet ()
				.Add ("ip=", v => serverIp = v)
				.Add ("port=", v => int.Parse (v))
				.Add ("user="******"pass", v => userPassword = ReadPassword());

			p.Parse (args);

			var MinecraftServer = new MinecraftClient(serverIp, serverPort, userName, userPassword, !String.IsNullOrWhiteSpace(userPassword));
            MinecraftServer.ServerState = 2;

            MinecraftServer.Message += (sender, message, name) => {
                Console.WriteLine("<" + name + "> " + message);
            };

            //MinecraftServer.DebugMessage += (sender, message) => {
            //    Console.WriteLine("[DEBUG][" + sender.ToString() + "] " + message);
            //};

            MinecraftServer.LoginFailure += (sender, message) => {
                Console.WriteLine("Login Error: " + message);
            };

            MinecraftServer.ErrorMessage += (sender, message) => {
                Console.WriteLine("[ERROR][" + sender.ToString() + "] " + message);
            };

            MinecraftServer.InfoMessage += (sender, message) => {
                Console.WriteLine("[INFO][" + sender.ToString() + "] " + message);
            };

            MinecraftServer.PlayerRespawned += () => {
                Console.WriteLine("[Info] You respawned!");
            };

            if (MinecraftServer.VerifyNames)
                MinecraftServer.Login();

            MinecraftServer.Connect();

            string command;

            do {
                command = Console.ReadLine();

                if (command.StartsWith("say ")) 
                    MinecraftServer.SendChat(command.Substring(4));

                if (command.StartsWith("respawn")) {
                    MinecraftServer.Respawn();
                }
            } while (command != "quit");

            MinecraftServer.Disconnect();

            Console.ReadKey();
        }