Jagex-ByteBuf is a set of Netty ByteBuf utilities for RuneTek game emulation. Jagex-ByteBuf contains 3 different modules; extensions, wrapper and serialization which are discussed in detail below.
Contains a set of ByteBuf
extension methods to encode and decode RuneTek specific types and protocol obfuscations, for
example:
public fun ByteBuf.readShortLEAdd(index: Int) { ... }
reads 16-bits in little endian byte-order and negates 128 from the resulting value.
The wrapper module provides a wrapper, called JByteBuf
around ByteBuf
that, instead of upcasting the unsigned value to next biggest primitive returns an unsigned type. Using the wrapper is recommended because it results in stronger typing. Most methods that are available in ByteBuf
are also available in JByteBuf
. Creating a JByteBuf
can be done by calling ByteBufAllocator#jBuffer
.
Provides a kotlinx.serialization implementation for writing messages used in the RuneTek protocol. Jagex-ByteBuf-Serialization is similar to Protobuf but instead of specifying the encoding through a serializable format it uses annotations. Example:
@Serialization
class VarpLargePacket(
@JShort(JShortType.LE_ADD) private val id: Short,
@JInt(JIntType.IME) private val state: Int
)
Artifacts:
dependencies {
implementation(group = "org.guthix", name = "jagex-bytebuf-extensions", version = VERSION)
implementation(group = "org.guthix", name = "jagex-bytebuf-wrapper", version = VERSION)
implementation(group = "org.guthix", name = "jagex-bytebuf-serialization", version = VERSION)
}
Snapshot repository:
repositories {
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
When using the Serialization module:
plugins {
kotlin("plugin.serialization") version KOTLINX_SERIALIZATION_VERSION
}