public class UserConnection extends Object
Constructor and Description |
---|
UserConnection(@Nullable io.netty.channel.Channel channel) |
UserConnection(@Nullable io.netty.channel.Channel channel,
boolean clientSide)
Creates an UserConnection.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkIncomingPacket()
Monitors incoming packets
|
boolean |
checkOutgoingPacket()
Monitors outgoing packets
|
void |
clearStoredObjects()
Clear all the stored objects.
|
void |
disconnect(String reason)
Disconnect a connection.
|
boolean |
equals(Object o) |
boolean |
exceedsMaxPPS()
Checks for packet flood with the packets sent in the last second.
|
<T extends StoredObject> |
get(Class<T> objectClass)
Get an object from the storage.
|
@Nullable io.netty.channel.Channel |
getChannel() |
long |
getId() |
long |
getIntervalPackets() |
@Nullable Object |
getLastPacket() |
long |
getPacketsPerSecond() |
@Nullable ProtocolInfo |
getProtocolInfo() |
long |
getReceivedPackets() |
int |
getSecondsObserved() |
long |
getSentPackets() |
long |
getStartTime() |
Map<Class,StoredObject> |
getStoredObjects() |
int |
getWarnings() |
boolean |
has(Class<? extends StoredObject> objectClass)
Check if the storage has an object.
|
int |
hashCode() |
boolean |
incrementReceived()
Used for incrementing the number of packets received from the client.
|
void |
incrementSent()
Used for incrementing the number of packets sent to the client.
|
boolean |
isActive() |
boolean |
isClientSide() |
boolean |
isPendingDisconnect() |
void |
put(StoredObject object)
Put an object into the stored objects based on class.
|
void |
sendRawPacket(io.netty.buffer.ByteBuf packet)
Send a raw packet to the player (netty thread).
|
void |
sendRawPacket(io.netty.buffer.ByteBuf packet,
boolean currentThread)
Send a raw packet to the player.
|
io.netty.channel.ChannelFuture |
sendRawPacketFuture(io.netty.buffer.ByteBuf packet)
Send a raw packet to the player with returning the future.
|
void |
sendRawPacketToServer(io.netty.buffer.ByteBuf packet)
Sends a raw packet to the server.
|
void |
sendRawPacketToServer(io.netty.buffer.ByteBuf packet,
boolean currentThread)
Sends a raw packet to the server.
|
void |
setActive(boolean active) |
void |
setIntervalPackets(long intervalPackets) |
void |
setLastPacket(@Nullable Object lastPacket) |
void |
setPacketsPerSecond(long packetsPerSecond) |
void |
setPendingDisconnect(boolean pendingDisconnect) |
void |
setProtocolInfo(@Nullable ProtocolInfo protocolInfo) |
void |
setReceivedPackets(long receivedPackets) |
void |
setSecondsObserved(int secondsObserved) |
void |
setSentPackets(long sentPackets) |
void |
setStartTime(long startTime) |
void |
setWarnings(int warnings) |
boolean |
shouldApplyBlockProtocol() |
boolean |
shouldTransformPacket()
Checks if packets needs transforming.
|
void |
transformIncoming(io.netty.buffer.ByteBuf buf,
Function<Throwable,Exception> cancelSupplier)
Transforms the incoming packet contained in ByteBuf.
|
void |
transformOutgoing(io.netty.buffer.ByteBuf buf,
Function<Throwable,Exception> cancelSupplier)
Transforms the outgoing packet contained in ByteBuf.
|
public UserConnection(@Nullable @Nullable io.netty.channel.Channel channel, boolean clientSide)
channel
- netty channel.clientSide
- true if it's a client-side connectionpublic UserConnection(@Nullable @Nullable io.netty.channel.Channel channel)
channel
- UserConnection(Channel, boolean)
@Nullable public <T extends StoredObject> T get(Class<T> objectClass)
T
- The type of the class you want to get.objectClass
- The class of the object to getpublic boolean has(Class<? extends StoredObject> objectClass)
objectClass
- The object class to checkpublic void put(StoredObject object)
object
- The object to store.public void clearStoredObjects()
public void sendRawPacket(io.netty.buffer.ByteBuf packet, boolean currentThread)
packet
- The raw packet to sendcurrentThread
- Should it run in the same threadpublic io.netty.channel.ChannelFuture sendRawPacketFuture(io.netty.buffer.ByteBuf packet)
packet
- The raw packet to sendpublic void sendRawPacket(io.netty.buffer.ByteBuf packet)
packet
- The packet to sendpublic void incrementSent()
public boolean incrementReceived()
public boolean exceedsMaxPPS()
incrementReceived()
before using this method.incrementReceived()
public void disconnect(String reason)
reason
- The reason to use, not used if player is not active.public void sendRawPacketToServer(io.netty.buffer.ByteBuf packet, boolean currentThread)
packet
- Raw packet to be sentcurrentThread
- If true
executes immediately, false
submits a task to EventLooppublic void sendRawPacketToServer(io.netty.buffer.ByteBuf packet)
packet
- Raw packet to be sentpublic boolean checkIncomingPacket()
public boolean checkOutgoingPacket()
public boolean shouldTransformPacket()
public void transformOutgoing(io.netty.buffer.ByteBuf buf, Function<Throwable,Exception> cancelSupplier) throws Exception
buf
- ByteBuf with packet id and packet contentscancelSupplier
- Function called with original CancelException for generating the Exception used when
packet is cancelledCancelException
- if the packet should be cancelledInformativeException
- if packet transforming failedException
- if any other processing outside of transforming failspublic void transformIncoming(io.netty.buffer.ByteBuf buf, Function<Throwable,Exception> cancelSupplier) throws Exception
buf
- ByteBuf with packet id and packet contentscancelSupplier
- Function called with original CancelException for generating the Exception used when
packet is cancelledCancelException
- if the packet should be cancelledInformativeException
- if packet transforming failedException
- if any other processing outside of transforming failspublic long getId()
@Nullable public @Nullable io.netty.channel.Channel getChannel()
@Nullable public @Nullable ProtocolInfo getProtocolInfo()
public void setProtocolInfo(@Nullable @Nullable ProtocolInfo protocolInfo)
public Map<Class,StoredObject> getStoredObjects()
public boolean isActive()
public void setActive(boolean active)
public boolean isPendingDisconnect()
public void setPendingDisconnect(boolean pendingDisconnect)
@Nullable public @Nullable Object getLastPacket()
public void setLastPacket(@Nullable @Nullable Object lastPacket)
public long getSentPackets()
public void setSentPackets(long sentPackets)
public long getReceivedPackets()
public void setReceivedPackets(long receivedPackets)
public long getStartTime()
public void setStartTime(long startTime)
public long getIntervalPackets()
public void setIntervalPackets(long intervalPackets)
public long getPacketsPerSecond()
public void setPacketsPerSecond(long packetsPerSecond)
public int getSecondsObserved()
public void setSecondsObserved(int secondsObserved)
public int getWarnings()
public void setWarnings(int warnings)
public boolean isClientSide()
public boolean shouldApplyBlockProtocol()
Copyright © 2016–2021. All rights reserved.