public class PacketContainer
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
handle |
protected int |
id |
protected StructureModifier<java.lang.Object> |
structureModifier |
Modifier | Constructor and Description |
---|---|
protected |
PacketContainer()
For serialization.
|
|
PacketContainer(int id)
Creates a packet container for a new packet.
|
|
PacketContainer(int id,
java.lang.Object handle)
Creates a packet container for an existing packet.
|
|
PacketContainer(int id,
java.lang.Object handle,
StructureModifier<java.lang.Object> structure)
Creates a packet container for an existing packet.
|
Modifier and Type | Method and Description |
---|---|
PacketContainer |
deepClone()
Create a deep copy of the current packet.
|
StructureModifier<byte[]> |
getByteArrays()
Retrieves a read/write structure for every byte array field.
|
StreamSerializer |
getByteArraySerializer()
Retrieve a serializer for reading and writing ItemStacks stored in a byte array.
|
StructureModifier<java.lang.Byte> |
getBytes()
Retrieves a read/write structure for every byte field.
|
StructureModifier<WrappedDataWatcher> |
getDataWatcherModifier()
Retrieves a read/write structure for data watchers.
|
StructureModifier<java.lang.Double> |
getDoubles()
Retrieves a read/write structure for every double field.
|
StructureModifier<org.bukkit.entity.Entity> |
getEntityModifier(org.bukkit.World world)
Retrieves a read/write structure for entity objects.
|
StructureModifier<java.lang.Float> |
getFloat()
Retrieves a read/write structure for every float field.
|
java.lang.Object |
getHandle()
Retrieves the underlying Minecraft packet.
|
int |
getID()
Retrieves the ID of this packet.
|
StructureModifier<int[]> |
getIntegerArrays()
Retrieves a read/write structure for every int array field.
|
StructureModifier<java.lang.Integer> |
getIntegers()
Retrieves a read/write structure for every integer field.
|
StructureModifier<org.bukkit.inventory.ItemStack[]> |
getItemArrayModifier()
Retrieves a read/write structure for arrays of ItemStacks.
|
StructureModifier<org.bukkit.inventory.ItemStack> |
getItemModifier()
Retrieves a read/write structure for ItemStack.
|
StructureModifier<java.lang.Long> |
getLongs()
Retrieves a read/write structure for every long field.
|
StructureModifier<java.lang.Object> |
getModifier()
Retrieves the generic structure modifier for this packet.
|
StructureModifier<NbtBase<?>> |
getNbtModifier()
Retrieves a read/write structure for NBT classes.
|
StructureModifier<java.util.List<ChunkPosition>> |
getPositionCollectionModifier()
Retrieves a read/write structure for collections of chunk positions.
|
StructureModifier<ChunkPosition> |
getPositionModifier()
Retrieves a read/write structure for chunk positions.
|
StructureModifier<java.lang.Short> |
getShorts()
Retrieves a read/write structure for every short field.
|
<T> StructureModifier<T> |
getSpecificModifier(java.lang.Class<T> primitiveType)
Retrieves a read/write structure for every field with the given type.
|
StructureModifier<java.lang.String[]> |
getStringArrays()
Retrieves a read/write structure for every String array field.
|
StructureModifier<java.lang.String> |
getStrings()
Retrieves a read/write structure for every String field.
|
StructureModifier<java.util.List<WrappedWatchableObject>> |
getWatchableCollectionModifier()
Retrieves a read/write structure for collections of watchable objects.
|
StructureModifier<org.bukkit.WorldType> |
getWorldTypeModifier()
Retrieves a read/write structure for the world type enum.
|
PacketContainer |
shallowClone()
Create a shallow copy of the current packet.
|
protected int id
protected transient java.lang.Object handle
protected transient StructureModifier<java.lang.Object> structureModifier
public PacketContainer(int id)
id
- - ID of the packet to create.public PacketContainer(int id, java.lang.Object handle)
id
- - ID of the given packet.handle
- - contained packet.public PacketContainer(int id, java.lang.Object handle, StructureModifier<java.lang.Object> structure)
id
- - ID of the given packet.handle
- - contained packet.structure
- - structure modifier.protected PacketContainer()
public java.lang.Object getHandle()
public StructureModifier<java.lang.Object> getModifier()
public <T> StructureModifier<T> getSpecificModifier(java.lang.Class<T> primitiveType)
primitiveType
- - the type to find.public StructureModifier<java.lang.Byte> getBytes()
public StructureModifier<java.lang.Short> getShorts()
public StructureModifier<java.lang.Integer> getIntegers()
public StructureModifier<java.lang.Long> getLongs()
public StructureModifier<java.lang.Float> getFloat()
public StructureModifier<java.lang.Double> getDoubles()
public StructureModifier<java.lang.String> getStrings()
public StructureModifier<java.lang.String[]> getStringArrays()
public StructureModifier<byte[]> getByteArrays()
public StreamSerializer getByteArraySerializer()
public StructureModifier<int[]> getIntegerArrays()
public StructureModifier<org.bukkit.inventory.ItemStack> getItemModifier()
This modifier will automatically marshall between the Bukkit ItemStack and the internal Minecraft ItemStack.
public StructureModifier<org.bukkit.inventory.ItemStack[]> getItemArrayModifier()
This modifier will automatically marshall between the Bukkit ItemStack and the internal Minecraft ItemStack.
public StructureModifier<org.bukkit.WorldType> getWorldTypeModifier()
This modifier will automatically marshall between the Bukkit world type and the internal Minecraft world type.
public StructureModifier<WrappedDataWatcher> getDataWatcherModifier()
public StructureModifier<org.bukkit.entity.Entity> getEntityModifier(org.bukkit.World world)
Note that entities are transmitted by integer ID, and the type may not be enough to distinguish between entities and other values. Thus, this structure modifier MAY return null or invalid entities for certain fields. Using the correct index is essential.
public StructureModifier<ChunkPosition> getPositionModifier()
public StructureModifier<NbtBase<?>> getNbtModifier()
public StructureModifier<java.util.List<ChunkPosition>> getPositionCollectionModifier()
This modifier will automatically marshall between the visible ProtocolLib ChunkPosition and the internal Minecraft ChunkPosition.
public StructureModifier<java.util.List<WrappedWatchableObject>> getWatchableCollectionModifier()
This modifier will automatically marshall between the visible WrappedWatchableObject and the internal Minecraft WatchableObject.
public int getID()
public PacketContainer shallowClone()
This merely writes the content of each field to the new class directly, without performing any expensive copies.
public PacketContainer deepClone()
This will perform a full copy of the entire object tree, only skipping known immutable objects and primitive types.
Note that the inflated buffers in packet 51 and 56 will be copied directly to save memory.