1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PacketListenerNMSK

Discussion in 'APIs' started by TPGamesNL, Aug 3, 2020.

  1. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,500
    Likes Received:
    102
    Medals:
    With this script you can listen to, modify and cancel NMS (net.minecraft.server) packets being sent / received.

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

    Code (Text):
    1. on packet PacketPlayInChat:
    2.     send "&a%player% said %packet.a%" to console
    3.     cancel event
    Code (Text):
    1. on packet PacketPlayInChat:
    2.     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. A resource that can help you a little is 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.
     

Share This Page

Loading...