@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); } }
@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); } }
@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); } }
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()); } }
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); }
protected void a(ChannelHandlerContext channelhandlercontext, Packet packet) { if (this.m.isOpen()) { if (packet.a()) { packet.handle(this.o); } else { this.k.add(packet); } } }
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); } }; }
@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); } }
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); }
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 }
@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); }
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); }
public void channelInactive(ChannelHandlerContext channelhandlercontext) { this.close(new ChatMessage("disconnect.endOfStream", new Object[0])); }
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Object object) { this.a(channelhandlercontext, (Packet) object); }
protected void encode(ChannelHandlerContext channelhandlercontext, Object object, ByteBuf bytebuf) throws IOException { this.a(channelhandlercontext, (Packet) object, bytebuf); }
public void channelActive(ChannelHandlerContext channelhandlercontext) throws Exception { }
public void channelInactive(ChannelHandlerContext channelhandlercontext) { }
public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) { }
protected void a(ChannelHandlerContext channelhandlercontext, Packet packet) { }
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Object object) { }