Using the fact that the Java Deflater/Inflater API now supports
ByteBuffers as of Java 11, we can provide performance benefits equivalent
to the Velocity 1.0.x native compression on servers running Java 11+ on
non-macOS and non-Linux platforms (such as Windows).
zlib-ng boasts higher throughput than regular zlib, by combining patches
from Cloudflare, zlib, and ARM's improvements to zlib along with a more
modern codebase.
Profiling consistently shows that compression is the largest CPU expense
by far, so even a minor speed-up here is significant.
Instead of going through the general process function, which does extra
checks to ensure that its arguments are sane, move "closer" to the action
by stripping down to the actual implementation.
* Delay switch to new server until after JoinGame is sent.
Unfortunately, in some cases (especially vanilla Minecraft) some login
disconnects are sent after ServerLoginSuccess but before JoinGame.
We've been using ServerLoginSuccess but it has caused too many problems.
Now Velocity will switch to a stripped-down version of the play session
handler until JoinGame is received. This handler does very little by
itself: it simply forwards plugin messages (for Forge) and waits for the
JoinGame packet from the server.
This is an initial version: only vanilla Minecraft 1.12.2 was tested.
However this is the way Waterfall without entity rewriting does server
switches (which, in turn, is inherited from BungeeCord).
* Move to Gradle 5 and Error Prone.
We now try to work within the boundaries given by the native. In the
case of Java natives, we work with byte arrays. With natives, always use
direct buffers.
However, the numbers do favor the natives, since they work with direct
byte buffers, without any copying. For the most part, this commit is
intended to improve the lives of Velocity users on Windows.