// Server-To-Client only public updateScore(Wrapped.Wrapped Socket, Form1 Mainform) { string itemName = Socket.readString(); byte update = Socket.readByte(); string scoreName = Socket.readString(); int value = Socket.readInt(); }
// Server-to-Client only public teams(Wrapped.Wrapped socket, Form1 Mainform) { List <string> players; string teamDisplayname; string teamPrefix; string teamSuffix; byte friendlyFire; short playerCount; string teamName = socket.readString(); byte mode = socket.readByte(); if (mode == 0 || mode == 2) { teamDisplayname = socket.readString(); teamPrefix = socket.readString(); teamSuffix = socket.readString(); friendlyFire = socket.readByte(); } if (mode == 0 || mode == 3 || mode == 4) { playerCount = socket.readShort(); players = new List <string>(); for (int i = 1; i < playerCount; i++) { players.Add(socket.readString()); } } }
public updateSign(Wrapped.Wrapped socket, Form1 Mainform) { socket.readInt(); socket.readShort(); socket.readInt(); socket.readString(); socket.readString(); socket.readString(); socket.readString(); }
public OpenWindow(Wrapped.Wrapped socket, Form1 mainform) { socket.readByte(); socket.readByte(); socket.readString(); socket.readByte(); bool useTitle = socket.readBool(); }
public SpawnPainting(Wrapped.Wrapped socket, Form1 Mainform) { socket.readInt(); socket.readString(); socket.readInt(); socket.readInt(); socket.readInt(); socket.readInt(); }
public Namedsound(Wrapped.Wrapped socket, Form1 mainform) { socket.readString(); socket.readInt(); socket.readInt(); socket.readInt(); socket.readFloat(); socket.readByte(); }
void handle() { int Dimention = socket.readInt(); byte Difficulty = socket.readByte(); byte mode = socket.readByte(); short height = socket.readShort(); string leveltype = socket.readString(); mainform.Chunks.Clear(); // Clear out the chunks. }
public PluginMessage(Wrapped.Wrapped socket, Form1 Mainform) { socket.readString(); int length = socket.readShort(); if (length != 0) { socket.readByteArray(length); } }
public Particle(Wrapped.Wrapped Socket, Form1 mainform) { // Server to client only string particleName = Socket.readString(); float X = Socket.readFloat(); float Y = Socket.readFloat(); float Z = Socket.readFloat(); float OffsetX = Socket.readFloat(); float OffsetY = Socket.readFloat(); float OffsetZ = Socket.readFloat(); float particleSpeed = Socket.readFloat(); int number = Socket.readInt(); }
public OpenWindow(Wrapped.Wrapped socket, Form1 mainform) { int meh = socket.readByte(); byte invType = socket.readByte(); socket.readString(); socket.readByte(); bool useTitle = socket.readBool(); if (invType == 11) { socket.readInt(); } }
public void readMetadata(Wrapped.Wrapped socket) { // read metadata from socket do { byte item = socket.readByte(); if (item == 127) { break; } int index = item & 0x1F; int type = item >> 5; switch (type) { case 0: socket.readByte(); break; case 1: socket.readShort(); break; case 2: socket.readInt(); break; case 3: socket.readFloat(); break; case 4: socket.readString(); break; case 5: readSlot(socket); break; case 6: socket.readInt(); socket.readInt(); socket.readInt(); break; } } while (true); }
void handle() { int entityID = sock.readInt(); string levelType = sock.readString(); sbyte gameMode = sock.readSByte(); sbyte Dimension = sock.readSByte(); sbyte Difficulty = sock.readSByte(); sbyte Blank = sock.readSByte(); sbyte maxPlayers = sock.readSByte(); myform.puts("Logged in to server."); myform.puts("Server max players is " + Convert.ToString(maxPlayers)); if (Dimension == -1) { myform.puts("You are in the nether!"); } if (Dimension == 1) { myform.puts("You are in the end!"); } switch (Difficulty) { case 0: myform.puts("Server difficulty: Peaceful"); break; case 1: myform.puts("Server difficulty: Easy"); break; case 2: myform.puts("Server difficulty: Normal"); break; case 3: myform.puts("Server difficulty: Hard"); break; default: break; } myform.EntityID = entityID; }
public SpawnNamedEntity(Wrapped.Wrapped socket, Form1 mainform) { int EID = socket.readInt(); string Name = socket.readString(); int X = socket.readInt(); int Y = socket.readInt(); int Z = socket.readInt(); byte Yaw = socket.readByte(); byte Pitch = socket.readByte(); short heldItem = socket.readShort(); functions parser = new functions(); parser.readMetadata(socket); Classes.Entity newPlayer = new Classes.Entity(EID, Name, X, Y, Z, Yaw, Pitch, heldItem); mainform.Entitys.Add(newPlayer); }
private void handle() { functions func = new functions(); Message = socket.readString(); commandHandler ch = new commandHandler(socket, mainform, func.strip_codes(Message)); handleColors(Message); if (mainform.ircmode == 2 || mainform.ircmode == 3) { string[] args = Message.Split(' '); string username = args[0].Replace("<", "").Replace(">", "").Replace(":", "").Replace(" ", ""); username = func.strip_codes(username); if (!(username == mainform.username && Message.Contains("IRC: <"))) { mainform.ircmessage(mainform.translate_colors(Message)); } } }
public entProps(Wrapped.Wrapped socket, Form1 mainform) { int entId = socket.readInt(); int propCount = socket.readInt(); for (int b = 0; b < propCount; b++) { string key = socket.readString(); double value = socket.readDouble(); short listLength = socket.readShort(); for (int i = 0; i < listLength; i++) { long msb = socket.readLong(); long lsb = socket.readLong(); double ammount = socket.readDouble(); byte op = socket.readByte(); } } }
void handle() { // This packet is complicated, so I will comment the process. // Let's get the data off the line first.. string serverID = sock.readString(); short keyLength = sock.readShort(); short verifyLength; byte[] key; byte[] token; key = sock.readByteArray(keyLength); verifyLength = sock.readShort(); token = sock.readByteArray(verifyLength); //Here, we need some random bytes to use as a shared key with the server. RandomNumberGenerator random = RandomNumberGenerator.Create(); random.GetBytes(myform.sharedkey); // AsnKeyParser is a part of the cryptography.dll, which is simply a compiled version // of SMProxy's Cryptography.cs, with the server side parts stripped out. // You pass it the key data and ask it to parse, and it will // Extract the server's public key, then parse that into RSA for us. AsnKeyParser keyParser = new AsnKeyParser(key); RSAParameters Dekey = keyParser.ParseRSAPublicKey(); // Now we create an encrypter, and encrypt the token sent to us by the server // as well as our newly made shared key (Which can then only be decrypted with the server's private key) // and we send it to the server. RSACryptoServiceProvider cryptoService = new RSACryptoServiceProvider(); cryptoService.ImportParameters(Dekey); byte[] EncryptedSecret = cryptoService.Encrypt(myform.sharedkey, false); byte[] EncryptedVerfy = cryptoService.Encrypt(token, false); // I pass this information back up (Unencrypted) to the main form. // This allows me to have it ready for when I need this later. myform.ServerID = serverID; myform.token = token; myform.PublicKey = key; if (serverID != "-" && myform.onlineMode) { // Verify with Minecraft.net, if need be. // At this point, the server requires a hash containing the server id, // shared key, and original public key. So we make this, and then pass to Minecraft.net List <byte> hashlist = new List <byte>(); hashlist.AddRange(System.Text.Encoding.ASCII.GetBytes(serverID)); hashlist.AddRange(myform.sharedkey); hashlist.AddRange(key); byte[] hashData = hashlist.ToArray(); string hash = JavaHexDigest(hashData); myform.serverHash = hash; Minecraft_Net_Interaction verify = new Minecraft_Net_Interaction(); if (!verify.VerifyName(myform.username, myform.sessionId, hash)) { myform.puts("Failed to verify name with minecraft.net"); sock._stream.Close(); myform.sessionId = null; return; } } else { // Skip Verification, user is not online. myform.puts("Skipping verification."); } // Sets up the socket for encryption, but does not enable it yet. sock.InitEncryption(myform.sharedkey); // Respond to server. EncResponse Response = new EncResponse(sock, myform, EncryptedVerfy, EncryptedSecret, true); }
public TabComplete(Wrapped.Wrapped socket, Form1 mainform) { socket.readString(); }
// Server-to-Client only public scoreboardObjective(Wrapped.Wrapped Socket, Form1 Mainform) { string objectiveName = Socket.readString(); string objectiveValue = Socket.readString(); byte create = Socket.readByte(); }
private void handle() { functions func = new functions(); string name = "", message = "", type = "", color = "", style = ""; Message = socket.readString(); var root = JObject.Parse(Message); foreach (KeyValuePair <String, JToken> app in root) { var appName = app.Key; switch (appName) { case "text": message = app.Value.ToString(); if (message.Contains(" ")) { name = func.strip_codes(message.Substring(0, message.IndexOf(" ")).Replace("<", "").Replace(">", "").Replace(":", "").Replace(" ", "")); } type = "chat"; break; case "translate": type = app.Value.ToString(); break; case "using": name = app.Value.First.ToString(); message = app.Value.Last.ToString(); break; case "color": color = app.Value.ToString(); break; case "italic": if (app.Value.ToString() == "true") { style = "italic"; } break; } if (type == "chat.type.admin") { if (app.Value.HasValues == true) { name = app.Value[0].ToString(); JObject thisObj = JObject.Parse(app.Value[1].ToString()); foreach (KeyValuePair <String, JToken> part in thisObj) { var topName = part.Key; switch (topName) { case "translate": type = part.Value.ToString(); break; case "using": message = part.Value.First.ToString(); name = part.Value.Last.ToString(); break; } } } } } // Now with the JSON Parsed, we have to add some special message cases. switch (type) { case "multiplayer.player.joined": message = name + " Joined the server"; break; case "multiplayer.player.left": message = name + " Left the server"; break; case "death.attack.outOfWorld": message = name + " fell out of the world!"; break; case "death.attack.explosion.player": message = name + " was blown up by " + message; break; case "death.attack.mob": message = name + " was killed by a " + message; break; case "chat.type.text": message = name + ": " + message; commandHandler ch = new commandHandler(socket, mainform, name, message); break; case "chat": commandHandler h = new commandHandler(socket, mainform, name, message); break; case "chat.type.emote": message = "§d" + name + " " + message; break; case "chat.type.announcement": message = "§d[" + name + "]:§f " + message; break; case "commands.tp.success": message = name + " teleported to " + message; break; case "commands.op.success": message = name + " was promoted to Op"; break; default: message = Message; break; } if (color != "") { message = convertCode(message, color); } handleColors(message, style); if (mainform.ircmode == 2 || mainform.ircmode == 3) { string[] args = message.Split(' '); string username = args[0].Replace("<", "").Replace(">", "").Replace(":", "").Replace(" ", ""); username = func.strip_codes(username); if (!(username == mainform.username && message.Contains("IRC: <"))) { mainform.ircmessage(mainform.translate_colors(message)); } } }
// server-to-client only public displayScoreboard(Wrapped.Wrapped Socket, Form1 mainform) { byte position = Socket.readByte(); string scoreName = Socket.readString(); }
void handle() { myform.puts("Kicked by server! Reason: " + sock.readString()); myform.nh.stop(); }