How to detect when server receives packet

Discussion in 'Plugin Development' started by bys1, Apr 2, 2017.

Thread Status:
Not open for further replies.
  1. How can I detect when a server receives a packet from a player using NMS?
    I want to make a packet listener with NMS which detects when the server receives a PacketPlayInSettings packet from a player. I've been searching for tutorials or topics with similar questions but I couldn't find anything.

    What I'm searching for: I want someone to link me a good tutorial or explain me how it works. I'd like to have a code example or at least with methods/classes to use with explanation on how it works.
    Please do not link me a github class which can detect Packets because it might work but I won't understand the code at all.
     
  2. I'm no expert at this, but you need ProtocolLib for this. There are many easy to find tutorials for it so I won't link you to it.
     
  3. I don't need and I don't want ProtocolLib. ProtocolLib is a plugin/API which means there is a way to do it without ProtocolLib. I have been searching for hours and I haven't found a way to do it without ProtocolLib.
     
  4. Offline

    frej4189

    Why don't you? There's no need to reprogram something that has already been done.
    The only reason you would ever have to not use API's is if you're practicing, but if you're actually working on a project, go ahead, it's not embarrassing to use other peoples code.
     
  5. I want to do some practicing with it indeed and later I want to implement it in a project. The reason I don't want to use ProtocolLib is because I don't want to depend on it. I want to have my projects/plugins not depend on any other api or plugin made by me.
     
  6. Offline

    Zombie_Striker

    @bys1
    The thing is, you're not just re-inventing the wheel, you're reinventing a car. ProtocolLib has a massive amount of code dedicated to this, so you would need to use almost all of his code in order to achieve what you want. Also, if you plan on doing anything with those received packets, such as try to cancel it or send other packets when it happens, you may actually break protocol lib if a server has it.

    Having your project depend on other APIs is not a negative. I have no idea why people have this repulsion to using code that already exists. APIs and Libraries exist so they can be used.
     
  7. The thing is, just answer my question.
     
  8. Offline

    frej4189

    I don't think you're getting the point here, you have absolutely no reason to NOT depend on anything, it's just a waste of time really, ProtocolLib has taken a lot of time to create, and if you want to create it all over again, it's gonna take just as long if not longer, get over your fear of using API's and libraries and depend on ProtocolLib.
     
  9. True, but I still want to know how to listen to a PacketPlayInSettings. Please don't ask why.
     
  10. Offline

    N00BHUN73R

  11. How can I listen to a PacketPlayInSettings? As far as I've seen it only gives an event on a packet going from the server to a client and not on a PacketPlayIn from the client to the server.
     
  12. Offline

    N00BHUN73R

    @bys1
    I'll try and look through the source and find it since I don't know all too much about how this works

    Edit: Try looking in PacketFilterManager, looks like it provides a little bit

    -- PixeLInc --
     
    Last edited: Apr 3, 2017
Thread Status:
Not open for further replies.

Share This Page