1.8 Protocol Update

Adds the new 1.8 protocol.
That looks like Java code, it might not work the same way in C++. I'm not sure if C++ guarantees the shifts to be arithmetic - perhaps @worktycho would know?