Packet manipulation

Discussion in 'Plugin Development' started by Skionz, Feb 2, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Skionz

    Currently I am working on removing my ProtocolLib dependency for this. Basically this means I need to know how to modify outgoing PacketStatusOutServerInfo packets. I'm not just interested in changing the online players, but changing all of the data stored in the packet.

    What I have tried
    Initially I tried creating a subclass of PlayerConnection and overriding the sendPacket method. To make sure it worked I printed out the packet class names as it was invoked, but PacketStatusOutServerInfo was not there. At first I was surprised, but then I realized this was because the Player hadn't joined the server yet and their corresponding EntityPlayer instance didn't exist yet.

    Background Information
    The PacketStatusOutServerInfo is a packet that that sends data (players, motd, etc.) about the server to the client which it displays in the server list. When the client sends a packet requesting this data the server creates a new 'ServerPing' instance which stores all of this instance. Then it creates a PacketStatusOutServerInfo instance with the ServerPing object as it's only argument. All of this happens in the PacketStatusListener class which invokes NetworkHandler#handle(Packet). This is the same method that PlayerConnection#sendPacket() uses. When the player joins the server an EntityPlayer instance is created and I believe the NetworkHandler corresponding to that EntityPlayer is created in the constructor. The NetworkHandler instance used when the server sends a PacketStatusOutServerInfo packet is created in this class. Then that class creates a new HandshakeListener, which creates a new PacketStatusListener using a MinecraftServer and the original NetworkHandler as arguments. I'm not sure if this is important, but it gives a decent background on whats going on.

    If I can get the outgoing PacketStatusOutServerInfo instance, then I can use reflection to get the 'b' field (ServerPing) which stores all of the information. So... Anyone have any ideas? You may need to get your decompiler out.
     
  2. Offline

    teej107

    @Skionz Could you do this with ProtocolLib? Why not look at its source?
     
  3. Offline

    Skionz

    @teej107 I have been searching, but so far no luck. Ill keep looking tomorrow.
     
Thread Status:
Not open for further replies.

Share This Page