Skip to content

Sending packets

Nico edited this page Aug 31, 2021 · 3 revisions

Sending packets is pretty straight forward. Just obtain an instance of ProtocolizePlayer using the ProtocolizePlayerProvider and call the sendPacket method.

Sending a packet to a client (for example a CloseWindow packet):

ProtocolizePlayer player = Protocolize.playerProvider().player(playerUniqueId);
player.sendPacket(new CloseWindow(id));

Sending a packet to a players server (for example a HeldItemChange packet):

ProtocolizePlayer player = Protocolize.playerProvider().player(playerUniqueId);
player.sendPacketToServer(new HeldItemChange(slot));

Sendable packets

You can send all packets that are extending dev.simplix.protocolize.api.packet.AbstractPacket. Additionally, you also can send all platform implemented packets like:

  • Velocity: All packets extending com.velocitypowered.proxy.protocol.MinecraftPacket
  • BungeeCord: All packets extending net.md_5.bungee.protocol.DefinedPacket