/// <summary> /// Authecate the user to join /// </summary> private static bool Auth(string _Username, string _Password) { WebClient Client = new WebClient(); string returns; try { Debug("Connecting to minecraft.net...\n"); PostData post = new PostData("http://minecraft.net/game/getversion.jsp"); post.Add("user", _Username); post.Add("password", _Password); post.Add("version", "12"); returns = post.GetResult(true); } catch { SMPInterface.LastError = "Could not connect to minecraft.net"; return(false); } SMPInterface.Debug("Authecation: " + returns + "\n"); if (returns != "Bad login" && returns != "Old version" && returns != "Error") { string[] Bits = returns.Split(":".ToCharArray()); SessionHash = Bits[1]; CaseUsername = Bits[2]; SessionID = Bits[3]; return(true); } else { SMPInterface.LastError = returns; return(false); } }
public static bool AuthConnect(string _Username, string _ServerID) { string returns = ""; try { PostData post = new PostData("http://www.minecraft.net/game/joinserver.jsp"); post.Add("user", _Username); post.Add("sessionId", SessionID); post.Add("serverId", _ServerID); returns = post.GetResult(true); } catch { SMPInterface.LastError = "Could not connect to minecraft.net"; return(false); } SMPInterface.Debug("Connect Authecation: " + returns + "\n"); if (returns == "OK") { return(true); } else { return(false); } }
public static void Disconnect() { SMPInterface.Debug("Disconnected " + CaseUsername + "\n"); PacketResponder.Abort(); Reader.Close(); Writer.Close(); }
/// <summary> /// Send the shit down the toilet /// </summary> public void Flush() { byte[] BufferSend = new byte[Pointer]; for (int i = 0; i < Pointer; i++) { BufferSend[i] = Buffer[i]; //char[] Stuff = Buffer[i].ToString("X8").ToCharArray(); //SMPInterface.Debug(Stuff[6].ToString() + Stuff[7].ToString() + " "); } //SMPInterface.Debug("\n"); try { Writer.Write(BufferSend); } catch (Exception ex) { SMPInterface.Debug(ex.Message); } // Reset Buffer Buffer = new byte[1024]; Pointer = 0; }