public interface UserConnection
Modifier and Type | Method and Description |
---|---|
void |
addEntityTracker(java.lang.Class<? extends Protocol> protocolClass,
EntityTracker tracker)
Adds an entity tracker to the user connection.
|
boolean |
checkClientboundPacket()
Monitors clientbound packets and returns whether a packet can/should be processed.
|
default boolean |
checkIncomingPacket() |
default boolean |
checkOutgoingPacket() |
boolean |
checkServerboundPacket()
Monitors serverbound packets and returns whether a packet can/should be processed.
|
default void |
clearStoredObjects()
Clear stored objects and entity trackers.
|
void |
clearStoredObjects(boolean isServerSwitch)
Clear stored objects and entity trackers.
|
void |
disconnect(java.lang.String reason)
Disconnect a connection.
|
java.util.UUID |
generatePassthroughToken()
Returns a newly generated uuid that will let a packet be passed through without
transformig its contents if used together with
PacketWrapper.PASSTHROUGH_ID . |
<T extends StorableObject> |
get(java.lang.Class<T> objectClass)
Get an object from the storage.
|
@Nullable io.netty.channel.Channel |
getChannel()
Returns the netty channel if present.
|
<T extends EntityTracker> |
getEntityTracker(java.lang.Class<? extends Protocol> protocolClass)
Returns the entity tracker by the given protocol class if present.
|
java.util.Collection<EntityTracker> |
getEntityTrackers()
Returns a collection of entity trackers currently registered.
|
long |
getId()
Returns the internal id incremented for each new connection.
|
PacketTracker |
getPacketTracker()
Returns the user's packet tracker used for the inbuilt packet-limiter.
|
ProtocolInfo |
getProtocolInfo()
Returns info containing the current protocol state and userdata.
|
java.util.Map<java.lang.Class<?>,StorableObject> |
getStoredObjects()
Returns a map of stored objects.
|
boolean |
has(java.lang.Class<? extends StorableObject> objectClass)
Check if the storage has an object.
|
boolean |
isActive()
Returns whether the connection has protocols other than the base protocol applied.
|
boolean |
isClientSide()
Returns whether this is a client-side connection.
|
boolean |
isPacketLimiterEnabled()
Returns whether the packet limiter applies to this user.
|
boolean |
isPendingDisconnect()
Returns whether the connection is pending a disconnect, initiated through
disconnect(String) . |
void |
put(StorableObject object)
Put an object into the stored objects based on class.
|
<T extends StorableObject> |
remove(java.lang.Class<T> objectClass)
Removes and returns an object from the storage.
|
void |
scheduleSendRawPacket(io.netty.buffer.ByteBuf packet)
Send a raw packet to the player, submitted to the netty event loop.
|
void |
scheduleSendRawPacketToServer(io.netty.buffer.ByteBuf packet)
Sends a raw packet to the server, submitted to the netty event loop.
|
void |
sendRawPacket(io.netty.buffer.ByteBuf packet)
Sends a raw packet to the connection on the current thread.
|
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 on the current thread.
|
void |
setActive(boolean active) |
void |
setPacketLimiterEnabled(boolean packetLimiterEnabled)
Sets the status of the packet limiter.
|
void |
setPendingDisconnect(boolean pendingDisconnect) |
boolean |
shouldApplyBlockProtocol()
Returns whether
ViaVersionConfig.blockedProtocolVersions() should be checked for this connection. |
boolean |
shouldTransformPacket()
Checks if packets needs transforming.
|
void |
transformClientbound(io.netty.buffer.ByteBuf buf,
java.util.function.Function<java.lang.Throwable,java.lang.Exception> cancelSupplier)
Transforms the clientbound packet contained in ByteBuf.
|
default void |
transformIncoming(io.netty.buffer.ByteBuf buf,
java.util.function.Function<java.lang.Throwable,java.lang.Exception> cancelSupplier)
Transforms the packet depending on whether the connection is clientside or not.
|
default void |
transformOutgoing(io.netty.buffer.ByteBuf buf,
java.util.function.Function<java.lang.Throwable,java.lang.Exception> cancelSupplier)
Transforms the packet depending on whether the connection is clientside or not.
|
void |
transformServerbound(io.netty.buffer.ByteBuf buf,
java.util.function.Function<java.lang.Throwable,java.lang.Exception> cancelSupplier)
Transforms the serverbound packet contained in ByteBuf.
|
<T extends StorableObject> T get(java.lang.Class<T> objectClass)
T
- The type of the class you want to get.objectClass
- The class of the object to getboolean has(java.lang.Class<? extends StorableObject> objectClass)
objectClass
- The object class to check<T extends StorableObject> T remove(java.lang.Class<T> objectClass)
T
- type of the class you want to getobjectClass
- class of the object to getvoid put(StorableObject object)
object
- The object to store.java.util.Collection<EntityTracker> getEntityTrackers()
<T extends EntityTracker> T getEntityTracker(java.lang.Class<? extends Protocol> protocolClass)
T
- entity tracker typeprotocolClass
- protocol classvoid addEntityTracker(java.lang.Class<? extends Protocol> protocolClass, EntityTracker tracker)
protocolClass
- protocol classtracker
- entity trackerdefault void clearStoredObjects()
void clearStoredObjects(boolean isServerSwitch)
isServerSwitch
- whether the clear is due to a server switchvoid sendRawPacket(io.netty.buffer.ByteBuf packet)
packet
- raw packet to sendvoid scheduleSendRawPacket(io.netty.buffer.ByteBuf packet)
packet
- raw packet to sendio.netty.channel.ChannelFuture sendRawPacketFuture(io.netty.buffer.ByteBuf packet)
packet
- The raw packet to sendPacketTracker getPacketTracker()
void disconnect(java.lang.String reason)
reason
- The reason to use, not used if player is not active.void sendRawPacketToServer(io.netty.buffer.ByteBuf packet)
packet
- raw packet to be sentvoid scheduleSendRawPacketToServer(io.netty.buffer.ByteBuf packet)
packet
- raw packet to be sentboolean checkServerboundPacket()
boolean checkClientboundPacket()
default boolean checkIncomingPacket()
checkClientboundPacket()
,
checkServerboundPacket()
default boolean checkOutgoingPacket()
checkClientboundPacket()
,
checkServerboundPacket()
boolean shouldTransformPacket()
void transformClientbound(io.netty.buffer.ByteBuf buf, java.util.function.Function<java.lang.Throwable,java.lang.Exception> cancelSupplier) throws java.lang.Exception
buf
- ByteBuf with packet id and packet contentscancelSupplier
- function called with original CancelException for generating the Exception when the packet is cancelledCancelException
- if the packet should be cancelledInformativeException
- if packet transforming failedjava.lang.Exception
- if any other processing outside of transforming failsvoid transformServerbound(io.netty.buffer.ByteBuf buf, java.util.function.Function<java.lang.Throwable,java.lang.Exception> cancelSupplier) throws java.lang.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 failedjava.lang.Exception
- if any other processing outside of transforming failsdefault void transformOutgoing(io.netty.buffer.ByteBuf buf, java.util.function.Function<java.lang.Throwable,java.lang.Exception> cancelSupplier) throws java.lang.Exception
java.lang.Exception
transformClientbound(ByteBuf, Function)
,
transformServerbound(ByteBuf, Function)
default void transformIncoming(io.netty.buffer.ByteBuf buf, java.util.function.Function<java.lang.Throwable,java.lang.Exception> cancelSupplier) throws java.lang.Exception
java.lang.Exception
transformClientbound(ByteBuf, Function)
,
transformServerbound(ByteBuf, Function)
long getId()
@Nullable io.netty.channel.Channel getChannel()
ProtocolInfo getProtocolInfo()
java.util.Map<java.lang.Class<?>,StorableObject> getStoredObjects()
has(Class)
,
get(Class)
,
put(StorableObject)
boolean isActive()
void setActive(boolean active)
boolean isPendingDisconnect()
disconnect(String)
.void setPendingDisconnect(boolean pendingDisconnect)
boolean isClientSide()
boolean shouldApplyBlockProtocol()
ViaVersionConfig.blockedProtocolVersions()
should be checked for this connection.boolean isPacketLimiterEnabled()
void setPacketLimiterEnabled(boolean packetLimiterEnabled)
packetLimiterEnabled
- whether the packet limiter should be enabledjava.util.UUID generatePassthroughToken()
PacketWrapper.PASSTHROUGH_ID
.