Package com.comphenix.protocol.events
Class PacketContainer
java.lang.Object
com.comphenix.protocol.events.AbstractStructure
com.comphenix.protocol.events.PacketContainer
- All Implemented Interfaces:
Serializable
Represents a Minecraft packet indirectly.
- See Also:
-
Field Summary
Fields inherited from class com.comphenix.protocol.events.AbstractStructure
handle, structureModifier -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFor serialization.PacketContainer(PacketType type) Creates a packet container for a new packet.PacketContainer(PacketType type, Object handle) Creates a packet container for an existing packet.PacketContainer(PacketType type, Object handle, StructureModifier<Object> structure) Creates a packet container for an existing packet. -
Method Summary
Modifier and TypeMethodDescriptionstatic io.netty.buffer.ByteBufDeprecated.Create a deep copy of the current packet.static ObjectdeserializeFromBuffer(PacketType packetType, Object buffer) static PacketContainerfromPacket(Object packet) Construct a new packet container from a given handle.Retrieves the underlying Minecraft packet.intgetId()Deprecated.Packet IDs are unreliable<T> Optional<T> Gets the metadata value for a given key if it exists.Retrieves the generic structure modifier for this packet.getType()Retrieve the packet type of this packet.voidremoveMeta(String key) Removes the metadata for a given key if it exists.<T> voidSets the metadata value at a given key.Create a shallow copy of the current packet.toString()Methods inherited from class com.comphenix.protocol.events.AbstractStructure
getAttributeCollectionModifier, getBlockData, getBlockDataArrays, getBlockEntityTypeModifier, getBlockPositionCollectionModifier, getBlockPositionModifier, getBlocks, getBooleans, getByteArrays, getByteArraySerializer, getBytes, getChatComponentArrays, getChatComponents, getChatFormattings, getChatTypes, getChatVisibilities, getChunkCoordIntPairs, getClientCommands, getClientIntents, getCombatEvents, getCustomPacketPayloads, getDataValueCollectionModifier, getDataWatcherModifier, getDifficulties, getDimensions, getDimensionTypes, getDirections, getDisplaySlots, getDoubles, getEffectTypes, getEithers, getEntityModifier, getEntityModifier, getEntityTypeModifier, getEntityUseActions, getEnumEntityUseActions, getEnumModifier, getEnumModifier, getFloat, getGameModes, getGameProfiles, getGameStateIDs, getHands, getHolders, getInstants, getIntegerArrays, getIntegers, getIntLists, getItemArrayModifier, getItemListModifier, getItemModifier, getItemSlots, getLevelChunkData, getLightUpdateData, getListNbtModifier, getLists, getLoginSignatures, getLongs, getMaps, getMerchantRecipeLists, getMessageSignatures, getMinecraftKeys, getMovingBlockPositions, getMultiBlockChangeInfoArrays, getNbtModifier, getNewParticles, getNumberFormats, getOptionals, getOptionalTeamParameters, getPacketBundles, getParticles, getPlayerActions, getPlayerDigTypes, getPlayerInfoAction, getPlayerInfoActions, getPlayerInfoDataLists, getProfilePublicKeyData, getProfilePublicKeys, getProtocols, getRegistrableModifier, getRemoteChatSessionData, getRenderTypes, getResourcePackStatus, getScoreboardActions, getSectionPositions, getServerPings, getSets, getShortArrays, getShorts, getSignatures, getSlotStackPairLists, getSoundCategories, getSoundEffects, getSpecificModifier, getStatisticMaps, getStringArrays, getStrings, getTitleActions, getUUIDLists, getUUIDs, getVectors, getWatchableCollectionModifier, getWorldBorderActions, getWorldKeys, getWorldTypeModifier
-
Constructor Details
-
PacketContainer
Creates a packet container for a new packet.- Parameters:
type- - the type of the packet to create.
-
PacketContainer
Creates a packet container for an existing packet.- Parameters:
type- - Type of the given packet.handle- - contained packet.
-
PacketContainer
Creates a packet container for an existing packet.- Parameters:
type- - Type of the given packet.handle- - contained packet.structure- - structure modifier.
-
PacketContainer
protected PacketContainer()For serialization.
-
-
Method Details
-
fromPacket
Construct a new packet container from a given handle.- Parameters:
packet- - the NMS packet.- Returns:
- The packet container.
-
getHandle
Retrieves the underlying Minecraft packet.- Overrides:
getHandlein classAbstractStructure- Returns:
- Underlying Minecraft packet.
-
getModifier
Retrieves the generic structure modifier for this packet.- Overrides:
getModifierin classAbstractStructure- Returns:
- Structure modifier.
-
getStructures
-
getOptionalStructures
-
getId
Deprecated.Packet IDs are unreliable -
getType
Retrieve the packet type of this packet.- Returns:
- The packet type.
-
shallowClone
Create a shallow copy of the current packet.This merely writes the content of each field to the new class directly, without performing any expensive copies.
- Returns:
- A shallow copy of the current packet.
-
deepClone
Create a deep copy of the current packet.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.
- Returns:
- A deep copy of the current packet.
-
createPacketBuffer
Deprecated.Construct a new packet data serializer.- Returns:
- The packet data serializer.
-
deserializeFromBuffer
-
serializeToBuffer
-
getMeta
Gets the metadata value for a given key if it exists. Packet metadata expires after a minute, which is far longer than a packet will ever be held in processing.- Type Parameters:
T- Metadata type- Parameters:
key- Metadata key- Returns:
- The metadata value, or an empty optional
-
setMeta
Sets the metadata value at a given key. Packet metadata expires after a minute, which is far longer than a packet will ever be held in processing.- Type Parameters:
T- Metadata type- Parameters:
key- Metadata keyvalue- Metadata value
-
removeMeta
Removes the metadata for a given key if it exists.- Parameters:
key- Key to remove meta for
-
toString
-
MinecraftReflection.createPacketDataSerializer(int)instead