Java 类io.netty.handler.codec.MessageToMessageDecoder 实例源码

项目:CratesPlus    文件:SignInputHandler.java   
public static void injectNetty(final Player player) {
    try {
        Object handle = player.getClass().getMethod("getHandle").invoke(player);
        Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
        final Channel channel = (Channel) channelField.get(playerConnection.getClass().getField("networkManager").get(playerConnection));
        if (channel != null) {
            channel.pipeline().addAfter("decoder", "update_sign", new MessageToMessageDecoder<Object>() {
                @Override
                protected void decode(ChannelHandlerContext channelHandlerContext, Object object, List list) throws Exception {
                    if (object.toString().contains("PacketPlayInUpdateSign")) {
                        Object packet = ReflectionUtil.getNMSClass("PacketPlayInUpdateSign").cast(object);
                        Bukkit.getPluginManager().callEvent(new PlayerInputEvent(player, (String[]) packet.getClass().getMethod("b").invoke(packet)));
                    }
                    list.add(object);
                }
            });
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:ViaVersion    文件:BungeePipelineUtil.java   
public static List<Object> callDecode(MessageToMessageDecoder decoder, ChannelHandlerContext ctx, ByteBuf input) throws InvocationTargetException {
    List<Object> output = new ArrayList<>();
    try {
        BungeePipelineUtil.DECODE_METHOD.invoke(decoder, ctx, input, output);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return output;
}
项目:ViaVersion    文件:BungeePipelineUtil.java   
public static ByteBuf decompress(ChannelHandlerContext ctx, ByteBuf bytebuf) {
    try {
        return (ByteBuf) callDecode((MessageToMessageDecoder) ctx.pipeline().get("decompress"), ctx.pipeline().context("decompress"), bytebuf).get(0);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        return ctx.alloc().buffer();
    }
}
项目:Cascade    文件:CryptoFunction.java   
public CryptoFunction(byte[] key, MessageToMessageEncoder<ByteBuf> encoder, MessageToMessageDecoder<ByteBuf> decoder) {

        this.key = key;
        this.encoder = encoder;
        this.decoder = decoder;
    }
项目:Cascade    文件:CryptoFunction.java   
public MessageToMessageDecoder<ByteBuf> getDecoder() {

        return decoder;
    }