public class PacketConstructor
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
PacketConstructor.Unwrapper
Represents a unwrapper for a constructor parameter.
|
Modifier and Type | Field and Description |
---|---|
static PacketConstructor |
DEFAULT
A packet constructor that automatically converts Bukkit types to their NMS conterpart.
|
Modifier and Type | Method and Description |
---|---|
PacketContainer |
createPacket(java.lang.Object... values)
Construct a packet using the special builtin Minecraft constructors.
|
int |
getPacketID()
Retrieve the id of the packets this constructor creates.
|
com.google.common.collect.ImmutableList<PacketConstructor.Unwrapper> |
getUnwrappers() |
PacketConstructor |
withPacket(int id,
java.lang.Object[] values)
Create a packet constructor that creates packets using the given types.
|
PacketConstructor |
withUnwrappers(java.util.List<PacketConstructor.Unwrapper> unwrappers)
Return a copy of the current constructor with a different list of unwrappers.
|
public static PacketConstructor DEFAULT
Remember to call withPacket().
public com.google.common.collect.ImmutableList<PacketConstructor.Unwrapper> getUnwrappers()
public int getPacketID()
public PacketConstructor withUnwrappers(java.util.List<PacketConstructor.Unwrapper> unwrappers)
unwrappers
- - list of unwrappers that convert Bukkit wrappers into the equivalent NMS classes.public PacketConstructor withPacket(int id, java.lang.Object[] values)
id
- - packet ID.values
- - types to create.java.lang.IllegalArgumentException
- If no packet constructor could be created with these types.public PacketContainer createPacket(java.lang.Object... values) throws FieldAccessException
values
- - values containing Bukkit wrapped items to pass to Minecraft.FieldAccessException
- Failure due to a security limitation.java.lang.IllegalArgumentException
- Arguments doesn't match the constructor.java.lang.RuntimeException
- Minecraft threw an exception.