Class PacketSendingUtils
java.lang.Object
net.minestom.server.utils.PacketSendingUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbroadcastPlayPacket(ServerPacket packet) static voidsendGroupedPacket(Collection<Player> players, ServerPacket packet) Same assendGroupedPacket(Collection, ServerPacket, Predicate)but without any predicate.static voidsendGroupedPacket(Collection<Player> players, ServerPacket packet, Predicate<Player> predicate) Sends aServerPacketto multiple players.static voidsendPacket(Audience audience, ServerPacket packet) Sends a packet to an audience.
-
Constructor Details
-
PacketSendingUtils
public PacketSendingUtils()
-
-
Method Details
-
sendPacket
Sends a packet to an audience. This method performs the following steps in the following order:- If
audienceis aPlayer, send the packet to them. - Otherwise, if
audienceis aPacketGroupingAudience, callsendGroupedPacket(Collection, ServerPacket)on the players that the grouping audience contains. - Otherwise, if
audienceis aForwardingAudience.Single, call this method on the single audience inside the forwarding audience. - Otherwise, if
audienceis aForwardingAudience, call this method for each audience member of the forwarding audience. - Otherwise, do nothing.
- Parameters:
audience- the audiencepacket- the packet
- If
-
sendGroupedPacket
public static void sendGroupedPacket(Collection<Player> players, ServerPacket packet, Predicate<Player> predicate) Sends aServerPacketto multiple players.Can drastically improve performance since the packet will not have to be processed as much.
- Parameters:
players- the players to send the packet topacket- the packet to send to the playerspredicate- predicate to ignore specific players
-
sendGroupedPacket
Same assendGroupedPacket(Collection, ServerPacket, Predicate)but without any predicate.- See Also:
-
broadcastPlayPacket
-