Package com.comphenix.protocol.injector
Class PacketConstructor
java.lang.Object
com.comphenix.protocol.injector.PacketConstructor
A packet constructor that uses an internal Minecraft.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRepresents a unwrapper for a constructor parameter. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PacketConstructorA packet constructor that automatically converts Bukkit types to their NMS conterpart. -
Method Summary
Modifier and TypeMethodDescriptioncreatePacket(Object... values) Construct a packet using the special builtin Minecraft constructors.static Class<?> Retrieve the class of an object, or just the class if it already is a class object.intDeprecated.getType()Retrieve the type of the packets this constructor creates.com.google.common.collect.ImmutableList<PacketConstructor.Unwrapper> withPacket(PacketType type, Object[] values) Create a packet constructor that creates packets using the given types.withUnwrappers(List<PacketConstructor.Unwrapper> unwrappers) Return a copy of the current constructor with a different list of unwrappers.
-
Field Details
-
DEFAULT
A packet constructor that automatically converts Bukkit types to their NMS conterpart.Remember to call withPacket().
-
-
Method Details
-
getClass
Retrieve the class of an object, or just the class if it already is a class object.- Parameters:
obj- - the object.- Returns:
- The class of an object.
-
getUnwrappers
-
getPacketID
Deprecated.Retrieve the id of the packets this constructor creates.Deprecated: Use
getType()instead.- Returns:
- The ID of the packets this constructor will create.
-
getType
Retrieve the type of the packets this constructor creates.- Returns:
- The type of the created packets.
-
withUnwrappers
Return a copy of the current constructor with a different list of unwrappers.- Parameters:
unwrappers- - list of unwrappers that convert Bukkit wrappers into the equivalent NMS classes.- Returns:
- A constructor with a different set of unwrappers.
-
withPacket
Create a packet constructor that creates packets using the given types.Note that if you pass a Class as a value, it will use its type directly.
- Parameters:
type- - the type of the packet to create.values- - the values that will match each parameter in the desired constructor.- Returns:
- A packet constructor with these types.
- Throws:
IllegalArgumentException- If no packet constructor could be created with these types.
-
createPacket
Construct a packet using the special builtin Minecraft constructors.- Parameters:
values- - values containing Bukkit wrapped items to pass to Minecraft.- Returns:
- The created packet.
- Throws:
FieldAccessException- Failure due to a security limitation.IllegalArgumentException- Arguments doesn't match the constructor.RuntimeException- Minecraft threw an exception.
-