public class PacketWrapper extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
PASSTHROUGH_ID |
| Constructor and Description |
|---|
PacketWrapper(int packetID,
io.netty.buffer.ByteBuf inputBuffer,
UserConnection userConnection) |
| Modifier and Type | Method and Description |
|---|---|
PacketWrapper |
apply(Direction direction,
State state,
int index,
List<Protocol> pipeline) |
PacketWrapper |
apply(Direction direction,
State state,
int index,
List<Protocol> pipeline,
boolean reverse)
Applies a pipeline from an index to the wrapper.
|
void |
cancel()
Cancel this packet from sending
|
void |
clearInputBuffer()
Clear the input buffer / readable objects
|
void |
clearPacket()
Clear the packet, used if you have to change the packet completely
|
PacketWrapper |
create(int packetID)
Create a new packet for the target of this packet.
|
PacketWrapper |
create(int packetID,
ValueCreator init)
Create a new packet with values.
|
<T> T |
get(Type<T> type,
int index)
Get a part from the output
|
int |
getId() |
boolean |
is(Type type,
int index)
Check if a type is at an index
|
boolean |
isCancelled()
Check if this packet is cancelled.
|
boolean |
isReadable(Type type,
int index)
Check if a type is at an index
|
<T> T |
passthrough(Type<T> type)
Take a value from the input and write to the output.
|
void |
passthroughAll()
Take all the inputs and write them to the output.
|
<T> T |
read(Type<T> type)
Read a type from the input.
|
void |
resetReader()
Reset the reader, so that it can be read again.
|
void |
send()
Deprecated.
|
void |
send(Class<? extends Protocol> packetProtocol)
Send this packet to the associated user.
|
void |
send(Class<? extends Protocol> packetProtocol,
boolean skipCurrentPipeline)
Send this packet to the associated user.
|
void |
send(Class<? extends Protocol> packetProtocol,
boolean skipCurrentPipeline,
boolean currentThread)
Send this packet to the associated user.
|
io.netty.channel.ChannelFuture |
sendFuture(Class<? extends Protocol> packetProtocol)
Send this packet to the associated user.
|
void |
sendToServer()
Deprecated.
|
void |
sendToServer(Class<? extends Protocol> packetProtocol) |
void |
sendToServer(Class<? extends Protocol> packetProtocol,
boolean skipCurrentPipeline) |
void |
sendToServer(Class<? extends Protocol> packetProtocol,
boolean skipCurrentPipeline,
boolean currentThread)
Send this packet to the server.
|
<T> void |
set(Type<T> type,
int index,
T value)
Set a currently existing part in the output
|
void |
setId(int id) |
String |
toString() |
UserConnection |
user()
Get the user associated with this Packet
|
<T> void |
write(Type<T> type,
T value)
Write a type to the output.
|
void |
writeToBuffer(io.netty.buffer.ByteBuf buffer)
Write the current output to a buffer.
|
public static final int PASSTHROUGH_ID
public PacketWrapper(int packetID,
io.netty.buffer.ByteBuf inputBuffer,
UserConnection userConnection)
public <T> T get(Type<T> type, int index) throws Exception
T - The return type of the type you wish to get.type - The type of the part you wish to get.index - The index of the part (relative to the type)InformativeException - If it fails to find it, an exception will be thrown.Exceptionpublic boolean is(Type type, int index)
type - The type of the part you wish to get.index - The index of the part (relative to the type)public boolean isReadable(Type type, int index)
type - The type of the part you wish to get.index - The index of the part (relative to the type)public <T> void set(Type<T> type, int index, T value) throws Exception
T - The return type of the type you wish to set.type - The type of the part you wish to set.index - The index of the part (relative to the type)value - The value of the part you wish to set it to.InformativeException - If it fails to set it, an exception will be thrown.Exceptionpublic <T> T read(Type<T> type) throws Exception
T - The return type of the type you wish to read.type - The type you wish to readInformativeException - If it fails to readExceptionpublic <T> void write(Type<T> type, T value)
T - The return type of the type you wish to write.type - The type to write.value - The value of the type to write.public <T> T passthrough(Type<T> type) throws Exception
T - The return type of the type you wish to pass through.type - The type to read and write.Exception - If it failed to read or writepublic void passthroughAll()
throws Exception
Exception - If it failed to read or writepublic void writeToBuffer(io.netty.buffer.ByteBuf buffer)
throws Exception
buffer - The buffer to write to.InformativeException - Throws an exception if it fails to write a value.Exceptionpublic void clearInputBuffer()
public void clearPacket()
public void send(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) throws Exception
packetProtocol - The protocol version of the packet.skipCurrentPipeline - Skip the current pipelineException - if it fails to writepublic void send(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception
packetProtocol - The protocol version of the packet.skipCurrentPipeline - Skip the current pipelinecurrentThread - Run in the same threadException - if it fails to writepublic void send(Class<? extends Protocol> packetProtocol) throws Exception
packetProtocol - The protocol version of the packet.Exception - if it fails to writepublic io.netty.channel.ChannelFuture sendFuture(Class<? extends Protocol> packetProtocol) throws Exception
packetProtocol - The protocol version of the packet.Exception - if it fails to write@Deprecated public void send() throws Exception
send(Class) as it will handle the pipeline properly.Exception - if it fails to writepublic PacketWrapper create(int packetID)
packetID - The ID of the new packetpublic PacketWrapper create(int packetID, ValueCreator init) throws Exception
packetID - The ID of the new packetinit - A ValueCreator to write to the packet.Exception - If it failed to write the values from the ValueCreator.public PacketWrapper apply(Direction direction, State state, int index, List<Protocol> pipeline, boolean reverse) throws Exception
direction - protocol directionstate - protocol stateindex - index to start from, will be reversed depending on the reverse parameterpipeline - protocol pipelinereverse - whether the array should be looped in reverse, will also reverse the given indexException - If it fails to transform a packet, exception will be thrownpublic PacketWrapper apply(Direction direction, State state, int index, List<Protocol> pipeline) throws Exception
Exceptionapply(Direction, State, int, List, boolean)public void cancel()
public boolean isCancelled()
public UserConnection user()
public void resetReader()
@Deprecated public void sendToServer() throws Exception
Exception - If it failed to writepublic void sendToServer(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception
packetProtocol - The protocol version of the packet.skipCurrentPipeline - Skip the current pipelinecurrentThread - Run in the same threadException - if it fails to writepublic void sendToServer(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) throws Exception
Exceptionpublic void sendToServer(Class<? extends Protocol> packetProtocol) throws Exception
Exceptionpublic int getId()
public void setId(int id)
Copyright © 2016–2021. All rights reserved.