Package com.viaversion.viaversion.util
Class PipelineUtil
java.lang.Object
com.viaversion.viaversion.util.PipelineUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncallDecode(io.netty.handler.codec.ByteToMessageDecoder decoder, io.netty.channel.ChannelHandlerContext ctx, Object input) Calls the decode method on a netty ByteToMessageDecoder.callDecode(io.netty.handler.codec.MessageToMessageDecoder decoder, io.netty.channel.ChannelHandlerContext ctx, Object msg) Calls the decode method on a netty MessageToMessageDecoder.static voidcallEncode(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 booleancontainsCause(Throwable t, Class<?> c) Check if a stack trace contains a certain exceptionstatic <T> @Nullable TCheck if a stack trace contains a certain exception and returns it if present.static @Nullable io.netty.channel.ChannelHandlerContextgetContextBefore(String name, io.netty.channel.ChannelPipeline pipeline) Get the context for the channel handler before a certain name.static @Nullable io.netty.channel.ChannelHandlerContextgetPreviousContext(String name, io.netty.channel.ChannelPipeline pipeline)
-
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- decoderctx- current contextinput- packet to decode- Returns:
- a list of the decoders output
- Throws:
Exception- propagated exception from the underlying method if thrownInvocationTargetException- wrapped throwable if a given throwable is not an exception 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- encoderctx- current contextmsg- packet to encode- Throws:
Exception- propagated exception from the underlying method if thrownInvocationTargetException- wrapped throwable if a given throwable is not an exception 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- decoderctx- current contextmsg- packet to decode- Returns:
- a list of the decoders output
- Throws:
Exception- propagated exception from the underlying method if thrownInvocationTargetException- wrapped throwable if a given throwable is not an exception or error
-
containsCause
Check if a stack trace contains a certain exception- Parameters:
t- The throwablec- 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
Check if a stack trace contains a certain exception and returns it if present.- Parameters:
t- throwablec- 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 handlerpipeline- 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)
-