mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Include original packet in FramedPacket
for debugging/listening purpose
This commit is contained in:
parent
17f9eb45ca
commit
d4f74abc64
@ -1,5 +1,7 @@
|
||||
package net.minestom.server.network.packet;
|
||||
|
||||
import net.minestom.server.network.packet.server.ServerPacket;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@ -8,13 +10,16 @@ import java.nio.ByteBuffer;
|
||||
* Represents a packet which is already framed. (packet id+payload) + optional compression
|
||||
* Can be used if you want to send the exact same buffer to multiple clients without processing it more than once.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public final class FramedPacket {
|
||||
private final int packetId;
|
||||
private final ByteBuffer body;
|
||||
private final ServerPacket packet;
|
||||
|
||||
public FramedPacket(int packetId, @NotNull ByteBuffer body) {
|
||||
public FramedPacket(int packetId, @NotNull ByteBuffer body, @NotNull ServerPacket packet) {
|
||||
this.packetId = packetId;
|
||||
this.body = body;
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
public int packetId() {
|
||||
@ -24,4 +29,8 @@ public final class FramedPacket {
|
||||
public @NotNull ByteBuffer body() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public @NotNull ServerPacket packet() {
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public final class PacketUtils {
|
||||
if (!PACKET_LISTENER_MANAGER.processServerPacket(packet, players))
|
||||
return;
|
||||
final ByteBuffer finalBuffer = createFramedPacket(packet);
|
||||
final FramedPacket framedPacket = new FramedPacket(packet.getId(), finalBuffer);
|
||||
final FramedPacket framedPacket = new FramedPacket(packet.getId(), finalBuffer, packet);
|
||||
// Send packet to all players
|
||||
for (Player player : players) {
|
||||
if (!player.isOnline() || !playerValidator.isValid(player))
|
||||
|
Loading…
Reference in New Issue
Block a user