Package net.minestom.server.utils
Class PacketUtils
java.lang.Object
net.minestom.server.utils.PacketUtils
public final class PacketUtils
extends java.lang.Object
Utils class for packets. Including writing a
ServerPacket
into a ByteBuf
for network processing.-
Method Summary
Modifier and Type Method Description static void
sendGroupedPacket(java.util.Collection<Player> players, ServerPacket packet)
Sends aServerPacket
to multiple players.static void
writePacket(io.netty.buffer.ByteBuf buf, ServerPacket packet)
Writes aServerPacket
into aByteBuf
.static io.netty.buffer.ByteBuf
writePacket(ServerPacket packet)
Writes aServerPacket
into a newly createdByteBuf
.
-
Method Details
-
sendGroupedPacket
public static void sendGroupedPacket(@NotNull java.util.Collection<Player> players, @NotNull ServerPacket packet)Sends aServerPacket
to multiple players. Mostly used for convenience.Be aware that this will cause the send packet listeners to be given the exact same packet object.
- Parameters:
players
- the players to send the packet topacket
- the packet to send to the players
-
writePacket
Writes aServerPacket
into aByteBuf
.- Parameters:
buf
- the recipient ofpacket
packet
- the packet to write intobuf
-
writePacket
Writes aServerPacket
into a newly createdByteBuf
.- Parameters:
packet
- the packet to write- Returns:
- a
ByteBuf
containingpacket
-