With this script you can listen to, modify and cancel NMS (net.minecraft.server) packets being sent / received.
- Native Minecraft Version:
- Tested Minecraft Versions:
- skript-reflect (2.1.0+)Packet event:
Within this event the event-values player and string are usable: player is the player that sent / received the packet, string is the simple name of the packet class.Code (Text):packet [<(.+)>]
The regex represents the simple name of the packet class, this class doesn't need to be imported. You can also not include this part, and the trigger will be called for every packet.
Code (Text):on packet PacketPlayInChat:
send "&a%player% said %packet.a%" to console
cancel eventCode (Text):on packet PacketPlayInChat:
set packet.a to "Hello there!"
Be aware that NMS packets aren't nice to deal with, as they're undocumented, obfuscated and inconsistent between Minecraft server versions. To know what fields you need, you'll have to look at the source code of your server. There are 2 helpful resources that can help you find the meaning of packets and their fields:
- Mini's Mapping Viewer. This tool shows the non-obfuscated field names of nms classes, including packets. It does this by matching Mojang's official mappings to Spigot's mappings.
- The Protocol page of wiki.vg, where the Minecraft protocol is documented. This page documents the packets and their usage, and documents the protocol fields. These protocol fields are different from the fields from nms packets, but they are often similar, so they can help you get started.
Docs / Forums / Parser /Discord
Do you speak Dutch, Spanish, French or German and need Skript help? We've got channels for that in the skUnity Discord!