PacketListenerNMSK

API PacketListenerNMSK 1.0.0

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Contributors
TPGamesNL
Supported Minecraft Versions
  1. 1.8
  2. 1.9
  3. 1.10
  4. 1.11
  5. 1.12
  6. 1.13
  7. 1.14
  8. 1.15
  9. 1.16
With this script you can listen to, modify and cancel NMS (net.minecraft.server) packets being sent / received.

Required addons:
Packet event:
Code:
packet [<(.+)>]
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.
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.

Packet:
Code:
[event-]packet

Code:
on packet PacketPlayInChat:
    send "&a%player% said %packet.a%" to console
    cancel event

Code:
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.

Icon made by Eucalyp from www.flaticon.com.
Author
TPGamesNL
Downloads
1,014
Views
1,014
First release
Last update
Rating
5.00 star(s) 3 ratings

More resources from TPGamesNL

Latest reviews

Does not work for me on paper v1_19_R1 but still the code looks very clean and looks like it could work. If it would work for me it would be crazy and ye.

What i dont understand is
if {_packetType} is "PacketPlayInChat"
how should "net.minecraft.server.v1_19_R1(as example).PacketPlayInChat" exist?
Shouldn't it be something like "net.minecraft.server.network.protocol.game.%{_packetType}%"?
At "if class "net.minecraft.server.{@nms}.%{_packetType}%" is set:"

Anyways. Looks good and would be even cooler if workx but other guy said that u should update to 1.17 so maybe thts why its not working for me
Good API, but could you update it to 1.17 because I get warnings at 1.17 through the API
He knows, how to do excellent addons, five start, without looking
TPGamesNL
TPGamesNL
Thanks for the review :D