Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devsrsouza/kt-mc-packet
A Minecraft Protocol library for Kotlin Multiplatform
https://github.com/devsrsouza/kt-mc-packet
kotlin kotlin-multiplatform kotlinx-serialization minecraft minecraft-api
Last synced: 2 months ago
JSON representation
A Minecraft Protocol library for Kotlin Multiplatform
- Host: GitHub
- URL: https://github.com/devsrsouza/kt-mc-packet
- Owner: DevSrSouza
- License: mit
- Created: 2020-04-01T22:09:28.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-03T13:16:17.000Z (over 3 years ago)
- Last Synced: 2024-10-12T03:44:31.320Z (3 months ago)
- Topics: kotlin, kotlin-multiplatform, kotlinx-serialization, minecraft, minecraft-api
- Language: Kotlin
- Homepage:
- Size: 223 KB
- Stars: 30
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kt-mc-packet
A Minecraft Java Edition Protocol library for Kotlin multiplatform that uses Kotlinx.serialization
to Encode and Decode Minecraft packets as kotlin data classes.## Usage
Serialize:
```kotlin
val minecraftVersion = 578 // 1.15.2val byteArray: ByteArray = MinecraftProtocol.dump(
Handshake.serializer(),
Handshake(
minecraftVersion,
"minecraftserver.com",
25565,
HandshakePacket.HandshakeNextState.STATUS
)
)
```Deserialize:
```kotlin
val handshake: Handshake = MinecraftProtocol.load(
Handshake.serializer(),
byteArrayWithPacketData
)
```## Images
from `src/jvmTest/kotlin/ServerStatusTest.kt`
![](images/server_status_test_image.png)from `src/jvmTest/kotlin/ServerLoginTest.kt`
![](images/server_login_test_image.png)