Class WirePacket
java.lang.Object
com.comphenix.protocol.injector.netty.WirePacket
A packet represented only by its id and bytes.
-
Constructor Summary
ConstructorsConstructorDescriptionWirePacket(int id, byte[] bytes) Constructs a new WirePacket with a given id and contentsWirePacket(PacketType type, byte[] bytes) Constructs a new WirePacket with a given type and contents -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]bytesFromPacket(PacketContainer packet) Creates a byte array from an existing PacketContainer containing all the bytes from that packetbooleanstatic WirePacketfromPacket(PacketContainer packet) Creates a WirePacket from an existing PacketContainerstatic WirePacketfromPacket(Object packet) Creates a WirePacket from an existing Minecraft packetbyte[]getBytes()Gets this packet's contents as a byte arrayintgetId()Gets this packet's IDinthashCode()static intreadVarInt(io.netty.buffer.ByteBuf input) io.netty.buffer.ByteBufSerializes this packet into a byte buffertoString()voidwriteBytes(io.netty.buffer.ByteBuf output) Writes the contents of this packet to a given outputvoidwriteFully(io.netty.buffer.ByteBuf output) Fully writes the ID and contents of this packet to a given outputvoidwriteId(io.netty.buffer.ByteBuf output) Writes the id of this packet to a given outputstatic voidwriteVarInt(io.netty.buffer.ByteBuf output, int value)
-
Constructor Details
-
WirePacket
Constructs a new WirePacket with a given type and contents- Parameters:
type- Type of the packetbytes- Contents of the packet
-
WirePacket
public WirePacket(int id, byte[] bytes) Constructs a new WirePacket with a given id and contents- Parameters:
id- ID of the packetbytes- Contents of the packet
-
-
Method Details
-
fromPacket
Creates a WirePacket from an existing PacketContainer- Parameters:
packet- Existing packet- Returns:
- The resulting WirePacket
-
bytesFromPacket
Creates a byte array from an existing PacketContainer containing all the bytes from that packet- Parameters:
packet- Existing packet- Returns:
- the byte array
-
fromPacket
Creates a WirePacket from an existing Minecraft packet- Parameters:
packet- Existing Minecraft packet- Returns:
- The resulting WirePacket
- Throws:
IllegalArgumentException- If the packet is null or not a Minecraft packet
-
writeVarInt
public static void writeVarInt(io.netty.buffer.ByteBuf output, int value) -
readVarInt
public static int readVarInt(io.netty.buffer.ByteBuf input) -
getId
public int getId()Gets this packet's ID- Returns:
- The ID
-
getBytes
public byte[] getBytes()Gets this packet's contents as a byte array- Returns:
- The contents
-
writeId
public void writeId(io.netty.buffer.ByteBuf output) Writes the id of this packet to a given output- Parameters:
output- Output to write to
-
writeBytes
public void writeBytes(io.netty.buffer.ByteBuf output) Writes the contents of this packet to a given output- Parameters:
output- Output to write to
-
writeFully
public void writeFully(io.netty.buffer.ByteBuf output) Fully writes the ID and contents of this packet to a given output- Parameters:
output- Output to write to
-
serialize
public io.netty.buffer.ByteBuf serialize()Serializes this packet into a byte buffer- Returns:
- The buffer
-
equals
-
hashCode
public int hashCode() -
toString
-