Skip to content

ProtocolManager

Dan Mulloy edited this page Dec 27, 2019 · 5 revisions

Now that you have ProtocolLib added to your project, it's time to start actually working with it. The ProtocolManager is your primary entry point to ProtocolLib. It can be accessed like this:

import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.ProtocolLibrary;

@Override
public void onEnable() {
    ProtocolManager manager = ProtocolLibrary.getProtocolManager();
    manager.addPacketListener(...);
}

The main methods you will be working with in the ProtocolManager are:

  • addPacketListener(PacketListener)
    • Tells ProtocolLib to listen for a given set of packets. See that wiki page for more info.
  • createPacket(PacketType)
    • Creates a packet of a given type, that you can then...
  • sendServerPacket(Player, PacketContainer)
    • Send a packet to a player

More advanced methods can be found in the JavaDocs: