From 8a96555cc741bdd2fb53c604209e23fe1725b52b Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 9 Mar 2013 09:54:19 +1100 Subject: [PATCH] We can now get pings! --- proxy/src/main/java/net/md_5/bungee/BungeeCord.java | 4 ++-- proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java | 1 + proxy/src/main/java/net/md_5/bungee/netty/PacketDecoder.java | 5 ++++- .../src/main/java/net/md_5/bungee/packet/DefinedPacket.java | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 880e24e2..a670eadf 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -187,11 +187,11 @@ public class BungeeCord extends ProxyServer for ( ListenerInfo info : config.getListeners() ) { Channel server = new ServerBootstrap() - .channel( NioServerSocketChannel.class) + .channel( NioServerSocketChannel.class ) + .childAttr( PipelineUtils.LISTENER, info ) .childHandler( PipelineUtils.SERVER_CHILD ) .group( eventLoops ) .localAddress( info.getHost() ) - .attr( PipelineUtils.LISTENER, info) .bind().channel(); listeners.add( server ); diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java index 8dcbddef..269ae264 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java @@ -60,6 +60,7 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + super.exceptionCaught( ctx, cause ); if ( ctx.channel().isActive() ) { ctx.close(); diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PacketDecoder.java b/proxy/src/main/java/net/md_5/bungee/netty/PacketDecoder.java index 98f0b821..0f7e2d0f 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/PacketDecoder.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/PacketDecoder.java @@ -27,7 +27,10 @@ public class PacketDecoder extends ReplayingDecoder @Override protected ByteBuf decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception { + int startIndex = in.readerIndex(); PacketReader.readPacket( in, protocol ); - return in.copy(); + ByteBuf readPacket = in.copy( startIndex, in.readerIndex() - startIndex ); + System.out.println( readPacket ); + return readPacket; } } diff --git a/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java b/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java index 6aff1861..f4a4e44c 100644 --- a/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java +++ b/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java @@ -88,7 +88,7 @@ public abstract class DefinedPacket implements ByteBuf public static DefinedPacket packet(ByteBuf buf) { - int id = buf.getUnsignedShort( 0 ); + short id = buf.getUnsignedByte( 0 ); Class clazz = classes[id]; DefinedPacket ret = null; if ( clazz != null )