Interface VersionedPacketTransformer<C extends ClientboundPacketType,​S extends ServerboundPacketType>

  • Type Parameters:
    C - clientbound packet type
    S - 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 Detail

      • send

        boolean send​(PacketWrapper packet)
              throws java.lang.Exception
        Sends a packet to the user or server, depending on the packet type given by PacketWrapper.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:
        java.lang.IllegalArgumentException - if the packet type is not of the expected clientbound or serverbound packets class
        java.lang.IllegalArgumentException - if PacketWrapper.user() returns null
        java.lang.RuntimeException - if no path from the input version to the required client version exists
        java.lang.Exception - if an error occurred while transforming or sending the packet
      • scheduleSend

        boolean scheduleSend​(PacketWrapper packet)
                      throws java.lang.Exception
        Sends a packet to the user or server, depending on the packet type given by PacketWrapper.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:
        java.lang.IllegalArgumentException - if the packet type is not of the expected clientbound or serverbound packets class
        java.lang.IllegalArgumentException - if PacketWrapper.user() returns null
        java.lang.RuntimeException - if no path from the input version to the required client version exists
        java.lang.Exception - if an error occurred while transforming or sending the packet
      • transform

        @Nullable PacketWrapper transform​(PacketWrapper packet)
                                   throws java.lang.Exception
        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 by ProtocolInfo.getProtocolVersion() or ProtocolInfo.getServerProtocolVersion().
        Parameters:
        packet - packet wrapper
        Returns:
        created and transformed packet wrapper, or null if cancelled at some point
        Throws:
        java.lang.IllegalArgumentException - if the packet type is not of the expected clientbound or serverbound packets class
        java.lang.IllegalArgumentException - if PacketWrapper.user() returns null
        java.lang.RuntimeException - if no path from the input version to the required client version exists
        java.lang.Exception - if an error occurred while transforming the packet