mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-16 21:21:22 +01:00
Merge branch 'master' into viewable-broadcast
# Conflicts: # src/main/java/net/minestom/server/network/player/PlayerSocketConnection.java
This commit is contained in:
commit
e19b49db55
@ -124,7 +124,7 @@ public class DynamicChunk extends Chunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChunk(@NotNull Player player) {
|
||||
public synchronized void sendChunk(@NotNull Player player) {
|
||||
if (!isLoaded()) return;
|
||||
final PlayerConnection connection = player.getPlayerConnection();
|
||||
final long lastChange = getLastChangeTime();
|
||||
@ -141,7 +141,7 @@ public class DynamicChunk extends Chunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendChunk() {
|
||||
public synchronized void sendChunk() {
|
||||
if (!isLoaded()) return;
|
||||
if (getViewers().isEmpty()) return;
|
||||
final long lastChange = getLastChangeTime();
|
||||
|
@ -75,7 +75,7 @@ public class PlayerSocketConnection extends PlayerConnection {
|
||||
|
||||
private final Object bufferLock = new Object();
|
||||
private final List<BinaryBuffer> waitingBuffers = new ArrayList<>();
|
||||
private BinaryBuffer tickBuffer = BinaryBuffer.ofSize(BUFFER_SIZE);
|
||||
private BinaryBuffer tickBuffer = getPooledBuffer();
|
||||
private volatile BinaryBuffer cacheBuffer;
|
||||
|
||||
public PlayerSocketConnection(@NotNull Worker worker, @NotNull SocketChannel channel, SocketAddress remoteAddress) {
|
||||
@ -300,6 +300,8 @@ public class PlayerSocketConnection extends PlayerConnection {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Update tick buffer
|
||||
this.tickBuffer = getPooledBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
@ -460,4 +462,14 @@ public class PlayerSocketConnection extends PlayerConnection {
|
||||
public void setNonce(byte[] nonce) {
|
||||
this.nonce = nonce;
|
||||
}
|
||||
|
||||
private static BinaryBuffer getPooledBuffer() {
|
||||
BinaryBuffer newBuffer = POOLED_BUFFERS.poll();
|
||||
if (newBuffer == null) {
|
||||
newBuffer = BinaryBuffer.ofSize(BUFFER_SIZE);
|
||||
} else {
|
||||
newBuffer.clear();
|
||||
}
|
||||
return newBuffer;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user