9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-30 20:39:10 +00:00

refactor(network): 重构发送包方法以便全部阶段都可发送包

This commit is contained in:
jhqwqmc
2025-05-31 16:31:36 +08:00
parent 34c9416056
commit a35db2b8f4

View File

@@ -302,7 +302,7 @@ public class BukkitServerPlayer extends Player {
dataPayload = Reflections.constructor$DiscardedPayload.newInstance(channelKey, Unpooled.wrappedBuffer(data));
}
Object responsePacket = Reflections.constructor$ClientboundCustomPayloadPacket.newInstance(dataPayload);
this.nettyChannel().writeAndFlush(responsePacket, true);
this.sendPacket(responsePacket, true);
} catch (Exception e) {
CraftEngine.instance().logger().warn("Failed to send custom payload to " + name(), e);
}
@@ -313,7 +313,7 @@ public class BukkitServerPlayer extends Player {
try {
Object reason = ComponentUtils.adventureToMinecraft(message);
Object kickPacket = Reflections.constructor$ClientboundDisconnectPacket.newInstance(reason);
this.nettyChannel().writeAndFlush(kickPacket, true);
this.sendPacket(kickPacket, true);
this.nettyChannel().disconnect();
} catch (Exception e) {
CraftEngine.instance().logger().warn("Failed to kick " + name(), e);