示例#1
0
        void ConnectToServer()
        {
            IPEndPoint localEP;

            lock (serverConnectLock)
            {
                //Get a unique addres for every connection attempt
                rotatingSourceIP = (rotatingSourceIP + 1) % 0xFFFF;
                byte[] address = new byte[4];
                address[0] = 127;
                address[1] = (byte)(rotatingSourceIP >> 8);
                address[2] = (byte)(rotatingSourceIP & 0xFF);
                address[3] = (byte)(1);
                localEP    = new IPEndPoint(new IPAddress(address), 0);
            }
            //Console.WriteLine ("Connecting to " + MinecraftServer.IP + ":" + MinecraftServer.Port + " from " + localEP);

            Socket s = new Socket(
                AddressFamily.InterNetwork,
                SocketType.Stream,
                ProtocolType.Tcp
                );

            s.Bind(localEP);
            VanillaWorld vw = (VanillaWorld)World;

            s.Connect(vw.Endpoint);

            thread.User  = Player.MinecraftUsername + " " + s.LocalEndPoint;
            thread.State = "Connected";

            socket       = s;
            serverStream = new NetworkStream(s);
        }
示例#2
0
        public VanillaSession(VanillaWorld world, Client player)
            : base(player)
        {
            this.World = world;
            this.Vanilla = world;

            OreTracker = new OreTracker(player);

            if (player.MinecraftUsername == null)
                throw new ArgumentException("Player must be logged in, missing minecraftusername");

            thread = Threads.Create(this, RunServerReader, WatchdogKilled);
            thread.User = Player.MinecraftUsername;
            thread.Start();
        }
示例#3
0
        public VanillaSession(VanillaWorld world, Client player)
            : base(player)
        {
            this.World   = world;
            this.Vanilla = world;

            OreTracker = new OreTracker(player);

            if (player.MinecraftUsername == null)
            {
                throw new ArgumentException("Player must be logged in, missing minecraftusername");
            }

            thread      = Threads.Create(this, RunServerReader, WatchdogKilled);
            thread.User = Player.MinecraftUsername;
            thread.Start();
        }
示例#4
0
        static World()
        {
            var dirs = Directory.GetDirectories(Directory.GetCurrentDirectory());
            foreach (string d in dirs)
            {
                try
                {
                    string name = Path.GetFileName(d);
                    VanillaWorld w = new VanillaWorld(name);
                    VanillaWorlds.Add(w.ServerName, w);
                    Console.WriteLine("Loaded VanillaWorld: " + w);
                } catch (Exception)
                {
                }
            }

            Main = VanillaWorlds ["main"];
        }
示例#5
0
        static World()
        {
            var dirs = Directory.GetDirectories(Directory.GetCurrentDirectory());

            foreach (string d in dirs)
            {
                try
                {
                    string       name = Path.GetFileName(d);
                    VanillaWorld w    = new VanillaWorld(name);
                    VanillaWorlds.Add(w.ServerName, w);
                    Console.WriteLine("Loaded VanillaWorld: " + w);
                } catch (Exception)
                {
                }
            }

            Main = VanillaWorlds ["main"];
        }
示例#6
0
        void VanillaLoad(Client player, string[] cmd, int iarg)
        {
            string name = cmd [iarg];

            if (World.VanillaWorlds.ContainsKey(name))
                throw new ErrorException("World already loaded");

            try
            {
                VanillaWorld w = new VanillaWorld(name);
                World.VanillaWorlds.Add(name, w);
            } catch (FileNotFoundException)
            {
                throw new ErrorException("No such world: " + name);
            }
            player.TellSystem(Chat.Purple, "Loaded world " + name);
        }