Java 类net.minecraft.util.io.netty.channel.ChannelHandlerContext 实例源码

项目:MoreMobs    文件:TinyProtocol.java   
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg)
        throws Exception {
    final Channel channel = ctx.channel();
    handleLoginStart(channel, msg);

    try {
        for (PacketListener listener : packetListeners) {
            msg = listener.onPacketInAsync(player, channel, msg);
        }
    } catch (Exception e) {
        plugin.getLogger().log(Level.SEVERE,
                "Error in onPacketInAsync().", e);
    }

    if (msg != null) {
        super.channelRead(ctx, msg);
    }
}
项目:MoreMobs    文件:TinyProtocol.java   
@Override
public void write(ChannelHandlerContext ctx, Object msg,
        ChannelPromise promise) throws Exception {
    try {
        for (PacketListener listener : packetListeners) {
            msg = listener.onPacketOutAsync(player, ctx.channel(), msg);
        }
    } catch (Exception e) {
        plugin.getLogger().log(Level.SEVERE,
                "Error in onPacketOutAsync().", e);
    }

    if (msg != null) {
        super.write(ctx, msg, promise);
    }
}
项目:SignGUI    文件:TinyProtocol.java   
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    final Channel channel = ctx.channel();
    handleLoginStart(channel, msg);

    try {
        for(PacketListener pl : protocolsListeners)
        msg = pl.onPacketInAsync(player, channel, msg);
    } catch (Exception e) {
        plugin.getLogger().log(Level.SEVERE, "Error in onPacketInAsync().", e);
    }

    if (msg != null) {
        super.channelRead(ctx, msg);
    }
}
项目:Tweakkit-Server    文件:PacketEncoder.java   
protected void a(ChannelHandlerContext channelhandlercontext, Packet packet, ByteBuf bytebuf) throws IOException {
    Integer integer = (Integer) ((BiMap) channelhandlercontext.channel().attr(NetworkManager.f).get()).inverse().get(packet.getClass());

    if (a.isDebugEnabled()) {
        a.debug(b, "OUT: [{}:{}] {}[{}]", new Object[] { channelhandlercontext.channel().attr(NetworkManager.d).get(), integer, packet.getClass().getName(), packet.b()});
    }

    if (integer == null) {
        throw new IOException("Can\'t serialize unregistered packet");
    } else {
        PacketDataSerializer packetdataserializer = new PacketDataSerializer(bytebuf, NetworkManager.getVersion(channelhandlercontext.channel())); // Spigot

        packetdataserializer.b(integer.intValue());
        packet.b(packetdataserializer);
        this.c.b(integer.intValue(), (long) packetdataserializer.readableBytes());
    }
}
项目:CraftBukkit    文件:NetworkManager.java   
public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) {
    ChatMessage chatmessage;

    if (throwable instanceof TimeoutException) {
        chatmessage = new ChatMessage("disconnect.timeout", new Object[0]);
    } else {
        chatmessage = new ChatMessage("disconnect.genericReason", new Object[] { "Internal Exception: " + throwable});
    }

    this.close(chatmessage);
}
项目:CraftBukkit    文件:NetworkManager.java   
protected void a(ChannelHandlerContext channelhandlercontext, Packet packet) {
    if (this.m.isOpen()) {
        if (packet.a()) {
            packet.handle(this.o);
        } else {
            this.k.add(packet);
        }
    }
}
项目:SignGUI    文件:TinyProtocol.java   
private void createServerChannelHandler() {
    endInitProtocol = new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(Channel channel) throws Exception {
            try {
                synchronized (networkManagers) {
                    if (!closed) {
                        injectChannelInternal(channel);
                    }
                }
            } catch (Exception e) {
                plugin.getLogger().log(Level.SEVERE, "Cannot inject incomming channel " + channel, e);
            }
        }

    };

    beginInitProtocol = new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(Channel channel) throws Exception {
            channel.pipeline().addLast(endInitProtocol);
        }

    };

    serverChannelHandler = new ChannelInboundHandlerAdapter() {

        @Override
        public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
            Channel channel = (Channel) msg;

            channel.pipeline().addFirst(beginInitProtocol);
            ctx.fireChannelRead(msg);
        }

    };
}
项目:SignGUI    文件:TinyProtocol.java   
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
    try {
        for(PacketListener pl : protocolsListeners)
        msg = pl.onPacketOutAsync(player, ctx.channel(), msg);
    } catch (Exception e) {
        plugin.getLogger().log(Level.SEVERE, "Error in onPacketOutAsync().", e);
    }

    if (msg != null) {
        super.write(ctx, msg, promise);
    }
}
项目:Tweakkit-Server    文件:NetworkManager.java   
public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception { // CraftBukkit - throws Exception
    super.channelActive(channelhandlercontext);
    this.m = channelhandlercontext.channel();
    this.n = this.m.remoteAddress();
    // Spigot Start
    this.preparing = false;
    // Spigot End
    this.a(EnumProtocol.HANDSHAKING);
}
项目:Tweakkit-Server    文件:NetworkManager.java   
public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) {
    ChatMessage chatmessage;

    if (throwable instanceof TimeoutException) {
        chatmessage = new ChatMessage("disconnect.timeout", new Object[0]);
    } else {
        chatmessage = new ChatMessage("disconnect.genericReason", new Object[] { "Internal Exception: " + throwable});
    }

    this.close(chatmessage);
    if (MinecraftServer.getServer().isDebugging()) throwable.printStackTrace(); // Spigot
}
项目:Tweakkit-Server    文件:NetworkManager.java   
protected void a(ChannelHandlerContext channelhandlercontext, Packet packet) {
    if (this.m.isOpen()) {
        if (packet.a()) {
            packet.handle(this.o);
        } else {
            this.k.add(packet);
        }
    }
}
项目:HoloAPI    文件:PlayerInjector.java   
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    // Handle the packet
    final WrappedPacket packet = new WrappedPacket(msg);

    if (packet.getPacketType().equals(PacketType.Play.Client.USE_ENTITY))
        Bukkit.getScheduler().scheduleSyncDelayedTask(HoloAPI.getCore(), new Runnable() {
            @Override
            public void run() {
                PlayerInjector.this.injectionManager.handlePacket(packet, PlayerInjector.this);
            }
        });

    super.channelRead(ctx, msg);
}
项目:MoreMobs    文件:TinyProtocol.java   
private void createServerChannelHandler() {
    endInitProtocol = new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(Channel channel) throws Exception {
            try {
                synchronized (networkManagers) {
                    if (!closed) {
                        injectChannelInternal(channel);
                    }
                }
            } catch (Exception e) {
                plugin.getLogger().log(Level.SEVERE,
                        "Cannot inject incomming channel " + channel, e);
            }
        }

    };

    beginInitProtocol = new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(Channel channel) throws Exception {
            channel.pipeline().addLast(endInitProtocol);
        }

    };

    serverChannelHandler = new ChannelInboundHandlerAdapter() {

        @Override
        public void channelRead(ChannelHandlerContext ctx, Object msg)
                throws Exception {
            Channel channel = (Channel) msg;

            channel.pipeline().addFirst(beginInitProtocol);
            ctx.fireChannelRead(msg);
        }

    };
}
项目:CraftBukkit    文件:NetworkManager.java   
public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception { // CraftBukkit - throws Exception
    super.channelActive(channelhandlercontext);
    this.m = channelhandlercontext.channel();
    this.n = this.m.remoteAddress();
    this.a(EnumProtocol.HANDSHAKING);
}
项目:CraftBukkit    文件:NetworkManager.java   
public void channelInactive(ChannelHandlerContext channelhandlercontext) {
    this.close(new ChatMessage("disconnect.endOfStream", new Object[0]));
}
项目:CraftBukkit    文件:NetworkManager.java   
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Object object) {
    this.a(channelhandlercontext, (Packet) object);
}
项目:Tweakkit-Server    文件:NetworkManager.java   
public void channelInactive(ChannelHandlerContext channelhandlercontext) {
    this.close(new ChatMessage("disconnect.endOfStream", new Object[0]));
}
项目:Tweakkit-Server    文件:NetworkManager.java   
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Object object) {
    this.a(channelhandlercontext, (Packet) object);
}
项目:Tweakkit-Server    文件:PacketEncoder.java   
protected void encode(ChannelHandlerContext channelhandlercontext, Object object, ByteBuf bytebuf) throws IOException {
    this.a(channelhandlercontext, (Packet) object, bytebuf);
}
项目:PlayerSimulator    文件:DummyNetworkManager.java   
public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception {
}
项目:PlayerSimulator    文件:DummyNetworkManager.java   
public void channelInactive(ChannelHandlerContext channelhandlercontext) {
}
项目:PlayerSimulator    文件:DummyNetworkManager.java   
public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) {
}
项目:PlayerSimulator    文件:DummyNetworkManager.java   
protected void a(ChannelHandlerContext channelhandlercontext, Packet packet) {
}
项目:PlayerSimulator    文件:DummyNetworkManager.java   
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Object object) {
}