mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-29 04:28:21 +01:00
Reduce grouped packet buffer overhead
This commit is contained in:
parent
10224baa96
commit
d41a4dcf54
@ -84,7 +84,6 @@ public final class PacketUtils {
|
||||
|
||||
// work out if the packet needs to be sent individually due to server-side translating
|
||||
boolean needsTranslating = false;
|
||||
|
||||
if (AdventureSerializer.AUTOMATIC_COMPONENT_TRANSLATION && packet instanceof ComponentHoldingServerPacket) {
|
||||
needsTranslating = AdventureSerializer.areAnyTranslatable(((ComponentHoldingServerPacket) packet).components());
|
||||
}
|
||||
@ -98,16 +97,12 @@ public final class PacketUtils {
|
||||
|
||||
// Send packet to all players
|
||||
for (Player player : players) {
|
||||
|
||||
if (!player.isOnline())
|
||||
continue;
|
||||
|
||||
// Verify if the player should receive the packet
|
||||
if (playerValidator != null && !playerValidator.isValid(player))
|
||||
continue;
|
||||
|
||||
finalBuffer.retain();
|
||||
|
||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||
if (playerConnection instanceof NettyPlayerConnection) {
|
||||
final NettyPlayerConnection nettyPlayerConnection = (NettyPlayerConnection) playerConnection;
|
||||
@ -115,15 +110,12 @@ public final class PacketUtils {
|
||||
} else {
|
||||
playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
finalBuffer.release();
|
||||
}
|
||||
finalBuffer.release(); // Release last reference
|
||||
}
|
||||
} else {
|
||||
// Write the same packet for each individual players
|
||||
for (Player player : players) {
|
||||
|
||||
// Verify if the player should receive the packet
|
||||
if (playerValidator != null && !playerValidator.isValid(player))
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user