Intercepting disconnect packet sent by the client?

Discussion in 'Spigot Plugin Development' started by Neoka, Jul 19, 2018.

  1. I am trying to make a combat-logging system for my server and instead of going through the trouble of physically creating an NPC I thought that maybe there is a way to prevent that disconnect packet from being handled. Is this possible? I have tried using ProtocolLib but it does not have the required PacketType that I am looking for.

    Thanks for your help!
  2. gzx


    The client doesn't send a disconnect packet to leave the server. I'm pretty sure it just closes the TCP connection.

    You could mess around with Netty to intercept the connection closing, but you're probably better off just creating an NPC.
  3. The ChannelDuplexHandler thing. If it's the packet you're looking for, don't call the super method
  4. Or you know, just use PlayerQuitEvent
    • Like Like x 1
    • Funny Funny x 1
  5. OP wanted to "cancel" the disconnect so the player stays "online" as an NPC while the connection is already closed.
    Though yeah, I agree with @gzx that it'll be easier to just make an NPC. You need to maintain the NPC player after the player disconnects. Might as well just spawn an NPC that's automatically handled right away.