diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java index 06d282e6..12c2606d 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java @@ -37,11 +37,17 @@ public class PluginManager private final ProxyServer proxy; /*========================================================================*/ private final Yaml yaml = new Yaml(); - @SuppressWarnings("unchecked") - private final EventBus eventBus = new EventBus( ProxyServer.getInstance().getLogger(), Subscribe.class, EventHandler.class ); + private final EventBus eventBus; private final Map plugins = new HashMap<>(); private final Map commandMap = new HashMap<>(); + @SuppressWarnings("unchecked") + public PluginManager(ProxyServer proxy) + { + this.proxy = proxy; + eventBus = new EventBus( proxy.getLogger(), Subscribe.class, EventHandler.class ); + } + /** * Register a command so that it may be executed. * diff --git a/pom.xml b/pom.xml index 1623896c..b82a7786 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ unknown - 4.0.0.CR1 + 4.0.0.CR2 UTF-8 diff --git a/proxy/pom.xml b/proxy/pom.xml index dae93676..f76f403e 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -53,13 +53,19 @@ mysql mysql-connector-java 5.1.24 - compile + runtime + + + org.javassist + javassist + 3.17.1-GA + runtime org.xerial sqlite-jdbc 3.7.2 - compile + runtime 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 80c5647b..2f17e7ad 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -84,7 +84,7 @@ public class BungeeCord extends ProxyServer * Thread pools. */ public final ScheduledThreadPoolExecutor executors = new BungeeThreadPool( new ThreadFactoryBuilder().setNameFormat( "Bungee Pool Thread #%1$d" ).build() ); - public final MultithreadEventLoopGroup eventLoops = new NioEventLoopGroup( 0, new ThreadFactoryBuilder().setNameFormat( "Netty IO Thread #%1$d" ).build() ); + public final MultithreadEventLoopGroup eventLoops = new NioEventLoopGroup( NioEventLoopGroup.DEFAULT_EVENT_LOOP_THREADS, new ThreadFactoryBuilder().setNameFormat( "Netty IO Thread #%1$d" ).build() ); /** * locations.yml save thread. */ 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 2b7b9e27..564b88c0 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 @@ -1,6 +1,7 @@ package net.md_5.bungee.netty; import io.netty.buffer.ByteBuf; +import io.netty.buffer.MessageBuf; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ReplayingDecoder; import lombok.AllArgsConstructor; @@ -25,13 +26,29 @@ public class PacketDecoder extends ReplayingDecoder private int protocol; @Override - protected byte[] decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception + protected void decode(ChannelHandlerContext ctx, ByteBuf in, MessageBuf out) throws Exception { - int startIndex = in.readerIndex(); - PacketReader.readPacket( in, protocol ); - byte[] buf = new byte[ in.readerIndex() - startIndex ]; - in.readerIndex( startIndex ); - in.readBytes( buf, 0, buf.length ); - return buf; + // While we have enough data + while ( true ) + { + // Store our start index + int startIndex = in.readerIndex(); + // Run packet through framer + PacketReader.readPacket( in, protocol ); + // If we got this far, it means we have formed a packet, so lets grab the end index + int endIndex = in.readerIndex(); + // Allocate a buffer big enough for all bytes we have read + byte[] buf = new byte[ endIndex - startIndex ]; + // Go back to start index + in.readerIndex( startIndex ); + // Drain all the bytes into our buffer + in.readBytes( buf, 0, buf.length ); + // Jump back to the end of this packet + in.readerIndex( endIndex ); + // Checkpoint our state incase we don't have enough data for another packet + checkpoint(); + // Store our decoded message + out.add( buf ); + } } }