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); }
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(); }
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(); }
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"]; }
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); }