コード例 #1
0
        public bool HandlePacket(PacketIncomingType packetType, List <byte> packetData)
        {
            string url  = dataTypes.ReadNextString(packetData);
            string hash = dataTypes.ReadNextString(packetData);

            //Send back "accepted" and "successfully loaded" responses for plugins making use of resource pack mandatory
            byte[] responseHeader = new byte[0];
            if (protocolversion < (int)McVersion.V110) //MC 1.10 does not include resource pack hash in responses
            {
                responseHeader = dataTypes.ConcatBytes(dataTypes.GetVarInt(hash.Length), Encoding.UTF8.GetBytes(hash));
            }
            packetSender.WritePacket(PacketOutgoingType.ResourcePackStatus, dataTypes.ConcatBytes(responseHeader, dataTypes.GetVarInt(3))); //Accepted pack
            packetSender.WritePacket(PacketOutgoingType.ResourcePackStatus, dataTypes.ConcatBytes(responseHeader, dataTypes.GetVarInt(0))); //Successfully loaded
            return(true);
        }
コード例 #2
0
 public override byte[] write(DataTypes dataTypes)
 {
     return(dataTypes.ConcatBytes(
                dataTypes.GetString(channel),
                dataTypes.GetArray(data.ToArray())
                ));
 }
コード例 #3
0
 public override byte[] write(DataTypes dataTypes)
 {
     return(dataTypes.ConcatBytes(
                dataTypes.GetVarInt(protocolVersion),
                dataTypes.GetString(serverAddress),
                dataTypes.GetUShort(serverPort),
                dataTypes.GetVarInt((int)nextState)));
 }
コード例 #4
0
 public override byte[] write(DataTypes dataTypes)
 {
     return(dataTypes.ConcatBytes(
                dataTypes.GetString(locale),
                dataTypes.GetByte(viewDistance),
                dataTypes.GetVarInt(chatMode),
                dataTypes.GetBool(chatColors),
                dataTypes.GetByte(skinParks),
                dataTypes.GetVarInt(mainHand)
                ));
 }
コード例 #5
0
        public void WritePacket(int id, IEnumerable <byte> data)
        {
            byte[] the_packet = dataTypes.ConcatBytes(dataTypes.GetVarInt(id), data.ToArray());

            if (connectionInfo.compressionThreshold > 0)                      //Compression enabled?
            {
                if (the_packet.Length >= connectionInfo.compressionThreshold) //Packet long enough for compressing?
                {
                    byte[] compressed_packet = ZlibUtils.Compress(the_packet);
                    the_packet = dataTypes.ConcatBytes(dataTypes.GetVarInt(the_packet.Length), compressed_packet);
                }
                else
                {
                    byte[] uncompressed_length = dataTypes.GetVarInt(0); //Not compressed (short packet)
                    the_packet = dataTypes.ConcatBytes(uncompressed_length, the_packet);
                }
            }

            connectionInfo.socketWrapper.SendDataRAW(dataTypes.ConcatBytes(dataTypes.GetVarInt(the_packet.Length), the_packet));
        }