mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-10 12:50:17 +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
|
// work out if the packet needs to be sent individually due to server-side translating
|
||||||
boolean needsTranslating = false;
|
boolean needsTranslating = false;
|
||||||
|
|
||||||
if (AdventureSerializer.AUTOMATIC_COMPONENT_TRANSLATION && packet instanceof ComponentHoldingServerPacket) {
|
if (AdventureSerializer.AUTOMATIC_COMPONENT_TRANSLATION && packet instanceof ComponentHoldingServerPacket) {
|
||||||
needsTranslating = AdventureSerializer.areAnyTranslatable(((ComponentHoldingServerPacket) packet).components());
|
needsTranslating = AdventureSerializer.areAnyTranslatable(((ComponentHoldingServerPacket) packet).components());
|
||||||
}
|
}
|
||||||
@ -98,16 +97,12 @@ public final class PacketUtils {
|
|||||||
|
|
||||||
// Send packet to all players
|
// Send packet to all players
|
||||||
for (Player player : players) {
|
for (Player player : players) {
|
||||||
|
|
||||||
if (!player.isOnline())
|
if (!player.isOnline())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Verify if the player should receive the packet
|
// Verify if the player should receive the packet
|
||||||
if (playerValidator != null && !playerValidator.isValid(player))
|
if (playerValidator != null && !playerValidator.isValid(player))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
finalBuffer.retain();
|
|
||||||
|
|
||||||
final PlayerConnection playerConnection = player.getPlayerConnection();
|
final PlayerConnection playerConnection = player.getPlayerConnection();
|
||||||
if (playerConnection instanceof NettyPlayerConnection) {
|
if (playerConnection instanceof NettyPlayerConnection) {
|
||||||
final NettyPlayerConnection nettyPlayerConnection = (NettyPlayerConnection) playerConnection;
|
final NettyPlayerConnection nettyPlayerConnection = (NettyPlayerConnection) playerConnection;
|
||||||
@ -115,15 +110,12 @@ public final class PacketUtils {
|
|||||||
} else {
|
} else {
|
||||||
playerConnection.sendPacket(packet);
|
playerConnection.sendPacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
finalBuffer.release();
|
|
||||||
}
|
}
|
||||||
finalBuffer.release(); // Release last reference
|
finalBuffer.release(); // Release last reference
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Write the same packet for each individual players
|
// Write the same packet for each individual players
|
||||||
for (Player player : players) {
|
for (Player player : players) {
|
||||||
|
|
||||||
// Verify if the player should receive the packet
|
// Verify if the player should receive the packet
|
||||||
if (playerValidator != null && !playerValidator.isValid(player))
|
if (playerValidator != null && !playerValidator.isValid(player))
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user