Interface VersionedPacketTransformer<C extends ClientboundPacketType,S extends ServerboundPacketType>
- Type Parameters:
C
- clientbound packet typeS
- serverbound packet type
public interface VersionedPacketTransformer<C extends ClientboundPacketType,S extends ServerboundPacketType>
Utility to send packets from a given base version to or from any client version supported by Via.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
scheduleSend
(UserConnection connection, C packetType, Consumer<PacketWrapper> packetWriter) boolean
scheduleSend
(UserConnection connection, S packetType, Consumer<PacketWrapper> packetWriter) boolean
scheduleSend
(PacketWrapper packet) Sends a packet to the user or server, depending on the packet type given byPacketWrapper.getPacketType()
, submitted to the netty event loop.boolean
send
(UserConnection connection, C packetType, Consumer<PacketWrapper> packetWriter) boolean
send
(UserConnection connection, S packetType, Consumer<PacketWrapper> packetWriter) boolean
send
(PacketWrapper packet) Sends a packet to the user or server, depending on the packet type given byPacketWrapper.getPacketType()
.@Nullable PacketWrapper
transform
(UserConnection connection, C packetType, Consumer<PacketWrapper> packetWriter) @Nullable PacketWrapper
transform
(UserConnection connection, S packetType, Consumer<PacketWrapper> packetWriter) @Nullable PacketWrapper
transform
(PacketWrapper packet) Transforms a packet to the protocol version of the given connection or server, or null if cancelled at some point.
-
Method Details
-
send
Sends a packet to the user or server, depending on the packet type given byPacketWrapper.getPacketType()
. Returns false if the packet has been cancelled at some point, but does not indicate whether a replacement has been constructed.- Returns:
- whether this packet specifically has been sent, false if cancelled
- Throws:
IllegalArgumentException
- if the packet type is not of the expected clientbound or serverbound packets classIllegalArgumentException
- ifPacketWrapper.user()
returns nullRuntimeException
- if no path from the input version to the required client version existsInformativeException
- if an error occurred while transforming or sending the packet
-
send
boolean send(UserConnection connection, C packetType, Consumer<PacketWrapper> packetWriter) throws InformativeException - Throws:
InformativeException
- See Also:
-
send
boolean send(UserConnection connection, S packetType, Consumer<PacketWrapper> packetWriter) throws InformativeException - Throws:
InformativeException
- See Also:
-
scheduleSend
Sends a packet to the user or server, depending on the packet type given byPacketWrapper.getPacketType()
, submitted to the netty event loop. Returns false if the packet has been cancelled at some point, but does not indicate whether a replacement has been constructed.- Parameters:
packet
- packet wrapper- Returns:
- whether this packet specifically has been sent, false if cancelled
- Throws:
IllegalArgumentException
- if the packet type is not of the expected clientbound or serverbound packets classIllegalArgumentException
- ifPacketWrapper.user()
returns nullRuntimeException
- if no path from the input version to the required client version existsInformativeException
- if an error occurred while transforming or sending the packet
-
scheduleSend
boolean scheduleSend(UserConnection connection, C packetType, Consumer<PacketWrapper> packetWriter) throws InformativeException - Throws:
InformativeException
- See Also:
-
scheduleSend
boolean scheduleSend(UserConnection connection, S packetType, Consumer<PacketWrapper> packetWriter) throws InformativeException - Throws:
InformativeException
- See Also:
-
transform
Transforms a packet to the protocol version of the given connection or server, or null if cancelled at some point. The target version is given byProtocolInfo.getProtocolVersion()
orProtocolInfo.getServerProtocolVersion()
.- Parameters:
packet
- packet wrapper- Returns:
- created and transformed packet wrapper, or null if cancelled at some point
- Throws:
IllegalArgumentException
- if the packet type is not of the expected clientbound or serverbound packets classIllegalArgumentException
- ifPacketWrapper.user()
returns nullRuntimeException
- if no path from the input version to the required client version existsInformativeException
- if an error occurred while transforming the packet
-
transform
@Nullable PacketWrapper transform(UserConnection connection, C packetType, Consumer<PacketWrapper> packetWriter) throws InformativeException - Throws:
InformativeException
- See Also:
-
transform
@Nullable PacketWrapper transform(UserConnection connection, S packetType, Consumer<PacketWrapper> packetWriter) throws InformativeException - Throws:
InformativeException
- See Also:
-