Class PipelineUtil

java.lang.Object
com.viaversion.viaversion.util.PipelineUtil

public final class PipelineUtil extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<Object>
    callDecode(io.netty.handler.codec.ByteToMessageDecoder decoder, io.netty.channel.ChannelHandlerContext ctx, Object input)
    Calls the decode method on a netty ByteToMessageDecoder.
    static List<Object>
    callDecode(io.netty.handler.codec.MessageToMessageDecoder decoder, io.netty.channel.ChannelHandlerContext ctx, Object msg)
    Calls the decode method on a netty MessageToMessageDecoder.
    static void
    callEncode(io.netty.handler.codec.MessageToByteEncoder encoder, io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.buffer.ByteBuf output)
    Calls the encode method on a netty MessageToByteEncoder.
    static boolean
    Check if a stack trace contains a certain exception
    static <T> @Nullable T
    Check if a stack trace contains a certain exception and returns it if present.
    static @Nullable io.netty.channel.ChannelHandlerContext
    getContextBefore(String name, io.netty.channel.ChannelPipeline pipeline)
    Get the context for the channel handler before a certain name.
    static @Nullable io.netty.channel.ChannelHandlerContext
    getPreviousContext(String name, io.netty.channel.ChannelPipeline pipeline)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PipelineUtil

      public PipelineUtil()
  • Method Details

    • callDecode

      public static List<Object> callDecode(io.netty.handler.codec.ByteToMessageDecoder decoder, io.netty.channel.ChannelHandlerContext ctx, Object input) throws Exception
      Calls the decode method on a netty ByteToMessageDecoder.
      Parameters:
      decoder - decoder
      ctx - current context
      input - packet to decode
      Returns:
      a list of the decoders output
      Throws:
      Exception - prapagated exception from the underlying method if thrown
      InvocationTargetException - wrapped throwable if a given throwable is not an exeption or error
    • callEncode

      public static void callEncode(io.netty.handler.codec.MessageToByteEncoder encoder, io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.buffer.ByteBuf output) throws Exception
      Calls the encode method on a netty MessageToByteEncoder.
      Parameters:
      encoder - encoder
      ctx - current context
      msg - packet to encode
      Throws:
      Exception - prapagated exception from the underlying method if thrown
      InvocationTargetException - wrapped throwable if a given throwable is not an exeption or error
    • callDecode

      public static List<Object> callDecode(io.netty.handler.codec.MessageToMessageDecoder decoder, io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception
      Calls the decode method on a netty MessageToMessageDecoder.
      Parameters:
      decoder - decoder
      ctx - current context
      msg - packet to decode
      Returns:
      a list of the decoders output
      Throws:
      Exception - prapagated exception from the underlying method if thrown
      InvocationTargetException - wrapped throwable if a given throwable is not an exeption or error
    • containsCause

      public static boolean containsCause(Throwable t, Class<?> c)
      Check if a stack trace contains a certain exception
      Parameters:
      t - The throwable
      c - The exception to look for
      Returns:
      True if the stack trace contained it as its cause or if t is an instance of c.
    • getCause

      public static <T> @Nullable T getCause(Throwable t, Class<T> c)
      Check if a stack trace contains a certain exception and returns it if present.
      Parameters:
      t - throwable
      c - the exception to look for
      Returns:
      contained exception of t if present
    • getContextBefore

      public static @Nullable io.netty.channel.ChannelHandlerContext getContextBefore(String name, io.netty.channel.ChannelPipeline pipeline)
      Get the context for the channel handler before a certain name.
      Parameters:
      name - The name of the channel handler
      pipeline - The pipeline to target
      Returns:
      The ChannelHandler before the one requested.
    • getPreviousContext

      public static @Nullable io.netty.channel.ChannelHandlerContext getPreviousContext(String name, io.netty.channel.ChannelPipeline pipeline)