Packets
Module for accessing Minecraft's packets.
Features
- Sending packets
- Listening to packets
Usage
Supported platforms are: bukkit
Packet availability
Not all packets are currently mapped! Most serverbound packets are currently not available.
Maven
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 | <repositories>
<repository>
<id>screamingrepo</id>
<url>https://repo.screamingsandals.org/repository/maven-public</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.screamingsandals.lib</groupId>
<artifactId>packets-YOUR_PLATFORM</artifactId>
<version>2.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.screamingsandals.lib</groupId>
<artifactId>annotation</artifactId>
<version>2.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!-- Shade plugin configuration and relocation package org.screamingsandals.lib to your own package -->
|
Gradle
1
2
3
4
5
6
7
8
9
10
11
12
13 | repositories {
maven {
url 'https://repo.screamingsandals.org/repository/maven-public'
}
maven {
url 'https://papermc.io/repo/repository/maven-public'
}
}
dependencies {
implementation 'org.screamingsandals.lib:packets-YOUR_PLATFORM:2.0.1-SNAPSHOT'
annotationProcessor 'org.screamingsandals.lib:annotation:2.0.1-SNAPSHOT'
}
|
Examples
Sending a packet
I will demonstrate the functionality on the ClientboundDisconnectPacket.
First of all, construct the SLib packet with it's constructor.
| final SClientboundDisconnectPacket packet = new SClientboundDisconnectPacket();
|
Then, add the data to the packet.
| final SClientboundDisconnectPacket packet = new SClientboundDisconnectPacket();
packet.reason(Component.text("You were kicked, because why not."));
|
And lastly, send the packet.
| final SClientboundDisconnectPacket packet = new SClientboundDisconnectPacket();
packet.reason(Component.text("You were kicked, because why not."));
packet.sendPacket(player);
|
It is also possible to directly supply the data in the constructor.
| final SClientboundDisconnectPacket packet = new SClientboundDisconnectPacket(Component.text("You were kicked, because why not."));
packet.sendPacket(player);
|
And it is very recommended to use the fluent accessors.
| new SClientboundDisconnectPacket()
.reason(Component.text("You were kicked, because why not."))
.sendPacket(player);
|
Last update:
2022-03-22