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.
|
static java.lang.Class<?> |
getClass(java.lang.Object obj)
Retrieve the class of an object, or just the class if it already is a class object.
|
int |
getPacketID()
Deprecated.
|
PacketType |
getType()
Retrieve the type of the packets this constructor creates.
|
com.google.common.collect.ImmutableList<PacketConstructor.Unwrapper> |
getUnwrappers() |
PacketConstructor |
withPacket(int id,
java.lang.Object[] values)
Deprecated.
|
PacketConstructor |
withPacket(PacketType type,
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()
@Deprecated public int getPacketID()
Deprecated: Use getType()
instead.
public PacketType getType()
public PacketConstructor withUnwrappers(java.util.List<PacketConstructor.Unwrapper> unwrappers)
unwrappers
- - list of unwrappers that convert Bukkit wrappers into the equivalent NMS classes.@Deprecated public PacketConstructor withPacket(int id, java.lang.Object[] values)
Note that if you pass a Class> as a value, it will use its type directly.
Deprecated: Use withPacket(PacketType, Object[])
instead.
id
- - legacy (1.6.4) packet ID.values
- - the values that will match each parameter in the desired constructor.java.lang.IllegalArgumentException
- If no packet constructor could be created with these types.public PacketConstructor withPacket(PacketType type, java.lang.Object[] values)
Note that if you pass a Class> as a value, it will use its type directly.
type
- - the type of the packet to create.values
- - the values that will match each parameter in the desired constructor.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.public static java.lang.Class<?> getClass(java.lang.Object obj)
obj
- - the object.