mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-01-03 14:27:51 +01:00
Move packet construction of schedule send methods to event loop as well
Fixes #3306
This commit is contained in:
parent
a2e214ae18
commit
b67e3c30fd
@ -266,20 +266,37 @@ public class PacketWrapperImpl implements PacketWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void send0(Class<? extends Protocol> protocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception {
|
private void send0(Class<? extends Protocol> protocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception {
|
||||||
if (isCancelled()) return;
|
if (isCancelled()) {
|
||||||
|
return;
|
||||||
try {
|
|
||||||
ByteBuf output = constructPacket(protocol, skipCurrentPipeline, Direction.CLIENTBOUND);
|
|
||||||
if (currentThread) {
|
|
||||||
user().sendRawPacket(output);
|
|
||||||
} else {
|
|
||||||
user().scheduleSendRawPacket(output);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (!PipelineUtil.containsCause(e, CancelException.class)) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final UserConnection connection = user();
|
||||||
|
if (currentThread) {
|
||||||
|
try {
|
||||||
|
final ByteBuf output = constructPacket(protocol, skipCurrentPipeline, Direction.CLIENTBOUND);
|
||||||
|
connection.sendRawPacket(output);
|
||||||
|
} catch (final Exception e) {
|
||||||
|
if (!PipelineUtil.containsCause(e, CancelException.class)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.getChannel().eventLoop().submit(() -> {
|
||||||
|
try {
|
||||||
|
final ByteBuf output = constructPacket(protocol, skipCurrentPipeline, Direction.CLIENTBOUND);
|
||||||
|
connection.sendRawPacket(output);
|
||||||
|
} catch (final RuntimeException e) {
|
||||||
|
if (!PipelineUtil.containsCause(e, CancelException.class)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
} catch (final Exception e) {
|
||||||
|
if (!PipelineUtil.containsCause(e, CancelException.class)) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -434,7 +451,9 @@ public class PacketWrapperImpl implements PacketWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendToServerRaw(boolean currentThread) throws Exception {
|
private void sendToServerRaw(boolean currentThread) throws Exception {
|
||||||
if (isCancelled()) return;
|
if (isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
|
ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
|
||||||
try {
|
try {
|
||||||
@ -464,18 +483,33 @@ public class PacketWrapperImpl implements PacketWrapper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
final UserConnection connection = user();
|
||||||
ByteBuf output = constructPacket(protocol, skipCurrentPipeline, Direction.SERVERBOUND);
|
if (currentThread) {
|
||||||
if (currentThread) {
|
try {
|
||||||
user().sendRawPacketToServer(output);
|
final ByteBuf output = constructPacket(protocol, skipCurrentPipeline, Direction.SERVERBOUND);
|
||||||
} else {
|
connection.sendRawPacketToServer(output);
|
||||||
user().scheduleSendRawPacketToServer(output);
|
} catch (final Exception e) {
|
||||||
}
|
if (!PipelineUtil.containsCause(e, CancelException.class)) {
|
||||||
} catch (Exception e) {
|
throw e;
|
||||||
if (!PipelineUtil.containsCause(e, CancelException.class)) {
|
}
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connection.getChannel().eventLoop().submit(() -> {
|
||||||
|
try {
|
||||||
|
final ByteBuf output = constructPacket(protocol, skipCurrentPipeline, Direction.SERVERBOUND);
|
||||||
|
connection.sendRawPacketToServer(output);
|
||||||
|
} catch (final RuntimeException e) {
|
||||||
|
if (!PipelineUtil.containsCause(e, CancelException.class)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
} catch (final Exception e) {
|
||||||
|
if (!PipelineUtil.containsCause(e, CancelException.class)) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user