Skip to content

Commit

Permalink
Release packets after it has been locked.
Browse files Browse the repository at this point in the history
  • Loading branch information
larryTheCoder committed Mar 26, 2023
1 parent 2b59142 commit 6441a07
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@ public void sendPacket(BedrockBatchWrapper wrapper) {
packetSendingLimit.set(this.packetSendingLimit.get() + wrapper.getPackets().size());

if (packetSendingLimit.get() >= MAX_UPSTREAM_PACKETS) {
wrapper.release();

if (packetSendingLock.compareAndSet(false, true)) {
getPlayer().getLogger().warning(getPlayer().getName() + " sent too many packets (" + packetSendingLimit.get() + "/s), disconnecting.");
getPlayer().getConnection().disconnect("§cToo many packets!");
}
} else if (!packetSendingLock.get()) {
super.sendPacket(wrapper);
return;
}

wrapper.release();
}

@Override
Expand Down

0 comments on commit 6441a07

Please sign in to comment.