Skip to content

Commit

Permalink
small optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
AoElite committed Jan 1, 2024
1 parent ea11ec9 commit 02c3007
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/ac/grim/grimac/player/GrimPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ public void sendTransaction(boolean async) {
lastTransSent = System.currentTimeMillis();
short transactionID = (short) (-1 * (transactionIDCounter.getAndIncrement() & 0x7FFF));
try {
addTransactionSend(transactionID);

PacketWrapper<?> packet;
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_17)) {
Expand All @@ -377,8 +376,12 @@ public void sendTransaction(boolean async) {
}

if (async) {
ChannelHelper.runInEventLoop(user.getChannel(), () -> user.writePacket(packet));
ChannelHelper.runInEventLoop(user.getChannel(), () -> {
addTransactionSend(transactionID);
user.writePacket(packet);
});
} else {
addTransactionSend(transactionID);
user.writePacket(packet);
}
} catch (
Expand Down

0 comments on commit 02c3007

Please sign in to comment.